@aut-labs/sdk
Version:
The TS/JS SDK package aims to make it easy for frontends/backends to integrate with Aut Smart Contracts
44 lines • 1.62 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CommitmentContract = void 0;
const abi_types_1 = require("@aut-labs/abi-types");
const response_1 = require("../models/response");
const base_contract_1 = __importDefault(require("./base.contract"));
const find_event_1 = require("../utils/find-event");
class CommitmentContract extends base_contract_1.default {
async getCommitment() {
try {
const commitment = await this.functions.commitmentLevel();
return new response_1.SDKContractGenericResponse({
isSuccess: true,
data: commitment.toString()
});
}
catch (error) {
return new response_1.SDKContractGenericResponse({
error
});
}
}
async setCommitment(commitment) {
try {
// @ts-ignore
const tx = await (await this.functions.setCommitment(commitment)).wait();
const event = (0, find_event_1.findLogEvent)(tx, abi_types_1.HubContractEventType.CommitmentSet);
return new response_1.SDKContractGenericResponse({
isSuccess: !!event,
event,
});
}
catch (error) {
return new response_1.SDKContractGenericResponse({
error
});
}
}
}
exports.CommitmentContract = CommitmentContract;
//# sourceMappingURL=commitment.contract.js.map