Skip to content

Commit

Permalink
Add shortcut to accessing Soroban resources
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaptic committed Jan 23, 2025
1 parent 68b8bae commit 5c4df38
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,21 @@ export class Transaction extends TransactionBase {
throw new Error('Transaction is immutable');
}

/** @type {xdr.SorobanResources|null} */
get sorobanResources() {
if (this._envelopeType == xdr.EnvelopeType.envelopeTypeTx()) {
ext = this._tx.v1().tx().ext()
if (ext.switch() == 1) {
return ext.sorobanData().resources();
}
}

return null;
}
set sorobanResources(value) {
throw new Error('Transaction is immutable');
}

/**
* @type {object}
* @property {number} minLedger - smallest ledger bound (uint32)
Expand Down
1 change: 1 addition & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,7 @@ export class Transaction<
minAccountSequenceAge?: number;
minAccountSequenceLedgerGap?: number;
extraSigners?: string[];
sorobanResources?: xdr.SorobanResources;

getClaimableBalanceId(opIndex: number): string;
}
Expand Down

0 comments on commit 5c4df38

Please sign in to comment.