From ed89fec3bb0b01d256300a94fe8ccf50cfda9ee5 Mon Sep 17 00:00:00 2001 From: George Date: Thu, 12 Sep 2024 10:35:11 -0700 Subject: [PATCH] Add missing methods to TypeScript definitions (#766) --- CHANGELOG.md | 1 + types/index.d.ts | 4 ++++ types/test.ts | 6 ++++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dff728a4..0dc79392 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unreleased ### Fixed +* Add missing methods to TypeScript definitions ([#766](https://github.com/stellar/js-stellar-base/pull/766)). * Fix the TypeScript definition of `walkInvocationTree` to allow void returns on the callback function as intended rather than forcing a `return null` ([#765](https://github.com/stellar/js-stellar-base/pull/765)). diff --git a/types/index.d.ts b/types/index.d.ts index 9d0ca2bc..2b188831 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1019,6 +1019,7 @@ export class FeeBumpTransaction extends TransactionI { ); feeSource: string; innerTransaction: Transaction; + get operations(): Operation[]; } export class Transaction< @@ -1058,7 +1059,9 @@ export class TransactionBuilder { options?: TransactionBuilder.TransactionBuilderOptions ); addOperation(operation: xdr.Operation): this; + addOperationAt(op: xdr.Operation, i: number): this; clearOperations(): this; + clearOperationAt(i: number): this; addMemo(memo: Memo): this; setTimeout(timeoutInSeconds: number): this; setTimebounds(min: Date | number, max: Date | number): this; @@ -1085,6 +1088,7 @@ export class TransactionBuilder { envelope: string | xdr.TransactionEnvelope, networkPassphrase: string ): Transaction | FeeBumpTransaction; + } export namespace TransactionBuilder { diff --git a/types/test.ts b/types/test.ts index 2dba861e..1d9a1dfe 100644 --- a/types/test.ts +++ b/types/test.ts @@ -134,11 +134,13 @@ const transaction = new StellarSdk.TransactionBuilder(account, { minAmountA: "10000", minAmountB: "20000", }) - ).addOperation( + ).addOperationAt( StellarSdk.Operation.setOptions({ setFlags: (StellarSdk.AuthImmutableFlag | StellarSdk.AuthRequiredFlag) as StellarSdk.AuthFlag, clearFlags: (StellarSdk.AuthRevocableFlag | StellarSdk.AuthClawbackEnabledFlag) as StellarSdk.AuthFlag, - }) + }), + 0 + ).clearOperationAt(2 ).addMemo(new StellarSdk.Memo(StellarSdk.MemoText, 'memo')) .setTimeout(5) .setTimebounds(Date.now(), Date.now() + 5000)