-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
List proofs #397
List proofs #397
Conversation
408361d
to
413a5ca
Compare
Thanks for this, I think we should list them under a header for each mint and then we shouldn't print the whole proofs as its too hard to read and i think has too much info. I'm thinking something like below and those proofs sorted by amount. 0: https://test.mint.com |
We can simplify formatting if we modify formatters for Amounts and CurrencyUnits: diff --git a/crates/cdk-cli/src/sub_commands/list_mint_proofs.rs b/crates/cdk-cli/src/sub_commands/list_mint_proofs.rs
index d9661db..f4e8a4d 100644
--- a/crates/cdk-cli/src/sub_commands/list_mint_proofs.rs
+++ b/crates/cdk-cli/src/sub_commands/list_mint_proofs.rs
@@ -23,11 +23,11 @@ async fn list_proofs(
for (i, (mint_url, proofs)) in wallets_proofs.iter().enumerate() {
let mint_url = mint_url.clone();
println!("{i}: {mint_url}");
- // TODO make this try to format this to a more readable format.
- println!("|Amount |Unit\t| Secret\t\t\t\t\t\t\t\t| Dleq proof included(bool)");
+ println!("| Amount | Unit | Secret | DLEQ proof included");
+ println!("|----------|------|------------------------------------------------------------------|--------------------");
for proof in &proofs.0 {
println!(
- "|{}\t|{}\t| {}\t| {:#?}",
+ "| {:8} | {:4} | {:64} | {}",
proof.amount,
proofs.1,
proof.secret,
diff --git a/crates/cdk/src/amount.rs b/crates/cdk/src/amount.rs
index 7e2d4e2..2d9fa34 100644
--- a/crates/cdk/src/amount.rs
+++ b/crates/cdk/src/amount.rs
@@ -138,7 +138,11 @@ impl Default for &Amount {
impl fmt::Display for Amount {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- write!(f, "{}", self.0)
+ if let Some(width) = f.width() {
+ write!(f, "{:width$}", self.0, width = width)
+ } else {
+ write!(f, "{}", self.0)
+ }
}
}
diff --git a/crates/cdk/src/nuts/nut00/mod.rs b/crates/cdk/src/nuts/nut00/mod.rs
index 58fff63..9822379 100644
--- a/crates/cdk/src/nuts/nut00/mod.rs
+++ b/crates/cdk/src/nuts/nut00/mod.rs
@@ -378,11 +378,16 @@ impl FromStr for CurrencyUnit {
impl fmt::Display for CurrencyUnit {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- match self {
- CurrencyUnit::Sat => write!(f, "sat"),
- CurrencyUnit::Msat => write!(f, "msat"),
- CurrencyUnit::Usd => write!(f, "usd"),
- CurrencyUnit::Eur => write!(f, "eur"),
+ let s = match self {
+ CurrencyUnit::Sat => "sat",
+ CurrencyUnit::Msat => "msat",
+ CurrencyUnit::Usd => "usd",
+ CurrencyUnit::Eur => "eur",
+ };
+ if let Some(width) = f.width() {
+ write!(f, "{:width$}", s, width = width)
+ } else {
+ write!(f, "{}", s)
}
}
} |
0b112c3
to
c57c292
Compare
Thank you for the feedback, I agree it was way to verbose to print the whole proof, changed it to be more readable. |
Thank you! This was way simpler updated with c57c292. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thank you. Can you just fix the clippy errors then squash the commits
fix typo make output more readable. Co-authored-by: Pavol Rusnak <[email protected]>
e019a22
to
a2190ab
Compare
About
New command which lists proofs in wallet. Sorted buy mint and time received.
Would it be preferred to sort the proofs buy amount instead?