mirror of
https://github.com/aljazceru/cdk.git
synced 2025-12-22 23:25:22 +01:00
feat: restart minting in cdk-cli with quote id
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::{anyhow, Result};
|
||||||
use cdk::amount::SplitTarget;
|
use cdk::amount::SplitTarget;
|
||||||
use cdk::cdk_database::{Error, WalletDatabase};
|
use cdk::cdk_database::{Error, WalletDatabase};
|
||||||
use cdk::mint_url::MintUrl;
|
use cdk::mint_url::MintUrl;
|
||||||
@@ -18,13 +18,16 @@ pub struct MintSubCommand {
|
|||||||
/// Mint url
|
/// Mint url
|
||||||
mint_url: MintUrl,
|
mint_url: MintUrl,
|
||||||
/// Amount
|
/// Amount
|
||||||
amount: u64,
|
amount: Option<u64>,
|
||||||
/// Currency unit e.g. sat
|
/// Currency unit e.g. sat
|
||||||
#[arg(default_value = "sat")]
|
#[arg(default_value = "sat")]
|
||||||
unit: String,
|
unit: String,
|
||||||
/// Quote description
|
/// Quote description
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
description: Option<String>,
|
description: Option<String>,
|
||||||
|
/// Quote Id
|
||||||
|
#[arg(short, long)]
|
||||||
|
quote_id: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn mint(
|
pub async fn mint(
|
||||||
@@ -50,9 +53,12 @@ pub async fn mint(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let quote = wallet
|
let quote_id = match &sub_command_args.quote_id {
|
||||||
.mint_quote(Amount::from(sub_command_args.amount), description)
|
None => {
|
||||||
.await?;
|
let amount = sub_command_args
|
||||||
|
.amount
|
||||||
|
.ok_or(anyhow!("Amount must be defined"))?;
|
||||||
|
let quote = wallet.mint_quote(Amount::from(amount), description).await?;
|
||||||
|
|
||||||
println!("Quote: {:#?}", quote);
|
println!("Quote: {:#?}", quote);
|
||||||
|
|
||||||
@@ -71,8 +77,12 @@ pub async fn mint(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
quote.id
|
||||||
|
}
|
||||||
|
Some(quote_id) => quote_id.to_string(),
|
||||||
|
};
|
||||||
|
|
||||||
let proofs = wallet.mint("e.id, SplitTarget::default(), None).await?;
|
let proofs = wallet.mint("e_id, SplitTarget::default(), None).await?;
|
||||||
|
|
||||||
let receive_amount = proofs.total_amount()?;
|
let receive_amount = proofs.total_amount()?;
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@
|
|||||||
# Nightly used for formatting
|
# Nightly used for formatting
|
||||||
nightly_toolchain = pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default.override {
|
nightly_toolchain = pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default.override {
|
||||||
targets = [ "wasm32-unknown-unknown" ]; # wasm
|
targets = [ "wasm32-unknown-unknown" ]; # wasm
|
||||||
extensions = [ "rustfmt" "clippy" "rust-src" ];
|
extensions = [ "rustfmt" "clippy" "rust-src" "rust-analyzer" ];
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user