diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index b063c4b294..172c5ad0d6 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `WalletCommand::Accounts` variant to list all available accounts in a wallet; - `addresses` now additionally prints the hex version of the address; +- `outputs`, `unspent-outputs` print a list that includes number and type of the output; ## 1.0.0 - 2023-07-27 diff --git a/cli/src/command/account.rs b/cli/src/command/account.rs index 1fbf578c0e..6192099b14 100644 --- a/cli/src/command/account.rs +++ b/cli/src/command/account.rs @@ -627,10 +627,11 @@ pub async fn outputs_command(account: &Account) -> Result<(), Error> { if outputs.is_empty() { println_log_info!("No outputs found"); } else { - let output_ids: Vec = outputs.iter().map(|o| o.output_id).collect(); - println_log_info!("Outputs: {output_ids:#?}"); + println_log_info!("Outputs:"); + for (i, output_data) in outputs.into_iter().enumerate() { + println_log_info!("{}\t{}\t{}", i, &output_data.output_id, output_data.output.kind_str()); + } } - Ok(()) } @@ -786,8 +787,10 @@ pub async fn unspent_outputs_command(account: &Account) -> Result<(), Error> { if outputs.is_empty() { println_log_info!("No outputs found"); } else { - let output_ids: Vec = outputs.iter().map(|o| o.output_id).collect(); - println_log_info!("Unspent outputs: {output_ids:#?}"); + println_log_info!("Unspent outputs:"); + for (i, output_data) in outputs.into_iter().enumerate() { + println_log_info!("{}\t{}\t{}", i, &output_data.output_id, output_data.output.kind_str()); + } } Ok(()) diff --git a/sdk/CHANGELOG.md b/sdk/CHANGELOG.md index f2657b58eb..ffc2e4309b 100644 --- a/sdk/CHANGELOG.md +++ b/sdk/CHANGELOG.md @@ -21,6 +21,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## 1.1.0 - 2023-MM-DD +### Added + +- `Output::kind_str()` method; + ### Changed - `StrongholdAdapterBuilder` updated to be slightly more ergonomic; diff --git a/sdk/src/types/block/output/mod.rs b/sdk/src/types/block/output/mod.rs index 4c6cb7d6f7..6cf6365424 100644 --- a/sdk/src/types/block/output/mod.rs +++ b/sdk/src/types/block/output/mod.rs @@ -164,6 +164,17 @@ impl Output { } } + /// Returns the output kind of an [`Output`] as a string. + pub fn kind_str(&self) -> &str { + match self { + Self::Alias(_) => "Alias", + Self::Basic(_) => "Basic", + Self::Foundry(_) => "Foundry", + Self::Nft(_) => "Nft", + Self::Treasury(_) => "Treasury", + } + } + /// Returns the amount of an [`Output`]. pub fn amount(&self) -> u64 { match self {