Переглянути джерело

fix: add unit and memo to ffi function

thesimplekid 1 рік тому
батько
коміт
ab5fdc44a1

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

@@ -299,7 +299,7 @@ interface Wallet {
     [Throws=CashuSdkError]
     [Throws=CashuSdkError]
 	RequestMintResponse request_mint(Amount amount);
 	RequestMintResponse request_mint(Amount amount);
     [Throws=CashuSdkError]
     [Throws=CashuSdkError]
-	Token mint_token(Amount amount, string hash);
+	Token mint_token(Amount amount, string hash, string? unit, string? memo);
     [Throws=CashuSdkError]
     [Throws=CashuSdkError]
 	sequence<Proof> mint(Amount amount, string hash);
 	sequence<Proof> mint(Amount amount, string hash);
     [Throws=CashuSdkError]
     [Throws=CashuSdkError]
@@ -313,7 +313,7 @@ interface Wallet {
     [Throws=CashuSdkError]
     [Throws=CashuSdkError]
 	Melted melt(Bolt11Invoice invoice, sequence<Proof> proofs, Amount fee_reserve);
 	Melted melt(Bolt11Invoice invoice, sequence<Proof> proofs, Amount fee_reserve);
     [Throws=CashuSdkError]
     [Throws=CashuSdkError]
-	string proof_to_token(sequence<Proof> proof, string? memo);
+	string proof_to_token(sequence<Proof> proof, string? unit, string? memo);
 };
 };
 
 
 
 

+ 19 - 4
bindings/cashu-sdk-ffi/src/wallet.rs

@@ -50,9 +50,18 @@ impl Wallet {
         Ok(Arc::new(mint_response))
         Ok(Arc::new(mint_response))
     }
     }
 
 
-    pub fn mint_token(&self, amount: Arc<Amount>, hash: String) -> Result<Arc<Token>> {
-        let token = RUNTIME
-            .block_on(async { self.inner.mint_token(*amount.as_ref().deref(), &hash).await })?;
+    pub fn mint_token(
+        &self,
+        amount: Arc<Amount>,
+        hash: String,
+        unit: Option<String>,
+        memo: Option<String>,
+    ) -> Result<Arc<Token>> {
+        let token = RUNTIME.block_on(async {
+            self.inner
+                .mint_token(*amount.as_ref().deref(), &hash, unit, memo)
+                .await
+        })?;
 
 
         Ok(Arc::new(token.into()))
         Ok(Arc::new(token.into()))
     }
     }
@@ -125,9 +134,15 @@ impl Wallet {
         Ok(Arc::new(melted.into()))
         Ok(Arc::new(melted.into()))
     }
     }
 
 
-    pub fn proof_to_token(&self, proofs: Vec<Arc<Proof>>, memo: Option<String>) -> Result<String> {
+    pub fn proof_to_token(
+        &self,
+        proofs: Vec<Arc<Proof>>,
+        unit: Option<String>,
+        memo: Option<String>,
+    ) -> Result<String> {
         Ok(self.inner.proofs_to_token(
         Ok(self.inner.proofs_to_token(
             proofs.iter().map(|p| p.as_ref().deref().clone()).collect(),
             proofs.iter().map(|p| p.as_ref().deref().clone()).collect(),
+            unit,
             memo,
             memo,
         )?)
         )?)
     }
     }