UNPKG

@swaptoshi/governance-module

Version:

Klayr governance on-chain module

32 lines 1.37 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CreateProposalCommand = void 0; const klayr_framework_1 = require("klayr-framework"); const context_1 = require("../stores/context"); const proposal_1 = require("../stores/proposal"); const schema_1 = require("../schema"); class CreateProposalCommand extends klayr_framework_1.Modules.BaseCommand { constructor() { super(...arguments); this.schema = schema_1.createProposalCommandSchema; } async verify(_context) { try { const context = (0, context_1.immutableTransactionHookGovernanceContext)(_context); await this.stores.get(proposal_1.ProposalStore).verifyCreateProposal(context, _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); await this.stores.get(proposal_1.ProposalStore).createProposal(context, _context.params, false); } } exports.CreateProposalCommand = CreateProposalCommand; //# sourceMappingURL=create_proposal_command.js.map