UNPKG

lisk-framework

Version:

Lisk blockchain application platform

86 lines 2.68 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ChannelDataStore = exports.channelSchema = void 0; const lisk_tree_1 = require("@liskhq/lisk-tree"); const base_store_1 = require("../../base_store"); const constants_1 = require("../constants"); const constants_2 = require("../../token/constants"); const inboxOutboxProps = { appendPath: { type: 'array', items: { dataType: 'bytes', minLength: constants_1.HASH_LENGTH, maxLength: constants_1.HASH_LENGTH, }, fieldNumber: 1, }, size: { dataType: 'uint32', fieldNumber: 2, }, root: { dataType: 'bytes', minLength: constants_1.HASH_LENGTH, maxLength: constants_1.HASH_LENGTH, fieldNumber: 3, }, }; exports.channelSchema = { $id: '/modules/interoperability/channel', type: 'object', required: [ 'inbox', 'outbox', 'partnerChainOutboxRoot', 'messageFeeTokenID', 'minReturnFeePerByte', ], properties: { inbox: { type: 'object', fieldNumber: 1, required: ['appendPath', 'size', 'root'], properties: inboxOutboxProps, }, outbox: { type: 'object', fieldNumber: 2, required: ['appendPath', 'size', 'root'], properties: inboxOutboxProps, }, partnerChainOutboxRoot: { dataType: 'bytes', minLength: constants_1.HASH_LENGTH, maxLength: constants_1.HASH_LENGTH, fieldNumber: 3, }, messageFeeTokenID: { dataType: 'bytes', minLength: constants_2.TOKEN_ID_LENGTH, maxLength: constants_2.TOKEN_ID_LENGTH, fieldNumber: 4, }, minReturnFeePerByte: { dataType: 'uint64', fieldNumber: 5, }, }, }; class ChannelDataStore extends base_store_1.BaseStore { constructor() { super(...arguments); this.schema = exports.channelSchema; } get storePrefix() { return constants_1.STORE_PREFIX; } async updatePartnerChainOutboxRoot(context, chainID, messageWitnessHashes) { const channel = await this.get(context, chainID); const outboxRoot = lisk_tree_1.regularMerkleTree.calculateRootFromRightWitness(channel.inbox.size, channel.inbox.appendPath, messageWitnessHashes); channel.partnerChainOutboxRoot = outboxRoot; await this.set(context, chainID, channel); } } exports.ChannelDataStore = ChannelDataStore; //# sourceMappingURL=channel_data.js.map