pub trait ActiveNote {
Show 18 methods
// Provided methods
fn get_initial_assets(&self) -> Vec<Asset> { ... }
fn get_sender(&self) -> AccountId { ... }
fn get_recipient(&self) -> Recipient { ... }
fn get_script_root(&self) -> Word { ... }
fn get_serial_number(&self) -> Word { ... }
fn get_metadata(&self) -> NoteMetadata { ... }
fn is_public(&self) -> bool { ... }
fn is_private(&self) -> bool { ... }
fn get_attachments_commitment(&self) -> Word { ... }
fn write_attachment_commitments_to_memory(&self) -> Vec<Word> { ... }
fn write_attachment_to_memory(&self, attachment_idx: u32) -> Vec<Word> { ... }
fn find_attachment(&self, attachment_scheme: Felt) -> Option<u32> { ... }
fn get_initial_assets_info(&self) -> ActiveNoteAssetsInfo { ... }
fn get_initial_num_assets(&self) -> u32 { ... }
fn get_asset(&self, asset_index: u32) -> Asset { ... }
fn get_note_id(&self) -> NoteId { ... }
fn get_storage_info(&self) -> ActiveNoteStorageInfo { ... }
fn remove_asset(&mut self, asset: Asset) -> Word { ... }
}Expand description
Trait that provides active-note operations for note scripts.
This trait is automatically implemented for the note input struct marked with the #[note]
macro, so a #[note_script] entrypoint can call the operations directly on self, e.g.
self.get_sender().
The operations read the note that is currently executing. Call them only during note-script
execution: a note value constructed outside of it (for example in a #[note_constructor])
has no active note, and the transaction kernel rejects the calls at run time.
get_storage is intentionally not part of this trait: the #[note] macro decodes the note
storage into the struct fields, so the values are available directly on self.
An inherent method of the note struct with the same name shadows the trait method; the trait
method stays reachable with UFCS, e.g. <MyNote as ActiveNote>::get_sender(¬e).
Provided Methods§
Sourcefn get_initial_assets(&self) -> Vec<Asset>
fn get_initial_assets(&self) -> Vec<Asset>
Get the initial assets of the currently executing note.
These are the note’s assets at creation time, unaffected by in-transaction removal.
Sourcefn get_sender(&self) -> AccountId
fn get_sender(&self) -> AccountId
Returns the sender AccountId of the note that is currently executing.
Sourcefn get_recipient(&self) -> Recipient
fn get_recipient(&self) -> Recipient
Returns the recipient of the note that is currently executing.
Sourcefn get_script_root(&self) -> Word
fn get_script_root(&self) -> Word
Returns the script root of the currently executing note.
Sourcefn get_serial_number(&self) -> Word
fn get_serial_number(&self) -> Word
Returns the serial number of the currently executing note.
Sourcefn get_metadata(&self) -> NoteMetadata
fn get_metadata(&self) -> NoteMetadata
Returns the metadata header of the note that is currently executing.
Sourcefn is_private(&self) -> bool
fn is_private(&self) -> bool
Returns whether the note currently executing is private.
Sourcefn get_attachments_commitment(&self) -> Word
fn get_attachments_commitment(&self) -> Word
Returns the commitment over all attachments of the note currently executing.
Sourcefn write_attachment_commitments_to_memory(&self) -> Vec<Word>
fn write_attachment_commitments_to_memory(&self) -> Vec<Word>
Returns the attachment commitments of the active note.
Sourcefn write_attachment_to_memory(&self, attachment_idx: u32) -> Vec<Word>
fn write_attachment_to_memory(&self, attachment_idx: u32) -> Vec<Word>
Returns the attachment at attachment_idx of the active note as protocol words.
Sourcefn find_attachment(&self, attachment_scheme: Felt) -> Option<u32>
fn find_attachment(&self, attachment_scheme: Felt) -> Option<u32>
Searches the active note metadata for attachment_scheme.
Sourcefn get_initial_assets_info(&self) -> ActiveNoteAssetsInfo
fn get_initial_assets_info(&self) -> ActiveNoteAssetsInfo
Returns the initial assets commitment and asset count of the note that is currently executing.
These describe the note’s assets at creation time, unaffected by in-transaction removal.
Sourcefn get_initial_num_assets(&self) -> u32
fn get_initial_num_assets(&self) -> u32
Returns the number of assets the currently executing note was created with.
The count is unaffected by in-transaction removal.
Sourcefn get_asset(&self, asset_index: u32) -> Asset
fn get_asset(&self, asset_index: u32) -> Asset
Returns the asset at asset_index in the note that is currently executing.
The asset is returned as it currently is: an asset that was already removed from the note reads back with both words empty.
§Panics
Panics if asset_index is out of bounds for the note.
Sourcefn get_note_id(&self) -> NoteId
fn get_note_id(&self) -> NoteId
Returns the ID of the note that is currently executing.
Sourcefn get_storage_info(&self) -> ActiveNoteStorageInfo
fn get_storage_info(&self) -> ActiveNoteStorageInfo
Returns the storage commitment and storage item count of the currently executing note.
Sourcefn remove_asset(&mut self, asset: Asset) -> Word
fn remove_asset(&mut self, asset: Asset) -> Word
Removes asset from the currently executing note and returns the asset value left in it.
The returned value is empty when the entire asset was removed. This mutates the note’s
assets in the transaction kernel, so the note script needs a mut self receiver to call it.
§Panics
Panics under the same conditions as remove_asset.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".