Skip to content

Commit

Permalink
CLI: add committee, validator, validators commands (#2185)
Browse files Browse the repository at this point in the history
* add committee, validator, validators commands

* rm pagination
  • Loading branch information
Alex6323 authored Mar 19, 2024
1 parent 67e9a66 commit 9ad22f7
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 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,10 @@ 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,
// /// Cast votes for an event.
// Vote {
// /// Event ID for which to cast votes, e.g.
Expand Down Expand Up @@ -620,6 +626,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 +1204,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) -> Result<(), Error> {
let validators = wallet.client().get_validators(None, None).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 +1484,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 +1660,8 @@ 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 => validators_command(wallet).await,
}
.unwrap_or_else(|err| {
println_log_error!("{err}");
Expand Down

0 comments on commit 9ad22f7

Please sign in to comment.