feat(bindings): js bindings send

This commit is contained in:
thesimplekid
2024-05-07 00:41:47 +01:00
parent c62381f252
commit 4cc02b7770
2 changed files with 18 additions and 2 deletions

View File

@@ -5,7 +5,7 @@ use std::sync::Arc;
use cdk::nuts::SigningKey;
use cdk::url::UncheckedUrl;
use cdk::wallet::Wallet;
use cdk::HttpClient;
use cdk::{Amount, HttpClient};
use cdk_rexie::RexieWalletDatabase;
use wasm_bindgen::prelude::*;
@@ -147,4 +147,20 @@ impl JsWallet {
Ok(())
}
#[wasm_bindgen(js_name = send)]
pub async fn send(
&mut self,
mint_url: String,
unit: JsCurrencyUnit,
memo: Option<String>,
amount: u64,
) -> Result<String> {
let mint_url = UncheckedUrl::from_str(&mint_url).map_err(into_err)?;
self.inner
.send(&mint_url, &unit.into(), memo, Amount::from(amount), None)
.await
.map_err(into_err)
}
}

View File

@@ -485,7 +485,7 @@ impl WalletDatabase for RexieWalletDatabase {
let proofs = serde_wasm_bindgen::to_value(&proofs).map_err(Error::from)?;
proofs_store
.add(&proofs, Some(&mint_url))
.put(&proofs, Some(&mint_url))
.await
.map_err(Error::from)?;
}