Skip to content

feat!: automatic NoteInterface and NoteGetterOptions auto select#4508

Merged
Thunkar merged 57 commits into
masterfrom
gj/notegetteroptions_auto_select
Mar 19, 2024
Merged

feat!: automatic NoteInterface and NoteGetterOptions auto select#4508
Thunkar merged 57 commits into
masterfrom
gj/notegetteroptions_auto_select

Conversation

@Thunkar

@Thunkar Thunkar commented Feb 8, 2024

Copy link
Copy Markdown
Contributor

Partially addresses: #4519 (moved autogeneration to the macro, even if not incremental)
Closes: #3011

Added the #[aztec(note)] attribute, which automatically implements most of the NoteInterface trait in a struct marked as such, plus several utilities. Even if this adds a fair share of "magic" to the note implementation logic, it is structured in a way that it's hopefully easy to follow, including meaningful errors attached to the correct span during the process.

Screenshot 2024-03-14 at 14 59 07

Hey you! Implement the trait!

Screenshot 2024-03-14 at 14 46 39
But only the meat and potatoes though.

As long as the user doesn't want to do any custom stuff, get_header, set_header, compute_note_content_hash, get_note_type_id, serialize_content and deserialize_content get automatically implemented. Any combination of them can be overridden by the developer though.

A metadata struct is also added, which takes the following form:

struct CardNote {
    points: FieldSelector,
    randomness: FieldSelector,
    owner: FieldSelector,
}

This is used to implement a properties() function, which in turn can be used in conjunction with the NoteGetterOptions.select and .sort

Screenshot 2024-03-18 at 15 27 27

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-aztec.nr Component: Aztec smart contract framework

Projects

No open projects
Archived in project

Development

Successfully merging this pull request may close these issues.

feat(AztecMacro): Autogenerate constants for struct field slots for better note-getter options

6 participants