diff --git a/docs/docs/dev_docs/contracts/syntax/storage.md b/docs/docs/dev_docs/contracts/syntax/storage.md index 77ae0b61338..fa97daf5f73 100644 --- a/docs/docs/dev_docs/contracts/syntax/storage.md +++ b/docs/docs/dev_docs/contracts/syntax/storage.md @@ -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` ImmutableSingleton represents a unique private state variable that, as the name suggests, is immutable. Once initialized, its value cannot be altered. @@ -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` 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. diff --git a/yarn-project/aztec-nr/aztec/src/state_vars/immutable_singleton.nr b/yarn-project/aztec-nr/aztec/src/state_vars/immutable_singleton.nr index 0dad78df1c6..d1ad96565d2 100644 --- a/yarn-project/aztec-nr/aztec/src/state_vars/immutable_singleton.nr +++ b/yarn-project/aztec-nr/aztec/src/state_vars/immutable_singleton.nr @@ -70,8 +70,10 @@ impl ImmutableSingleton { } // 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 } diff --git a/yarn-project/aztec-nr/aztec/src/state_vars/singleton.nr b/yarn-project/aztec-nr/aztec/src/state_vars/singleton.nr index d1ce9e44593..9d13156a4c0 100644 --- a/yarn-project/aztec-nr/aztec/src/state_vars/singleton.nr +++ b/yarn-project/aztec-nr/aztec/src/state_vars/singleton.nr @@ -104,8 +104,10 @@ impl Singleton { } // 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 }