Skip to content

Commit

Permalink
[ts sdk] replace WaitForLocalExecution with waitForTransaction (#18929)
Browse files Browse the repository at this point in the history
## Description 

Describe the changes or additions included in this PR.

## Test plan 

How did you test the new or updated feature?

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
- [ ] REST API:
  • Loading branch information
hayes-mysten authored Aug 13, 2024
1 parent fe922b7 commit a3e32fe
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
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

0 comments on commit a3e32fe

Please sign in to comment.