UNPKG

@swaptoshi/governance-module

Version:

Klayr governance on-chain module

34 lines 1.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RevokeDelegatedVoteCommand = void 0; const klayr_framework_1 = require("klayr-framework"); const context_1 = require("../stores/context"); const delegated_vote_1 = require("../stores/delegated_vote"); const schema_1 = require("../schema"); class RevokeDelegatedVoteCommand extends klayr_framework_1.Modules.BaseCommand { constructor() { super(...arguments); this.schema = schema_1.revokeDelegatedVoteCommandSchema; } async verify(_context) { try { const context = (0, context_1.immutableTransactionHookGovernanceContext)(_context); const delegatedVote = await this.stores.get(delegated_vote_1.DelegatedVoteStore).getImmutableDelegatedVote(context); await delegatedVote.verifyRevokeDelegatedVote(_context.params); } catch (error) { return { status: klayr_framework_1.StateMachine.VerifyStatus.FAIL, error: new Error(error.message), }; } return { status: klayr_framework_1.StateMachine.VerifyStatus.OK }; } async execute(_context) { const context = (0, context_1.mutableTransactionHookGovernanceContext)(_context); const delegatedVote = await this.stores.get(delegated_vote_1.DelegatedVoteStore).getMutableDelegatedVote(context); await delegatedVote.revokeDelegatedVote(_context.params, false); } } exports.RevokeDelegatedVoteCommand = RevokeDelegatedVoteCommand; //# sourceMappingURL=revoke_delegated_vote_command.js.map