1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
use js_export_macro::js_export;
use miden_client::note::NoteHeader as NativeNoteHeader;
use super::note_id::NoteId;
use super::note_metadata::NoteMetadata;
/// Holds the strictly required, public information of a note.
///
/// See `NoteId` and `NoteMetadata` for additional details.
#[derive(Clone)]
#[js_export]
pub struct NoteHeader(NativeNoteHeader);
#[js_export]
impl NoteHeader {
// TODO: new()
/// Returns the unique identifier for the note.
pub fn id(&self) -> NoteId {
self.0.id().into()
}
/// Returns the public metadata attached to the note.
pub fn metadata(&self) -> NoteMetadata {
self.0.metadata().into()
}
// `toCommitment` was removed in the migration to miden-client PR #2214 —
// `NoteHeader::to_commitment` is no longer part of the 0.15 protocol
// surface. Compute a commitment from `id().toString()` or related
// commitment-bearing accessors on the underlying note types if needed.
}
// CONVERSIONS
// ================================================================================================
impl From<NativeNoteHeader> for NoteHeader {
fn from(native_note_header: NativeNoteHeader) -> Self {
NoteHeader(native_note_header)
}
}
impl From<&NativeNoteHeader> for NoteHeader {
fn from(native_note_header: &NativeNoteHeader) -> Self {
NoteHeader(*native_note_header)
}
}
impl From<NoteHeader> for NativeNoteHeader {
fn from(note_header: NoteHeader) -> Self {
note_header.0
}
}
impl From<&NoteHeader> for NativeNoteHeader {
fn from(note_header: &NoteHeader) -> Self {
note_header.0
}
}