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
60
61
62
63
64
65
66
67
68
69
70
71
use miden_client::note::PartialNote as NativePartialNote;
use wasm_bindgen::prelude::*;
use super::note_assets::NoteAssets;
use super::note_id::NoteId;
use super::note_metadata::NoteMetadata;
use super::word::Word;
/// Partial information about a note.
///
/// Partial note consists of `NoteMetadata`, `NoteAssets`, and a recipient digest (see
/// `NoteRecipient`). However, it does not contain detailed recipient info, including
/// note script, note inputs, and note's serial number. This means that a partial note is sufficient
/// to compute note ID and note header, but not sufficient to compute note nullifier, and generally
/// does not have enough info to execute the note.
#[derive(Clone)]
#[wasm_bindgen]
pub struct PartialNote(NativePartialNote);
#[wasm_bindgen]
impl PartialNote {
// TODO: new
/// Returns the identifier of the partial note.
pub fn id(&self) -> NoteId {
self.0.id().into()
}
/// Returns the metadata attached to the note.
pub fn metadata(&self) -> NoteMetadata {
self.0.metadata().into()
}
/// Returns the digest of the recipient information.
#[wasm_bindgen(js_name = "recipientDigest")]
pub fn recipient_digest(&self) -> Word {
self.0.recipient_digest().into()
}
/// Returns the assets locked in the note.
pub fn assets(&self) -> NoteAssets {
self.0.assets().into()
}
}
// CONVERSIONS
// ================================================================================================
impl From<NativePartialNote> for PartialNote {
fn from(native_note: NativePartialNote) -> Self {
PartialNote(native_note)
}
}
impl From<&NativePartialNote> for PartialNote {
fn from(native_note: &NativePartialNote) -> Self {
PartialNote(native_note.clone())
}
}
impl From<PartialNote> for NativePartialNote {
fn from(note: PartialNote) -> Self {
note.0
}
}
impl From<&PartialNote> for NativePartialNote {
fn from(note: &PartialNote) -> Self {
note.0.clone()
}
}