@swaptoshi/governance-module
Version:
Klayr governance on-chain module
30 lines • 1.04 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.VoteScoreStore = void 0;
const klayr_framework_1 = require("klayr-framework");
const db = require("@liskhq/lisk-db");
const schema_1 = require("../schema");
class VoteScoreStore extends klayr_framework_1.Modules.BaseStore {
constructor() {
super(...arguments);
this.schema = schema_1.voteScoreStoreSchema;
}
async getVoteScore(context, address) {
try {
const voteScore = await this.get(context, address);
return voteScore.score;
}
catch (error) {
if (!(error instanceof db.NotFoundError)) {
throw error;
}
return BigInt(0);
}
}
async addVoteScore(context, address, addedVote) {
const voteScore = await this.getVoteScore(context, address);
await this.set(context, address, { score: voteScore + addedVote });
}
}
exports.VoteScoreStore = VoteScoreStore;
//# sourceMappingURL=vote_score.js.map