UNPKG

lisk-framework

Version:

Lisk blockchain application platform

32 lines 1.64 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RandomMethod = void 0; const lisk_codec_1 = require("@liskhq/lisk-codec"); const base_method_1 = require("../base_method"); const constants_1 = require("../validators/constants"); const schemas_1 = require("./schemas"); const validator_reveals_1 = require("./stores/validator_reveals"); const utils_1 = require("./utils"); class RandomMethod extends base_method_1.BaseMethod { constructor(stores, events, moduleName) { super(stores, events); this._moduleName = moduleName; } async isSeedRevealValid(methodContext, generatorAddress, blockAssets) { const randomDataStore = this.stores.get(validator_reveals_1.ValidatorRevealsStore); const { validatorReveals } = await randomDataStore.get(methodContext, constants_1.EMPTY_KEY); const asset = blockAssets.getAsset(this._moduleName); if (!asset) { throw new Error('Block asset is missing.'); } const { seedReveal } = lisk_codec_1.codec.decode(schemas_1.blockHeaderAssetRandomModule, asset); return (0, utils_1.getSeedRevealValidity)(generatorAddress, seedReveal, validatorReveals); } async getRandomBytes(methodContext, height, numberOfSeeds) { const randomDataStore = this.stores.get(validator_reveals_1.ValidatorRevealsStore); const { validatorReveals } = await randomDataStore.get(methodContext, constants_1.EMPTY_KEY); return (0, utils_1.getRandomSeed)(height, numberOfSeeds, validatorReveals); } } exports.RandomMethod = RandomMethod; //# sourceMappingURL=method.js.map