@swaptoshi/governance-module
Version:
Klayr governance on-chain module
37 lines • 1.7 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DelegatedVoteStore = void 0;
const schema_1 = require("../schema");
const base_1 = require("./base");
const instances_1 = require("./instances");
class DelegatedVoteStore extends base_1.BaseStoreWithInstance {
constructor() {
super(...arguments);
this.schema = schema_1.delegatedVoteStoreSchema;
this.default = { outgoingDelegation: Buffer.alloc(0), incomingDelegation: [] };
}
async getMutableDelegatedVote(ctx) {
this._checkDependencies();
const delegatedVoteData = await this.getOrDefault(ctx.context, ctx.senderAddress);
const delegatedVote = new instances_1.DelegatedVote(this.stores, this.events, this.config, this.genesisConfig, this.moduleName, delegatedVoteData, ctx.senderAddress);
delegatedVote.addMutableDependencies({
context: ctx,
tokenMethod: this.tokenMethod,
internalMethod: this.internalMethod,
});
return delegatedVote;
}
async getImmutableDelegatedVote(ctx) {
this._checkDependencies();
const delegatedVoteData = await this.getOrDefault(ctx.context, ctx.senderAddress);
const delegatedVote = new instances_1.DelegatedVote(this.stores, this.events, this.config, this.genesisConfig, this.moduleName, delegatedVoteData, ctx.senderAddress);
delegatedVote.addImmutableDependencies({
context: ctx,
tokenMethod: this.tokenMethod,
internalMethod: this.internalMethod,
});
return delegatedVote;
}
}
exports.DelegatedVoteStore = DelegatedVoteStore;
//# sourceMappingURL=delegated_vote.js.map