UNPKG

stellar-plus

Version:

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

36 lines (35 loc) 1.86 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FeeBumpPipeline = void 0; const tslib_1 = require("tslib"); const stellar_sdk_1 = require("@stellar/stellar-sdk"); const types_1 = require("../../../../stellar-plus/core/pipelines/fee-bump/types"); const conveyor_belt_1 = require("../../../../stellar-plus/error/helpers/conveyor-belt"); const conveyor_belts_1 = require("../../../../stellar-plus/utils/pipeline/conveyor-belts"); const errors_1 = require("./errors"); class FeeBumpPipeline extends conveyor_belts_1.ConveyorBelt { constructor(plugins) { super({ type: types_1.FeeBumpPipelineType.id, plugins: plugins || [], }); } process(item, itemId) { return tslib_1.__awaiter(this, void 0, void 0, function* () { const { innerTransaction, feeBumpHeader } = item; const networkPassphrase = innerTransaction.networkPassphrase; try { // The conversion to and from XDR seems unnecessary, but it's the only way to // get the fee bump transaction to be properly signed. // Not fully sure if a bug in the SDK or the way we build the transaction yet // Needs further investigation. const feeBumpTransaction = stellar_sdk_1.TransactionBuilder.buildFeeBumpTransaction(feeBumpHeader.header.source, feeBumpHeader.header.fee, stellar_sdk_1.TransactionBuilder.fromXDR(innerTransaction.toXDR(), networkPassphrase), networkPassphrase); return feeBumpTransaction; } catch (error) { throw errors_1.PFBError.couldntWrapFeeBump(error, (0, conveyor_belt_1.extractConveyorBeltErrorMeta)(item, this.getMeta(itemId)), innerTransaction); } }); } } exports.FeeBumpPipeline = FeeBumpPipeline;