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 committee, validator, validators commands #2185

Merged
merged 2 commits into from
Mar 19, 2024
Merged
Changes from 1 commit
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
37 changes: 36 additions & 1 deletion cli/src/wallet_cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use iota_sdk::{
OutputId, TokenId,
},
payload::signed_transaction::TransactionId,
slot::SlotIndex,
slot::{EpochIndex, SlotIndex},
IdentifierError,
},
utils::ConvertTo,
Expand Down Expand Up @@ -103,6 +103,8 @@ pub enum WalletCommand {
},
/// Print details about claimable outputs - if there are any.
ClaimableOutputs,
/// Get the committee for the given epoch.
Committee { epoch: Option<EpochIndex> },
/// Checks if an account is ready to issue a block.
Congestion {
account_id: Option<AccountId>,
Expand Down Expand Up @@ -325,6 +327,13 @@ pub enum WalletCommand {
},
/// List the unspent outputs.
UnspentOutputs,
/// Get information of a validator.
Validator { account_id: AccountId },
/// List all validators known to the node.
Validators {
page_size: Option<u32>,
DaughterOfMars marked this conversation as resolved.
Show resolved Hide resolved
cursor: Option<String>,
},
// /// Cast votes for an event.
// Vote {
// /// Event ID for which to cast votes, e.g.
Expand Down Expand Up @@ -620,6 +629,13 @@ pub async fn claimable_outputs_command(wallet: &Wallet) -> Result<(), Error> {
Ok(())
}

/// `committee` command
pub async fn committee_command(wallet: &Wallet, epoch: Option<EpochIndex>) -> Result<(), Error> {
let committee = wallet.client().get_committee(epoch).await?;
println_log_info!("{committee:#?}");
Ok(())
}

// `congestion` command
pub async fn congestion_command(
wallet: &Wallet,
Expand Down Expand Up @@ -1191,6 +1207,20 @@ pub async fn unspent_outputs_command(wallet: &Wallet) -> Result<(), Error> {
)
}

/// `validator` command
pub async fn validator_command(wallet: &Wallet, account_id: &AccountId) -> Result<(), Error> {
let validator = wallet.client().get_validator(account_id).await?;
println_log_info!("{validator:#?}");
Ok(())
}

/// `validators` command
pub async fn validators_command(wallet: &Wallet, page_size: Option<u32>, cursor: Option<String>) -> Result<(), Error> {
let validators = wallet.client().get_validators(page_size, cursor).await?;
println_log_info!("{validators:#?}");
Ok(())
}

// pub async fn vote_command(wallet: &Wallet, event_id: ParticipationEventId, answers: Vec<u8>) -> Result<(), Error> {
// let transaction = wallet.vote(Some(event_id), Some(answers)).await?;

Expand Down Expand Up @@ -1457,6 +1487,7 @@ pub async fn prompt_internal(
claim_command(wallet, output_id).await
}
WalletCommand::ClaimableOutputs => claimable_outputs_command(wallet).await,
WalletCommand::Committee { epoch } => committee_command(wallet, epoch).await,
WalletCommand::Congestion { account_id, work_score } => {
congestion_command(wallet, account_id, work_score).await
}
Expand Down Expand Up @@ -1632,6 +1663,10 @@ pub async fn prompt_internal(
// decrease_voting_power_command(wallet, amount).await
// }
// WalletCommand::VotingOutput => voting_output_command(wallet).await,
WalletCommand::Validator { account_id } => validator_command(wallet, &account_id).await,
WalletCommand::Validators { page_size, cursor } => {
validators_command(wallet, page_size, cursor).await
}
}
.unwrap_or_else(|err| {
println_log_error!("{err}");
Expand Down
Loading