Skip to main content

miden_standards/note/
standard_note_attachment.rs

1use miden_protocol::note::NoteAttachmentScheme;
2
3/// The [`NoteAttachmentScheme`]s of standard note attachments.
4#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5#[non_exhaustive]
6pub enum StandardNoteAttachment {
7    /// See [`NetworkAccountTarget`](crate::note::NetworkAccountTarget) for details.
8    NetworkAccountTarget,
9    /// The attachment scheme used by both PSWAP output notes (payback P2ID + remainder PSWAP).
10    /// Carries the word `[amount, order_id, depth, 0]`. See
11    /// [`PswapNote`](crate::note::PswapNote) for details.
12    PswapAttachment,
13}
14
15impl StandardNoteAttachment {
16    /// Returns the [`NoteAttachmentScheme`] of the standard attachment.
17    pub const fn attachment_scheme(&self) -> NoteAttachmentScheme {
18        match self {
19            StandardNoteAttachment::NetworkAccountTarget => NoteAttachmentScheme::new_const(2u16),
20            StandardNoteAttachment::PswapAttachment => NoteAttachmentScheme::new_const(3u16),
21        }
22    }
23}