Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/docs/dev_docs/contracts/syntax/storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,12 @@ However, it's possible that at the time this function is called, the system hasn

#include_code state_vars-SingletonGet /yarn-project/noir-contracts/src/contracts/docs_example_contract/src/actions.nr rust

### `view_note`

Functionally similar to [`get_note`](#get_note), but executed unconstrained and can be used by the wallet to fetch notes for use by front-ends etc.

#include_code view_note /yarn-project/aztec-nr/aztec/src/state_vars/singleton.nr rust

## `ImmutableSingleton<NoteType>`

ImmutableSingleton represents a unique private state variable that, as the name suggests, is immutable. Once initialized, its value cannot be altered.
Expand Down Expand Up @@ -363,6 +369,12 @@ Unlike a [`singleton`](#get_note-1), the `get_note` function for an ImmutableSin

This function will throw if the ImmutableSingleton hasn't been initialized.

### `view_note`

Functionally similar to `get_note`, but executed unconstrained and can be used by the wallet to fetch notes for use by front-ends etc.

#include_code view_note /yarn-project/aztec-nr/aztec/src/state_vars/immutable_singleton.nr rust

## `Set<NoteType>`

Set is used for managing a collection of notes. All notes in a set are of the same `NoteType`. But whether these notes all belong to one entity, or are accessible and editable by different entities, is totally up to the developer. Due to our state model, the set is a collection of notes inserted into the data-tree, but notes are never removed from the tree itself, they are only nullified.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ impl<Note, N> ImmutableSingleton<Note, N> {
}
// docs:end:get_note

// docs:start:view_note
unconstrained pub fn view_note(self) -> Note {
let options = NoteViewerOptions::new().set_limit(1);
view_notes(self.storage_slot, self.note_interface, options)[0].unwrap()
}
// docs:end:view_note
}
2 changes: 2 additions & 0 deletions yarn-project/aztec-nr/aztec/src/state_vars/singleton.nr
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,10 @@ impl<Note, N> Singleton<Note, N> {
}
// docs:end:get_note

// docs:start:view_note
unconstrained pub fn view_note(self) -> Note {
let options = NoteViewerOptions::new().set_limit(1);
view_notes(self.storage_slot, self.note_interface, options)[0].unwrap()
}
// docs:end:view_note
}