use miden_client::note::{Note as NativeNote, NoteInclusionProof as NativeNoteInclusionProof};
use miden_client::transaction::InputNote as NativeInputNote;
use wasm_bindgen::prelude::*;
use super::note::Note;
use super::note_id::NoteId;
use super::note_inclusion_proof::NoteInclusionProof;
use super::note_location::NoteLocation;
use super::word::Word;
#[derive(Clone)]
#[wasm_bindgen]
pub struct InputNote(pub(crate) NativeInputNote);
#[wasm_bindgen]
impl InputNote {
pub fn authenticated(note: &Note, inclusion_proof: &NoteInclusionProof) -> InputNote {
let native_note: NativeNote = note.into();
let native_proof: NativeNoteInclusionProof = inclusion_proof.clone().into();
InputNote(NativeInputNote::authenticated(native_note, native_proof))
}
pub fn unauthenticated(note: &Note) -> InputNote {
InputNote(NativeInputNote::unauthenticated(note.clone().into()))
}
pub fn id(&self) -> NoteId {
self.0.id().into()
}
pub fn note(&self) -> Note {
self.0.note().into()
}
pub fn commitment(&self) -> Word {
self.0.note().commitment().into()
}
pub fn proof(&self) -> Option<NoteInclusionProof> {
self.0.proof().map(Into::into)
}
pub fn location(&self) -> Option<NoteLocation> {
self.0.location().map(Into::into)
}
}
impl From<NativeInputNote> for InputNote {
fn from(native_note: NativeInputNote) -> Self {
InputNote(native_note)
}
}
impl From<&NativeInputNote> for InputNote {
fn from(native_note: &NativeInputNote) -> Self {
InputNote(native_note.clone())
}
}