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 30, 2024
1 parent ca28486 commit f072c51
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 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,6 +53,10 @@ 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: 10
*/
timeoutInSeconds: number;
};

export type AssembledTransactionOptions<T = string> = MethodOptions &
Expand Down Expand Up @@ -138,6 +141,7 @@ export class AssembledTransaction<T> {
}

private constructor(public options: AssembledTransactionOptions<T>) {
this.options.timeoutInSeconds = options.timeoutInSeconds ?? 10;
this.server = new SorobanRpc.Server(this.options.rpcUrl, {
allowHttp: this.options.rpcUrl.startsWith("http://"),
});
Expand All @@ -154,7 +158,7 @@ export class AssembledTransaction<T> {
networkPassphrase: options.networkPassphrase,
})
.addOperation(contract.call(options.method, ...(options.args ?? [])))
.setTimeout(TimeoutInfinite)
.setTimeout(options.timeoutInSeconds)
.build();

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

0 comments on commit f072c51

Please sign in to comment.