Skip to content

Move standard notes into individual files#2363

Merged
bobbinth merged 4 commits intonextfrom
bobbin-std-notes
Jan 29, 2026
Merged

Move standard notes into individual files#2363
bobbinth merged 4 commits intonextfrom
bobbin-std-notes

Conversation

@bobbinth
Copy link
Copy Markdown
Contributor

This PR reshuffles the code in the miden-standards/src/note directory. Specifically, I've created individual files for all current standard notes (P2ID, P2IDE, SWAP, MINT, BURN) and grouped most of the relevant functionality in these files under similarly-named structs (e.g., P2idNote and instead of create_p2id_note() we can now do P2idNote::create()).

This PR is purely code re-shuffling and should contain no actual code changes.

This is the first step on the path to #2283.

Copy link
Copy Markdown
Member

@partylikeits1983 partylikeits1983 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pattern looks a lot cleaner than having a free function that creates the various standard notes. Once this lands we should follow the same pattern for agglayer notes.

Copy link
Copy Markdown
Contributor

@PhilippGackstatter PhilippGackstatter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

Copy link
Copy Markdown
Collaborator

@mmagician mmagician left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ✅

///
/// # Errors
/// Returns an error if deserialization or compilation of the `P2ID` script fails.
pub fn create<R: FeltRng>(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the idea to eventually have a trait that encompasses methods like create?
I think if we abstracted away all the inputs of create into P2IDCreateInputs (name TBD 😁 ), we could do:

pub trait NoteTrait { // trait name TBD, StandardNote and Note are already taken
    type CreateInputs;  
    
    fn create(inputs: CreateInputs, rng: &mut R) -> Result<Note, NoteError>;

    fn script() -> NoteScript;
    // etc.
}

I am not sure if this trait would be useful for the consumer, but definitely helpful for us to keep track of the methods we should provide for standard notes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that would be possible. I guess one question is how this would work with the proposal from #2283 (or whether we need both).

bobbinth and others added 2 commits January 29, 2026 09:17
Co-authored-by: Philipp Gackstatter <PhilippGackstatter@users.noreply.github.com>
@bobbinth bobbinth merged commit cbc9ddc into next Jan 29, 2026
17 checks passed
@bobbinth bobbinth deleted the bobbin-std-notes branch January 29, 2026 17:58
afa7789 pushed a commit to afa7789/miden-base that referenced this pull request Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants