Browse Source

`bindings/cashu-sdk` add fee reserve arguments

thesimplekid 1 year ago
parent
commit
8e0327eb31

+ 1 - 1
bindings/cashu-sdk-ffi/src/cashu_sdk.udl

@@ -325,7 +325,7 @@ interface Wallet {
 
 interface Mint {
     [Throws=CashuSdkError]
-	constructor(string secret, string derivation_path, record<string, MintKeySet> inactive_keysets, sequence<Secret> spent_secrets, u8 max_order);
+	constructor(string secret, string derivation_path, record<string, MintKeySet> inactive_keysets, sequence<Secret> spent_secrets, u8 max_order, Amount min_fee_reserve, f32 percent_fee_reserve);
 	KeySet active_keyset_pubkeys();
 	KeySetResponse keysets();
 	MintKeySet active_keyset();

+ 1 - 1
bindings/cashu-sdk-ffi/src/lib.rs

@@ -17,7 +17,7 @@ mod ffi {
     pub use crate::client::Client;
     pub use crate::error::CashuSdkError;
     pub use crate::mint::Mint;
-    pub use crate::types::{Melted, ProofsStatus, SendProofs};
+    pub use crate::types::{FeeReserve, Melted, ProofsStatus, SendProofs};
     pub use crate::wallet::Wallet;
 
     // UDL

+ 6 - 1
bindings/cashu-sdk-ffi/src/mint.rs

@@ -7,8 +7,9 @@ use std::{
 use cashu_sdk::mint::Mint as MintSdk;
 
 use cashu_sdk::nuts::nut02::Id as IdSdk;
+use fee_reserve::FeeReserve;
 
-use crate::error::Result;
+use crate::{error::Result, types::fee_reserve};
 use cashu_ffi::{
     Amount, CheckSpendableRequest, CheckSpendableResponse, Id, KeySet, KeySetResponse, MeltRequest,
     MeltResponse, MintKeySet, MintRequest, PostMintResponse, Proof, Secret, SplitRequest,
@@ -26,6 +27,8 @@ impl Mint {
         inactive_keysets: HashMap<String, Arc<MintKeySet>>,
         spent_secrets: Vec<Arc<Secret>>,
         max_order: u8,
+        min_fee_reserve: Arc<Amount>,
+        percent_fee_reserve: f32,
     ) -> Result<Self> {
         let spent_secrets = spent_secrets
             .into_iter()
@@ -47,6 +50,8 @@ impl Mint {
                 inactive_keysets,
                 spent_secrets,
                 max_order,
+                *min_fee_reserve.as_ref().deref(),
+                percent_fee_reserve,
             )
             .into(),
         })

+ 19 - 0
bindings/cashu-sdk-ffi/src/types/fee_reserve.rs

@@ -0,0 +1,19 @@
+use std::{ops::Deref, sync::Arc};
+
+use cashu_ffi::Amount;
+use cashu_sdk::mint::FeeReserve as FeeReserveSdk;
+
+pub struct FeeReserve {
+    inner: FeeReserveSdk,
+}
+
+impl FeeReserve {
+    pub fn new(min_fee_reserve: Arc<Amount>, percent_fee_reserve: f32) -> Self {
+        Self {
+            inner: FeeReserveSdk {
+                min_fee_reserve: *min_fee_reserve.as_ref().deref(),
+                percent_fee_reserve,
+            },
+        }
+    }
+}

+ 2 - 0
bindings/cashu-sdk-ffi/src/types/mod.rs

@@ -1,7 +1,9 @@
+pub mod fee_reserve;
 pub mod melted;
 pub mod proofs_status;
 pub mod send_proofs;
 
+pub use fee_reserve::FeeReserve;
 pub use melted::Melted;
 pub use proofs_status::ProofsStatus;
 pub use send_proofs::SendProofs;