Simplify NoteMetadata constructor by making tag optional#2384
Merged
Simplify NoteMetadata constructor by making tag optional#2384
NoteMetadata constructor by making tag optional#2384Conversation
Copilot
AI
changed the title
[WIP] Change NoteMetadata constructor to avoid default tag
Simplify NoteMetadata constructor by making tag optional
Feb 1, 2026
Collaborator
|
@copilot add changelog entry, the PR number is 2384 |
Copilot AI
added a commit
that referenced
this pull request
Feb 1, 2026
Co-authored-by: mmagician <8402446+mmagician@users.noreply.github.com>
Contributor
Author
NoteMetadata constructor by making tag optional
Changed from NoteMetadata::new(sender, note_type, tag) to NoteMetadata::new(sender, note_type).with_tag(tag) across all files in the miden-testing crate. Updated files: - tests/agglayer/bridge_out.rs (2 occurrences) - tests/agglayer/bridge_in.rs (1 occurrence) - tests/scripts/faucet.rs (2 occurrences) - tests/scripts/send_note.rs (2 occurrences) - tests/scripts/swap.rs (1 occurrence) - tests/lib.rs (1 occurrence) - src/kernel_tests/tx/test_output_note.rs (3 occurrences) - src/kernel_tests/tx/test_tx.rs (2 occurrences) - src/kernel_tests/tx/test_account_interface.rs (1 occurrence) - src/kernel_tests/tx/test_note.rs (2 occurrences) - src/kernel_tests/tx/test_active_note.rs (1 occurrence) - src/standards/network_account_target.rs (1 occurrence)
- Modified NoteMetadata::new() to only take sender and note_type - Added with_tag() method for setting tag explicitly - Updated all call sites across protocol, testing, standards, tx, and agglayer crates - Tag now defaults to NoteTag::default() if not explicitly set Co-authored-by: mmagician <8402446+mmagician@users.noreply.github.com>
Co-authored-by: mmagician <8402446+mmagician@users.noreply.github.com>
Co-authored-by: mmagician <8402446+mmagician@users.noreply.github.com>
Co-authored-by: mmagician <8402446+mmagician@users.noreply.github.com>
12a8f8f to
9de85f1
Compare
PhilippGackstatter
approved these changes
Feb 2, 2026
bobbinth
reviewed
Feb 2, 2026
Comment on lines
+167
to
+170
| pub fn with_tag(mut self, tag: NoteTag) -> Self { | ||
| self.tag = tag; | ||
| self | ||
| } |
Contributor
There was a problem hiding this comment.
nit: I would have maybe changed the parameter type to something like Into<NoteTag>. This way, we'd be able to call this method with anything that can be trivially converted into a NoteTag (would make testing code a bit easier).
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.
Summary
This PR implements the change requested in issue #2334 to modify the
NoteMetadataconstructor API to use a builder pattern.Changes Made
Constructor Modification
NoteMetadata::new()to only takesender: AccountIdandnote_type: NoteTypeparametersNoteTag::default()(which is 0)New Builder Methods
with_tag()builder method to set a custom tag when neededset_tag()mutator method for setting tags on existing instancesAPI Usage Comparison
Before:
After:
Updated Call Sites
Updated ~40 call sites across all crates:
Testing
NoteMetadataconstructor by making tag optional #2384Security Summary
This change is a pure refactoring that maintains the same behavior but with a cleaner API. No security vulnerabilities were introduced:
Original prompt
NoteMetadataconstructor not to take the tag by default #2383💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.