UNPKG

lisk-framework

Version:

Lisk blockchain application platform

33 lines 1.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RewardEndpoint = void 0; const base_endpoint_1 = require("../base_endpoint"); const calculate_reward_1 = require("./calculate_reward"); class RewardEndpoint extends base_endpoint_1.BaseEndpoint { init(config, blockTime) { this._config = config; this._blockTime = blockTime; } getDefaultRewardAtHeight(context) { const { height } = context.params; if (typeof height !== 'number') { throw new Error('Parameter height must be a number.'); } if (height < 0) { throw new Error('Parameter height cannot be smaller than 0.'); } const reward = (0, calculate_reward_1.calculateDefaultReward)(this._config, height); return { reward: reward.toString() }; } getRewardTokenID() { return { tokenID: this._config.tokenID.toString('hex') }; } getAnnualInflation(context) { const reward = BigInt(this.getDefaultRewardAtHeight(context).reward); const blocksPerYear = BigInt(Math.floor((365 * 24 * 60 * 60) / this._blockTime)); const rate = blocksPerYear * reward; return { tokenID: this._config.tokenID.toString('hex'), rate: rate.toString() }; } } exports.RewardEndpoint = RewardEndpoint; //# sourceMappingURL=endpoint.js.map