UNPKG

lisk-framework

Version:

Lisk blockchain application platform

48 lines 2.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SubmitSidechainCrossChainUpdateCommand = void 0; const state_machine_1 = require("../../../../state_machine"); const panic_1 = require("../../../../utils/panic"); const base_cross_chain_update_command_1 = require("../../base_cross_chain_update_command"); const constants_1 = require("../../constants"); const utils_1 = require("../../utils"); class SubmitSidechainCrossChainUpdateCommand extends base_cross_chain_update_command_1.BaseCrossChainUpdateCommand { async verify(context) { await this.verifyCommon(context, false); return { status: state_machine_1.VerifyStatus.OK, }; } async execute(context) { const { params } = context; await this.verifyCertificateSignatureAndPartnerChainOutboxRoot(context); const [decodedCCMs, ok] = await this.beforeCrossChainMessagesExecution(context, false); if (!ok) { return; } try { context.contextStore.set(constants_1.CONTEXT_STORE_KEY_CCM_PROCESSING, true); for (let i = 0; i < decodedCCMs.length; i += 1) { const ccm = decodedCCMs[i]; const ccmBytes = params.inboxUpdate.crossChainMessages[i]; const ccmID = (0, utils_1.getIDFromCCMBytes)(ccmBytes); const ccmContext = { ...context, ccm, eventQueue: context.eventQueue.getChildQueue(Buffer.concat([constants_1.EVENT_TOPIC_CCM_EXECUTION, ccmID])), }; await this.apply(ccmContext); await this.internalMethod.appendToInboxTree(context, params.sendingChainID, ccmBytes); } } catch (error) { (0, panic_1.panic)(context.logger, error); } finally { context.contextStore.delete(constants_1.CONTEXT_STORE_KEY_CCM_PROCESSING); } await this.afterCrossChainMessagesExecute(context); } } exports.SubmitSidechainCrossChainUpdateCommand = SubmitSidechainCrossChainUpdateCommand; //# sourceMappingURL=submit_sidechain_cross_chain_update.js.map