feat: new struct 'MintUrl' which trims trailing slashes (#283)

https://github.com/cashubtc/nuts/pull/151/files
This commit is contained in:
Caleb Beery
2024-08-12 12:32:44 -07:00
committed by GitHub
parent e57c7f1e9d
commit 40554987e1
28 changed files with 385 additions and 229 deletions

View File

@@ -1,8 +1,8 @@
use std::collections::HashMap;
use anyhow::Result;
use cdk::mint_url::MintUrl;
use cdk::nuts::CurrencyUnit;
use cdk::url::UncheckedUrl;
use cdk::wallet::multi_mint_wallet::MultiMintWallet;
use cdk::Amount;
@@ -14,8 +14,8 @@ pub async fn balance(multi_mint_wallet: &MultiMintWallet) -> Result<()> {
pub async fn mint_balances(
multi_mint_wallet: &MultiMintWallet,
unit: &CurrencyUnit,
) -> Result<Vec<(UncheckedUrl, Amount)>> {
let wallets: HashMap<UncheckedUrl, Amount> = multi_mint_wallet.get_balances(unit).await?;
) -> Result<Vec<(MintUrl, Amount)>> {
let wallets: HashMap<MintUrl, Amount> = multi_mint_wallet.get_balances(unit).await?;
let mut wallets_vec = Vec::with_capacity(wallets.capacity());

View File

@@ -1,16 +1,17 @@
use std::str::FromStr;
use anyhow::Result;
use cdk::mint_url::MintUrl;
use cdk::nuts::CurrencyUnit;
use cdk::wallet::multi_mint_wallet::WalletKey;
use cdk::wallet::MultiMintWallet;
use cdk::{Amount, UncheckedUrl};
use cdk::Amount;
use clap::Args;
#[derive(Args)]
pub struct BurnSubCommand {
/// Mint Url
mint_url: Option<UncheckedUrl>,
mint_url: Option<MintUrl>,
/// Currency unit e.g. sat
#[arg(default_value = "sat")]
unit: String,

View File

@@ -5,8 +5,8 @@ use std::time::Duration;
use anyhow::Result;
use cdk::amount::SplitTarget;
use cdk::cdk_database::{Error, WalletDatabase};
use cdk::mint_url::MintUrl;
use cdk::nuts::{CurrencyUnit, MintQuoteState};
use cdk::url::UncheckedUrl;
use cdk::wallet::multi_mint_wallet::WalletKey;
use cdk::wallet::{MultiMintWallet, Wallet};
use cdk::Amount;
@@ -16,7 +16,7 @@ use tokio::time::sleep;
#[derive(Args)]
pub struct MintSubCommand {
/// Mint url
mint_url: UncheckedUrl,
mint_url: MintUrl,
/// Amount
amount: u64,
/// Currency unit e.g. sat

View File

@@ -1,5 +1,5 @@
use anyhow::Result;
use cdk::url::UncheckedUrl;
use cdk::mint_url::MintUrl;
use cdk::HttpClient;
use clap::Args;
use url::Url;
@@ -7,7 +7,7 @@ use url::Url;
#[derive(Args)]
pub struct MintInfoSubcommand {
/// Cashu Token
mint_url: UncheckedUrl,
mint_url: MintUrl,
}
pub async fn mint_info(proxy: Option<Url>, sub_command_args: &MintInfoSubcommand) -> Result<()> {

View File

@@ -1,8 +1,8 @@
use std::str::FromStr;
use anyhow::{anyhow, Result};
use cdk::mint_url::MintUrl;
use cdk::nuts::CurrencyUnit;
use cdk::url::UncheckedUrl;
use cdk::wallet::multi_mint_wallet::WalletKey;
use cdk::wallet::MultiMintWallet;
use clap::Args;
@@ -10,7 +10,7 @@ use clap::Args;
#[derive(Args)]
pub struct RestoreSubCommand {
/// Mint Url
mint_url: UncheckedUrl,
mint_url: MintUrl,
/// Currency unit e.g. sat
#[arg(default_value = "sat")]
unit: String,

View File

@@ -1,6 +1,6 @@
use anyhow::{anyhow, Result};
use cdk::mint_url::MintUrl;
use cdk::nuts::CurrencyUnit;
use cdk::url::UncheckedUrl;
use cdk::wallet::multi_mint_wallet::WalletKey;
use cdk::wallet::MultiMintWallet;
use clap::Args;
@@ -8,9 +8,9 @@ use clap::Args;
#[derive(Args)]
pub struct UpdateMintUrlSubCommand {
/// Old Mint Url
old_mint_url: UncheckedUrl,
old_mint_url: MintUrl,
/// New Mint Url
new_mint_url: UncheckedUrl,
new_mint_url: MintUrl,
}
pub async fn update_mint_url(