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

[ts sdk] replace WaitForLocalExecution with waitForTransaction #18929

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/seven-pets-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@mysten/sui': minor
---

`WaitForLocalExecution` now waits using client.waitForTransaction rather than sending requestType to the RPC node. This change will preserve readAfterWrite consistency when local execution is removed from fullnodes, at the cost of more network requests and higher latency.
32 changes: 22 additions & 10 deletions sdk/typescript/src/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,20 +406,32 @@ export class SuiClient {
});
}

async executeTransactionBlock(
input: ExecuteTransactionBlockParams,
): Promise<SuiTransactionBlockResponse> {
return await this.transport.request({
async executeTransactionBlock({
transactionBlock,
signature,
options,
requestType,
}: ExecuteTransactionBlockParams): Promise<SuiTransactionBlockResponse> {
const result: SuiTransactionBlockResponse = await this.transport.request({
method: 'sui_executeTransactionBlock',
params: [
typeof input.transactionBlock === 'string'
? input.transactionBlock
: toB64(input.transactionBlock),
Array.isArray(input.signature) ? input.signature : [input.signature],
input.options,
input.requestType,
typeof transactionBlock === 'string' ? transactionBlock : toB64(transactionBlock),
Array.isArray(signature) ? signature : [signature],
options,
],
});

if (requestType === 'WaitForLocalExecution') {
try {
await this.waitForTransaction({
digest: result.digest,
});
} catch (_) {
// Ignore error while waiting for transaction
}
}

return result;
}

async signAndExecuteTransaction({
Expand Down
Loading