stellar-plus
Version:
beta version of stellar-plus, an all-in-one sdk for the Stellar blockchain
31 lines (30 loc) • 1.31 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExtractContractIdPlugin = void 0;
const tslib_1 = require("tslib");
const stellar_sdk_1 = require("@stellar/stellar-sdk");
const types_1 = require("../../../../../../stellar-plus/core/pipelines/soroban-get-transaction/types");
class ExtractContractIdPlugin {
constructor() {
this.type = types_1.SorobanGetTransactionPipelineType.id;
this.name = 'ExtractContractIdPlugin';
}
postProcess(item, _meta) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
var _a, _b;
const { response, output } = item;
let contractId;
try {
contractId = stellar_sdk_1.Address.fromScAddress((_b = (_a = response.resultMetaXdr.v4().sorobanMeta()) === null || _a === void 0 ? void 0 : _a.returnValue()) === null || _b === void 0 ? void 0 : _b.address()).toString();
}
catch (e) {
contractId = '';
}
const pluginOutput = {
contractId,
};
return Object.assign(Object.assign({}, item), { output: Object.assign(Object.assign({}, output), pluginOutput) });
});
}
}
exports.ExtractContractIdPlugin = ExtractContractIdPlugin;