feat: check_pending by unit

This commit is contained in:
thesimplekid
2024-06-12 09:40:54 +01:00
parent eb8bd373ad
commit 9377b71104
3 changed files with 11 additions and 4 deletions

View File

@@ -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())

View File

@@ -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");

View File

@@ -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,
)