use miden_client::store::OutputNoteRecord as NativeOutputNoteRecord;
use wasm_bindgen::prelude::*;
use super::note_assets::NoteAssets;
use super::note_id::NoteId;
use super::note_inclusion_proof::NoteInclusionProof;
use super::note_metadata::NoteMetadata;
use super::note_recipient::NoteRecipient;
use super::output_note_state::OutputNoteState;
use super::word::Word;
#[derive(Clone)]
#[wasm_bindgen]
pub struct OutputNoteRecord(NativeOutputNoteRecord);
#[wasm_bindgen]
impl OutputNoteRecord {
pub fn id(&self) -> NoteId {
self.0.id().into()
}
pub fn state(&self) -> OutputNoteState {
self.0.state().into()
}
#[wasm_bindgen(js_name = "recipientDigest")]
pub fn recipient_digest(&self) -> Word {
self.0.recipient_digest().into()
}
pub fn assets(&self) -> NoteAssets {
self.0.assets().into()
}
pub fn metadata(&self) -> NoteMetadata {
self.0.metadata().into()
}
#[wasm_bindgen(js_name = "inclusionProof")]
pub fn inclusion_proof(&self) -> Option<NoteInclusionProof> {
self.0.inclusion_proof().map(Into::into)
}
pub fn recipient(&self) -> Option<NoteRecipient> {
self.0.recipient().map(Into::into)
}
#[wasm_bindgen(js_name = "expectedHeight")]
pub fn expected_height(&self) -> u32 {
self.0.expected_height().as_u32()
}
pub fn nullifier(&self) -> Option<String> {
self.0.nullifier().map(|nullifier| nullifier.to_hex())
}
#[wasm_bindgen(js_name = "isConsumed")]
pub fn is_consumed(&self) -> bool {
self.0.is_consumed()
}
#[wasm_bindgen(js_name = "isCommitted")]
pub fn is_committed(&self) -> bool {
self.0.is_committed()
}
}
impl From<NativeOutputNoteRecord> for OutputNoteRecord {
fn from(native_note: NativeOutputNoteRecord) -> Self {
OutputNoteRecord(native_note)
}
}
impl From<&NativeOutputNoteRecord> for OutputNoteRecord {
fn from(native_note: &NativeOutputNoteRecord) -> Self {
OutputNoteRecord(native_note.clone())
}
}