Skip to content
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

cli: add types and enumeration when listing Outputs #955

Merged
merged 18 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions cli/src/command/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@
U256,
};

use crate::{error::Error, helper::to_utc_date_time, println_log_info};
use crate::{
error::Error,
helper::{get_output_type_str, to_utc_date_time},

Check failure on line 30 in cli/src/command/account.rs

View workflow job for this annotation

GitHub Actions / Check Unused Dependencies

unresolved import `crate::helper::get_output_type_str`
println_log_info,
};

#[derive(Debug, Parser)]
#[command(author, version, about, long_about = None, propagate_version = true)]
Expand Down Expand Up @@ -627,10 +631,10 @@
if outputs.is_empty() {
println_log_info!("No outputs found");
} else {
let output_ids: Vec<OutputId> = outputs.iter().map(|o| o.output_id).collect();
println_log_info!("Outputs: {output_ids:#?}");
for (i, output_data) in outputs.into_iter().enumerate() {
Thoralf-M marked this conversation as resolved.
Show resolved Hide resolved
println_log_info!("{}\t{}\t{}", i, &output_data.output_id, output_data.output.kind_str());
thibault-martinez marked this conversation as resolved.
Show resolved Hide resolved
thibault-martinez marked this conversation as resolved.
Show resolved Hide resolved
}
}

Ok(())
}

Expand Down
1 change: 1 addition & 0 deletions cli/src/command/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ pub async fn new_account_command(
pub async fn node_info_command(storage_path: &Path) -> Result<Wallet, Error> {
let wallet = unlock_wallet(storage_path, None, None).await?;
let node_info = wallet.client().get_info().await?;
println_log_info!("{:?}", wallet.get_account_aliases().await.unwrap());
thibault-martinez marked this conversation as resolved.
Show resolved Hide resolved

thibault-martinez marked this conversation as resolved.
Show resolved Hide resolved
println_log_info!("Current node info: {}", serde_json::to_string_pretty(&node_info)?);
thibault-martinez marked this conversation as resolved.
Show resolved Hide resolved

Expand Down
1 change: 1 addition & 0 deletions cli/src/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use iota_sdk::{
client::{utils::Password, verify_mnemonic},
crypto::keys::bip39::Mnemonic,
types::block::output::Output,

Check warning on line 12 in cli/src/helper.rs

View workflow job for this annotation

GitHub Actions / Check Unused Dependencies

unused import: `types::block::output::Output`
wallet::{Account, Wallet},
};
use tokio::{
Expand Down
11 changes: 11 additions & 0 deletions sdk/src/types/block/output/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,17 @@ impl Output {
}
}

/// Return the output kind of an [`Output`] as a string.
thibault-martinez marked this conversation as resolved.
Show resolved Hide resolved
pub fn kind_str(&self) -> &str {
thibault-martinez marked this conversation as resolved.
Show resolved Hide resolved
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 {
Expand Down
Loading