From 7c85cc4e1cb41deac29ed2ef413cf924a3a718a5 Mon Sep 17 00:00:00 2001 From: George Date: Mon, 7 Aug 2023 11:27:32 -0700 Subject: [PATCH] Fix TypeScript definition for new static `TransactionBuilder` constructor (#665) * Add version bump to publish * Fixup docs --- package.json | 2 +- src/transaction_builder.js | 24 ++++++++++++++++-------- types/index.d.ts | 5 ++++- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 264ad7dd..13563dc0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "stellar-base", - "version": "10.0.0-soroban.5", + "version": "10.0.0-soroban.6", "description": "Low-level support library for the Stellar network.", "main": "./lib/index.js", "browser": { diff --git a/src/transaction_builder.js b/src/transaction_builder.js index 058d94b5..b9dc9cd3 100644 --- a/src/transaction_builder.js +++ b/src/transaction_builder.js @@ -122,7 +122,6 @@ export const TimeoutInfinite = 0; * {@link SorobanDataBuilder} to construct complicated combinations of * parameters without mucking with XDR directly. **Note:** For * non-contract(non-Soroban) transactions, this has no effect. - * */ export class TransactionBuilder { constructor(sourceAccount, opts = {}) { @@ -170,6 +169,11 @@ export class TransactionBuilder { * @returns {TransactionBuilder} a "prepared" builder instance with the same * configuration and operations as the given transaction * + * @warning This does not clone the transaction's + * {@link xdr.SorobanTransactionData} (if applicable), use + * {@link SorobanDataBuilder} and {@link TransactionBuilder.setSorobanData} + * as needed, instead.. + * * @todo This cannot clone {@link FeeBumpTransaction}s, yet. */ static cloneFrom(tx, opts = {}) { @@ -515,16 +519,20 @@ export class TransactionBuilder { } /** - * Set the {SorobanTransactionData}. For non-contract(non-Soroban) - * transactions, this setting has no effect. In the case of Soroban - * transactions, set to an instance of SorobanTransactionData. This can - * typically be obtained from the simulation response based on a transaction - * with a InvokeHostFunctionOp. It provides necessary resource estimations for - * contract invocation. + * Sets the transaction's internal Soroban transaction data (resources, + * footprint, etc.). + * + * For non-contract(non-Soroban) transactions, this setting has no effect. In + * the case of Soroban transactions, this is either an instance of + * {@link xdr.SorobanTransactionData} or a base64-encoded string of said + * structure. This is usually obtained from the simulation response based on a + * transaction with a Soroban operation (e.g. + * {@link Operation.invokeHostFunction}, providing necessary resource + * and storage footprint estimations for contract invocation. * * @param {xdr.SorobanTransactionData | string} sorobanData the * {@link xdr.SorobanTransactionData} as a raw xdr object or a base64 - * string to be decoded then set as Transaction.Ext.SorobanData + * string to be decoded * * @returns {TransactionBuilder} * @see {SorobanDataBuilder} diff --git a/types/index.d.ts b/types/index.d.ts index 941c90de..683f81a2 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1029,7 +1029,10 @@ export class TransactionBuilder { build(): Transaction; setNetworkPassphrase(networkPassphrase: string): this; - static cloneFrom(tx: Transaction): TransactionBuilder; + static cloneFrom( + tx: Transaction, + optionOverrides?: TransactionBuilder.TransactionBuilderOptions + ): TransactionBuilder; static buildFeeBumpTransaction( feeSource: Keypair | string, baseFee: string,