UNPKG

@sovrano-io/auth-sdk

Version:

Sovrano wallet auth sdk for koinos dapps

46 lines 1.77 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Account = void 0; const koilib_1 = require("koilib"); const config_1 = require("./config"); class Account { constructor(props) { this.address = props.address; this.provider = props.provider; } async allow(props) { var _a; const validation_module_contract = new koilib_1.Contract({ id: (_a = props.validationContractId) !== null && _a !== void 0 ? _a : (0, config_1.getConfig)().modAllowanceContractId, provider: this.provider }); await validation_module_contract.fetchAbi(); const { operation: allow } = await validation_module_contract.functions["allow"]({ user: this.address, operation: { contract_id: props.operation.call_contract.contract_id, entry_point: props.operation.call_contract.entry_point, args: props.operation.call_contract.args } }, { onlyOperation: true }); return allow; } async execute(props) { var _a; const contract = new koilib_1.Contract({ id: this.address, provider: this.provider }); await contract.fetchAbi(); const { operation: exec } = await contract.functions[(_a = props.mode) !== null && _a !== void 0 ? _a : "execute_user"]({ operation: { contract_id: props.operation.call_contract.contract_id, entry_point: props.operation.call_contract.entry_point, args: props.operation.call_contract.args } }, { onlyOperation: true }); return exec; } } exports.Account = Account; //# sourceMappingURL=Account.js.map