UNPKG

stellar-plus

Version:

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

32 lines (31 loc) 1.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ExtractInvocationOutputPlugin = void 0; const tslib_1 = require("tslib"); const types_1 = require("../../../../../../stellar-plus/core/pipelines/soroban-get-transaction/types"); class ExtractInvocationOutputPlugin { constructor(spec, method) { this.type = types_1.SorobanGetTransactionPipelineType.id; this.name = 'ExtractInvocationOutputPlugin'; this.spec = spec; this.method = method; } postProcess(item, _meta) { return tslib_1.__awaiter(this, void 0, void 0, function* () { var _a, _b; const { response, output } = item; let value; try { value = this.spec.funcResToNative(this.method, (_b = (_a = response.resultMetaXdr.v4().sorobanMeta()) === null || _a === void 0 ? void 0 : _a.returnValue()) === null || _b === void 0 ? void 0 : _b.toXDR('base64')); } catch (e) { value = {}; } const pluginOutput = { value: String(value), }; return Object.assign(Object.assign({}, item), { output: Object.assign(Object.assign({}, output), pluginOutput) }); }); } } exports.ExtractInvocationOutputPlugin = ExtractInvocationOutputPlugin;