Select Git revision
-
Hugo Trentesaux authored
closes #35
Hugo Trentesaux authoredcloses #35
smith.rs 8.19 KiB
use crate::*;
use std::ops::Deref;
type SessionKeys = [u8; 128];
#[cfg(feature = "gdev")]
type SmithMembershipMetaData =
runtime::runtime_types::common_runtime::entities::SmithMembershipMetaData<SessionKeys>;
/// define smith subcommands
#[derive(Clone, Default, Debug, clap::Parser)]
pub enum Subcommand {
/// Request smith membership
Request { endpoint: String },
/// Emit a smith certification
Cert { to: u32 },
/// Claim smith membership
Claim,
/// Renew smith membership
Renew,
/// go online
GoOnline,
/// go offline
#[default]
GoOffline,
/// Rotate and set session keys
UpdateKeys,
/// set sudo keys
SudoSetKey { new_key: AccountId },
/// List upcoming expirations that require an action
ShowExpire {
/// Show certs that expire within less than this number of blocks
#[clap(short, long, default_value_t = 100800)]
blocks: u32,
/// Show authorities that should rotate keys within less than this number of sessions
#[clap(short, long, default_value_t = 100)]
sessions: u32,
},
/// List online authorities
ShowOnline,
/// count of smith member
MemberCount,
}
/// handle smith commands
pub async fn handle_command(data: Data, command: Subcommand) -> anyhow::Result<()> {
let mut data = data.build_client().await?;
match command {
Subcommand::Request { endpoint } => {
request_smith_membership(&data, endpoint).await?;
}
Subcommand::Claim => {
claim_smith_membership(&data).await?;
}
Subcommand::Renew => {
renew_smith_membership(&data).await?;
}
Subcommand::GoOnline => {
go_online(&data).await?;
}
Subcommand::GoOffline => {
go_offline(&data).await?;
}
Subcommand::Cert { to } => {
data = data.fetch_idty_index().await?;
cert(&data, to).await?
}
Subcommand::UpdateKeys => {
update_session_keys(&data).await?;
}