mirror of
https://github.com/aljazceru/cdk.git
synced 2026-02-05 05:06:14 +01:00
feat: check_pending by unit
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
//! Wallet Js Bindings
|
||||
|
||||
use std::ops::Deref;
|
||||
use std::str::FromStr;
|
||||
use std::sync::Arc;
|
||||
@@ -90,7 +92,11 @@ impl JsWallet {
|
||||
}
|
||||
|
||||
#[wasm_bindgen(js_name = checkAllPendingProofs)]
|
||||
pub async fn check_all_pending_proofs(&self, mint_url: Option<String>) -> Result<JsAmount> {
|
||||
pub async fn check_all_pending_proofs(
|
||||
&self,
|
||||
mint_url: Option<String>,
|
||||
unit: Option<JsCurrencyUnit>,
|
||||
) -> Result<JsAmount> {
|
||||
let mint_url = match mint_url {
|
||||
Some(url) => Some(UncheckedUrl::from_str(&url).map_err(into_err)?),
|
||||
None => None,
|
||||
@@ -98,7 +104,7 @@ impl JsWallet {
|
||||
|
||||
Ok(self
|
||||
.inner
|
||||
.check_all_pending_proofs(mint_url)
|
||||
.check_all_pending_proofs(mint_url, unit.map(|u| u.into()))
|
||||
.await
|
||||
.map_err(into_err)?
|
||||
.into())
|
||||
|
||||
@@ -11,7 +11,7 @@ pub struct BurnSubCommand {
|
||||
|
||||
pub async fn burn(wallet: Wallet, sub_command_args: &BurnSubCommand) -> Result<()> {
|
||||
let amount_burnt = wallet
|
||||
.check_all_pending_proofs(sub_command_args.mint_url.clone().map(|u| u.into()))
|
||||
.check_all_pending_proofs(sub_command_args.mint_url.clone().map(|u| u.into()), None)
|
||||
.await?;
|
||||
|
||||
println!("{amount_burnt} burned");
|
||||
|
||||
@@ -365,6 +365,7 @@ impl Wallet {
|
||||
pub async fn check_all_pending_proofs(
|
||||
&self,
|
||||
mint_url: Option<UncheckedUrl>,
|
||||
unit: Option<CurrencyUnit>,
|
||||
) -> Result<Amount, Error> {
|
||||
let mints = match mint_url {
|
||||
Some(mint_url) => HashMap::from_iter(vec![(mint_url, None)]),
|
||||
@@ -378,7 +379,7 @@ impl Wallet {
|
||||
.localstore
|
||||
.get_proofs(
|
||||
Some(mint.clone()),
|
||||
None,
|
||||
unit.clone(),
|
||||
Some(vec![State::Pending, State::Reserved]),
|
||||
None,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user