fix(rust-client): wait for the final note-consume tx to commit in the custom-note and MASM-note tutorials#208
Merged
Conversation
… custom-note and MASM-note tutorials
Collaborator
Author
|
@brianseong could you give this one a review when you get a chance? 🙏 |
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.
Overview
Two of the note tutorials submit their final "Bob consumes the note" transaction and then immediately print a MidenScan link and exit, without confirming the transaction committed. Every earlier step in the same files already waits for commitment, so the final and most important step was the only unconfirmed one, and the printed happy-path output could show a link for a transaction that had not actually landed yet.
This PR makes both tutorials wait for the final consume to commit before exiting.
Key Changes
rust-client/src/bin/hash_preimage_note.rs: call the file's existingwait_for_txhelper on the final consume transaction (one line).rust-client/src/bin/note_creation_in_masm.rs: this file had nowait_for_txhelper, so I ported it verbatim fromhash_preimage_note.rsand added the imports it needs (store::TransactionFilter,TransactionId,TransactionStatus), then call it on the final consume.custom_note_how_to.md,creating_notes_in_masm_tutorial.md): mirrored the code change inside therust no_runblock and regenerated the expected-output transcript from a real run. Regenerating also cleaned up some pre-existing staleness: the custom-note transcript had an oldnote foundSTEP-2 poll, a fabricatedaccount deltaline, andRpoDigestwhere the binary now printsWord; the MASM-note transcript was truncated mid-line.Rationale
Correctness was never the issue here: these are local transactions, so a wrong secret or a broken note script already fails at proving and errors out. This is a robustness and output-honesty fix, so the tutorial's final line reflects a note that actually got consumed on-chain, matching how the rest of each file already behaves.
Tests
Ran both binaries against testnet: each now prints
✅ transaction <id> committedat STEP 4 and exits 0.cargo test --doc(17 passed, 0 failed) andprettier --checkare green.