diff --git a/bindings/cashu-ffi/src/cashu.udl b/bindings/cashu-ffi/src/cashu.udl index 903033983..90caafbda 100644 --- a/bindings/cashu-ffi/src/cashu.udl +++ b/bindings/cashu-ffi/src/cashu.udl @@ -5,6 +5,8 @@ interface CashuError { Generic(string err); }; +// Types + interface Bolt11Invoice { [Throws=CashuError] constructor(string bolt11); @@ -27,6 +29,9 @@ interface Secret { sequence as_bytes(); }; + +// NUT00 + interface Id { [Throws=CashuError] constructor(string id); diff --git a/bindings/cashu-ffi/src/lib.rs b/bindings/cashu-ffi/src/lib.rs index 040f30173..98a27369e 100644 --- a/bindings/cashu-ffi/src/lib.rs +++ b/bindings/cashu-ffi/src/lib.rs @@ -28,6 +28,7 @@ mod ffi { pub use crate::types::amount::Amount; pub use crate::types::Bolt11Invoice; pub use crate::types::KeySetInfo; + pub use crate::types::ProofsStatus; pub use crate::types::Secret; pub use cashu::types::InvoiceStatus; diff --git a/bindings/cashu-ffi/src/types/bolt11_invoice.rs b/bindings/cashu-ffi/src/types/bolt11_invoice.rs index 0b692034e..59ebed520 100644 --- a/bindings/cashu-ffi/src/types/bolt11_invoice.rs +++ b/bindings/cashu-ffi/src/types/bolt11_invoice.rs @@ -15,6 +15,12 @@ impl Deref for Bolt11Invoice { } } +impl From for Bolt11Invoice { + fn from(inner: Bolt11InvoiceSdk) -> Bolt11Invoice { + Bolt11Invoice { inner } + } +} + impl Bolt11Invoice { pub fn new(bolt11: String) -> Result { Ok(Self { diff --git a/bindings/cashu-ffi/src/types/proofs_status.rs b/bindings/cashu-ffi/src/types/proofs_status.rs index 13a48c16e..04489af45 100644 --- a/bindings/cashu-ffi/src/types/proofs_status.rs +++ b/bindings/cashu-ffi/src/types/proofs_status.rs @@ -8,6 +8,13 @@ pub struct ProofsStatus { inner: ProofsStatusSdk, } +impl Deref for ProofsStatus { + type Target = ProofsStatusSdk; + fn deref(&self) -> &Self::Target { + &self.inner + } +} + impl ProofsStatus { pub fn new(spendable: Vec>, spent: Vec>) -> Self { Self { diff --git a/bindings/cashu-sdk-ffi/src/cashu_sdk.udl b/bindings/cashu-sdk-ffi/src/cashu_sdk.udl index d7203c6ea..33bf4ad46 100644 --- a/bindings/cashu-sdk-ffi/src/cashu_sdk.udl +++ b/bindings/cashu-sdk-ffi/src/cashu_sdk.udl @@ -8,6 +8,8 @@ interface CashuError { }; +// Types + interface Bolt11Invoice { [Throws=CashuError] constructor(string bolt11); @@ -31,6 +33,7 @@ interface Secret { sequence as_bytes(); }; + interface Id { [Throws=CashuError] constructor(string id); diff --git a/bindings/cashu-sdk-ffi/src/types/melted.rs b/bindings/cashu-sdk-ffi/src/types/melted.rs index db27bf60b..4213ecb99 100644 --- a/bindings/cashu-sdk-ffi/src/types/melted.rs +++ b/bindings/cashu-sdk-ffi/src/types/melted.rs @@ -8,7 +8,12 @@ pub struct Melted { inner: MeltedSdk, } -// TODO: Deref +impl Deref for Melted { + type Target = MeltedSdk; + fn deref(&self) -> &Self::Target { + &self.inner + } +} impl From for Melted { fn from(inner: cashu_sdk::types::Melted) -> Melted { diff --git a/bindings/cashu-sdk-ffi/src/types/proofs_status.rs b/bindings/cashu-sdk-ffi/src/types/proofs_status.rs index 1afcbcff9..7f8c1985a 100644 --- a/bindings/cashu-sdk-ffi/src/types/proofs_status.rs +++ b/bindings/cashu-sdk-ffi/src/types/proofs_status.rs @@ -8,8 +8,18 @@ pub struct ProofsStatus { inner: ProofsStatusSdk, } -// TODO: Into -// TODO: Deref +impl Deref for ProofsStatus { + type Target = ProofsStatusSdk; + fn deref(&self) -> &Self::Target { + &self.inner + } +} + +impl From for ProofsStatus { + fn from(inner: ProofsStatusSdk) -> ProofsStatus { + ProofsStatus { inner } + } +} impl ProofsStatus { pub fn new(spendable: Vec>, spent: Vec>) -> Self { diff --git a/bindings/cashu-sdk-ffi/src/types/send_proofs.rs b/bindings/cashu-sdk-ffi/src/types/send_proofs.rs index ac50a0451..cf8d2bacd 100644 --- a/bindings/cashu-sdk-ffi/src/types/send_proofs.rs +++ b/bindings/cashu-sdk-ffi/src/types/send_proofs.rs @@ -1,17 +1,30 @@ use std::{ops::Deref, sync::Arc}; -use cashu_sdk::types::SendProofs as SendProofSdk; +use cashu_sdk::types::SendProofs as SendProofsSdk; use cashu_ffi::Proof; pub struct SendProofs { - inner: SendProofSdk, + inner: SendProofsSdk, +} + +impl Deref for SendProofs { + type Target = SendProofsSdk; + fn deref(&self) -> &Self::Target { + &self.inner + } +} + +impl From for SendProofs { + fn from(inner: SendProofsSdk) -> SendProofs { + SendProofs { inner } + } } impl SendProofs { pub fn new(change_proofs: Vec>, send_proofs: Vec>) -> Self { Self { - inner: SendProofSdk { + inner: SendProofsSdk { change_proofs: change_proofs .iter() .map(|p| p.as_ref().deref().clone()) @@ -42,9 +55,3 @@ impl SendProofs { .collect() } } - -impl From for SendProofs { - fn from(inner: cashu_sdk::types::SendProofs) -> SendProofs { - SendProofs { inner } - } -}