@okxweb3/coin-stellar
Version:
@ok/coin-stellar is a Stellar SDK for building Web3 wallets and applications. It supports Stellar and PI blockchains, enabling private key management, address generation, transaction signing, trustline creation, and asset transfers
57 lines • 2.71 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FeeBumpTransaction = void 0;
const xdr_1 = __importDefault(require("./xdr"));
const hashing_1 = require("./hashing");
const transaction_1 = require("./transaction");
const transaction_base_1 = require("./transaction_base");
const decode_encode_muxed_account_1 = require("./util/decode_encode_muxed_account");
class FeeBumpTransaction extends transaction_base_1.TransactionBase {
constructor(envelope, networkPassphrase) {
if (typeof envelope === 'string') {
const buffer = Buffer.from(envelope, 'base64');
envelope = xdr_1.default.TransactionEnvelope.fromXDR(buffer);
}
const envelopeType = envelope.switch();
if (envelopeType !== xdr_1.default.EnvelopeType.envelopeTypeTxFeeBump()) {
throw new Error(`Invalid TransactionEnvelope: expected an envelopeTypeTxFeeBump but received an ${envelopeType.name}.`);
}
const txEnvelope = envelope.value();
const tx = txEnvelope.tx();
const fee = tx.fee().toString();
const signatures = (txEnvelope.signatures() || []).slice();
super(tx, signatures, fee, networkPassphrase);
const innerTxEnvelope = xdr_1.default.TransactionEnvelope.envelopeTypeTx(tx.innerTx().v1());
this._feeSource = (0, decode_encode_muxed_account_1.encodeMuxedAccountToAddress)(this.tx.feeSource());
this._innerTransaction = new transaction_1.Transaction(innerTxEnvelope, networkPassphrase);
}
get innerTransaction() {
return this._innerTransaction;
}
get operations() {
return this._innerTransaction.operations;
}
get feeSource() {
return this._feeSource;
}
signatureBase() {
const taggedTransaction = new xdr_1.default.TransactionSignaturePayloadTaggedTransaction.envelopeTypeTxFeeBump(this.tx);
const txSignature = new xdr_1.default.TransactionSignaturePayload({
networkId: xdr_1.default.Hash.fromXDR((0, hashing_1.hash)(this.networkPassphrase)),
taggedTransaction
});
return txSignature.toXDR();
}
toEnvelope() {
const envelope = new xdr_1.default.FeeBumpTransactionEnvelope({
tx: xdr_1.default.FeeBumpTransaction.fromXDR(this.tx.toXDR()),
signatures: this.signatures.slice()
});
return new xdr_1.default.TransactionEnvelope.envelopeTypeTxFeeBump(envelope);
}
}
exports.FeeBumpTransaction = FeeBumpTransaction;
//# sourceMappingURL=fee_bump_transaction.js.map