Skip to content

Commit

Permalink
fix: stop using TimeoutInfinite
Browse files Browse the repository at this point in the history
  • Loading branch information
chadoh committed Jan 31, 2024
1 parent ca28486 commit ac5545b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/soroban/assembled_transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
Operation,
SorobanRpc,
StrKey,
TimeoutInfinite,
TransactionBuilder,
authorizeEntry,
hash,
Expand Down Expand Up @@ -54,8 +53,14 @@ export type MethodOptions = {
* The fee to pay for the transaction. Default: BASE_FEE
*/
fee?: number;
/**
* The maximum amount of time to wait for the transaction to complete. Default: {@link DEFAULT_TIMEOUT}
*/
timeoutInSeconds?: number;
};

const DEFAULT_TIMEOUT = 10;

export type AssembledTransactionOptions<T = string> = MethodOptions &
ContractClientOptions & {
method: string;
Expand Down Expand Up @@ -154,7 +159,7 @@ export class AssembledTransaction<T> {
networkPassphrase: options.networkPassphrase,
})
.addOperation(contract.call(options.method, ...(options.args ?? [])))
.setTimeout(TimeoutInfinite)
.setTimeout(options.timeoutInSeconds ?? DEFAULT_TIMEOUT)
.build();

return await tx.simulate();
Expand Down Expand Up @@ -552,7 +557,7 @@ class SentTransaction<T> {
networkPassphrase: this.options.networkPassphrase,
}
)
.setTimeout(TimeoutInfinite)
.setTimeout(this.assembled.options.timeoutInSeconds ?? DEFAULT_TIMEOUT)
.addOperation(
Operation.invokeHostFunction({ ...op, auth: op.auth ?? [] })
)
Expand Down

0 comments on commit ac5545b

Please sign in to comment.