Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set timeout after simulation and before sign #951

Merged
merged 27 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
9578bc8
set timeout after simulation and before sign
BlaineHeffron May 1, 2024
53ce40e
`SentTransaction` will `allowHttp` iff its `AssembledTransaction#opti…
chadoh May 2, 2024
2a42574
set timeout after simulation and before sign
BlaineHeffron May 1, 2024
1af928d
Merge branch 'timeout-before-signing' of https://github.com/blainehef…
BlaineHeffron May 2, 2024
920bf90
add back set timeout in assembled transaction
BlaineHeffron May 2, 2024
1aed8f9
minor formatting cleanup
BlaineHeffron May 2, 2024
41cc0cf
Prepare v12.0.0-rc.1 (Protocol 21) for release (#953)
Shaptic May 2, 2024
3e79c6f
pass new timebounds in cloneFrom to avoid set timeout error
BlaineHeffron May 2, 2024
4153588
formatting
BlaineHeffron May 2, 2024
356bf80
Prepare v12.0.0-rc.1 for release (#954)
Shaptic May 2, 2024
01f63e2
Update src/contract_client/sent_transaction.ts
BlaineHeffron May 2, 2024
7f266ad
no need to convert the bytes before passing to SorobanDataBuilder
BlaineHeffron May 2, 2024
e12cdd6
Merge branch 'timeout-before-signing' of https://github.com/blainehef…
BlaineHeffron May 2, 2024
fec9349
fix typo
BlaineHeffron May 2, 2024
1d5f5bb
cleaner way of passing timeout
BlaineHeffron May 2, 2024
73d97d7
set timeout after simulation and before sign
BlaineHeffron May 1, 2024
2a16ac9
set timeout after simulation and before sign
BlaineHeffron May 1, 2024
57f09f4
add back set timeout in assembled transaction
BlaineHeffron May 2, 2024
3605bb5
minor formatting cleanup
BlaineHeffron May 2, 2024
1409be6
pass new timebounds in cloneFrom to avoid set timeout error
BlaineHeffron May 2, 2024
cf84b8f
formatting
BlaineHeffron May 2, 2024
242db45
no need to convert the bytes before passing to SorobanDataBuilder
BlaineHeffron May 2, 2024
0fe9aaa
Update src/contract_client/sent_transaction.ts
BlaineHeffron May 2, 2024
3f5e227
fix typo
BlaineHeffron May 2, 2024
2ef7510
cleaner way of passing timeout
BlaineHeffron May 2, 2024
15bc773
Merge branch 'timeout-before-signing' of https://github.com/blainehef…
BlaineHeffron May 2, 2024
b94ef51
add changelog entry
BlaineHeffron May 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/contract_client/sent_transaction.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ContractClientOptions, Tx } from "./types";
import { SorobanRpc, TransactionBuilder } from "..";
import { SorobanDataBuilder, SorobanRpc, TransactionBuilder } from "..";
import { DEFAULT_TIMEOUT, withExponentialBackoff } from "./utils";
import { AssembledTransaction } from "./assembled_transaction";

Expand Down Expand Up @@ -72,6 +72,17 @@ export class SentTransaction<T> {

private send = async (): Promise<this> => {
const timeoutInSeconds = this.assembled.options.timeoutInSeconds ?? DEFAULT_TIMEOUT
const timeoutTimestamp =
Math.floor(Date.now() / 1000) + timeoutInSeconds + 1;
this.assembled.built = TransactionBuilder.cloneFrom(this.assembled.built!, {
fee: this.assembled.built!.fee,
timebounds: {
minTime: 0,
maxTime: timeoutTimestamp,
},
})
Shaptic marked this conversation as resolved.
Show resolved Hide resolved
.setSorobanData(new SorobanDataBuilder(this.assembled.simulationData.transactionData.toXDR("base64")).build())
BlaineHeffron marked this conversation as resolved.
Show resolved Hide resolved
Shaptic marked this conversation as resolved.
Show resolved Hide resolved
.build();

const signature = await this.signTransaction!(
// `signAndSend` checks for `this.built` before calling `SentTransaction.init`
Expand Down
2 changes: 1 addition & 1 deletion src/contract_client/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* The default timeout for waiting for a transaction to be included in a block.
*/
export const DEFAULT_TIMEOUT = 10;
export const DEFAULT_TIMEOUT = 60;
Shaptic marked this conversation as resolved.
Show resolved Hide resolved

/**
* Keep calling a `fn` for `timeoutInSeconds` seconds, if `keepWaitingIf` is true.
Expand Down