Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
waitForTransactionCommitpolls in a loop, passing the sameTransactionIdobject toTransactionFilter.ids([txId])on every iteration.Impact
The binding takes ownership:
Vec<TransactionId>by value plusinto_iter()means wasm-bindgen frees each element's pointer as it crosses the boundary. The first call therefore leaves the caller'stxIdwith a null pointer, and the second iteration throwsnull pointer passed to rust.That makes the wait unreliable for any transaction not already committed on the first poll, which is the case the function exists to handle.
Change
Snapshot the hex once before the loop and rebuild a fresh
TransactionIdper iteration viaTransactionId.fromHex(js_exported atcrates/web-client/src/models/transaction_id.rs). As a side effect the caller's object is never consumed, so callers that usetxIdafter the wait are also safe.Testing
I wasn't able to run the workspace locally, so this is reasoned from the source rather than executed:
idssignature above takes the vector by value and consumes it withinto_iter()TransactionId.fromHexisjs_exported and returns a new instance, so rebuilding is cheap and safeWorth flagging for reviewers: the existing unit tests pass a plain object such as
{ toHex: () => "0xtx" }in place of a realTransactionId, so they never exercise the by-value consumption and would pass either way. A regression test would need the real wasm-bindgen type.Public API is unchanged, so no
api-types.d.ts, docs, or README updates are needed.