UNPKG

stellar-plus

Version:

beta version of stellar-plus, an all-in-one sdk for the Stellar blockchain

27 lines (26 loc) 1.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ExtractInvocationOutputFromSimulationPlugin = void 0; const tslib_1 = require("tslib"); const types_1 = require("../../../../../../stellar-plus/core/pipelines/simulate-transaction/types"); class ExtractInvocationOutputFromSimulationPlugin { constructor(spec, method) { this.type = types_1.SimulateTransactionPipelineType.id; this.name = 'ExtractContractIdPlugin'; this.spec = spec; this.method = method; } postProcess(item, _meta) { return tslib_1.__awaiter(this, void 0, void 0, function* () { const { response, output } = item; if (!response.result) { throw new Error('simulationMissingResult'); } const value = this.spec.funcResToNative(this.method, response.result.retval); const pluginOutput = { value }; const updatedItem = Object.assign(Object.assign({}, item), { output: Object.assign(Object.assign({}, output), pluginOutput) }); return updatedItem; }); } } exports.ExtractInvocationOutputFromSimulationPlugin = ExtractInvocationOutputFromSimulationPlugin;