Move standard notes into individual files#2363
Conversation
partylikeits1983
left a comment
There was a problem hiding this comment.
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.
PhilippGackstatter
left a comment
There was a problem hiding this comment.
Looks good to me!
| /// | ||
| /// # Errors | ||
| /// Returns an error if deserialization or compilation of the `P2ID` script fails. | ||
| pub fn create<R: FeltRng>( |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
Co-authored-by: Philipp Gackstatter <PhilippGackstatter@users.noreply.github.com>
This PR reshuffles the code in the
miden-standards/src/notedirectory. 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.,P2idNoteand instead ofcreate_p2id_note()we can now doP2idNote::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.