mirror of
https://github.com/aljazceru/cdk.git
synced 2026-02-05 05:06:14 +01:00
feat(bindings): js bindings send
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)?;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user