diff --git a/src/commands/account.rs b/src/commands/account.rs index fa0407a3fd47b8e67b3ce4f7b5cbbff8d0ae5996..c1216b6f9942a4f6bb67ce2f38a228573835857e 100644 --- a/src/commands/account.rs +++ b/src/commands/account.rs @@ -11,6 +11,7 @@ pub enum Subcommand { /// Amount to transfer amount: u64, /// Destination address + #[clap(value_name = "ADDRESS")] dest: AccountId, /// Prevent from going below account existential deposit #[clap(short = 'k', long = "keep-alive")] @@ -20,11 +21,12 @@ pub enum Subcommand { is_ud: bool, }, /// Transfer the same amount for each space-separated address. - /// If an address appears mutiple times, it will get multiple times the same amount + /// If an address appears multiple times, it will get multiple times the same amount TransferMultiple { /// Amount given to each destination address amount: u64, /// List of target addresses + #[clap(value_name = "ADDRESSES")] dests: Vec<AccountId>, }, /// Unlink the account from the linked identity diff --git a/src/commands/identity.rs b/src/commands/identity.rs index e0ddf8af3436c2a4b6e1f2f8e1b1b01d4ae9c1d5..0cc8f4f1cd765783a93b52df1cad89d04be6d24a 100644 --- a/src/commands/identity.rs +++ b/src/commands/identity.rs @@ -18,7 +18,7 @@ pub enum Subcommand { Show, /// Fetch identity Get { - #[clap(short = 'a', long = "address")] + #[clap(short = 'a', long = "address", value_name = "ADDRESS")] account_id: Option<AccountId>, #[clap(short = 'i', long = "identity")] identity_id: Option<IdtyId>, @@ -28,7 +28,10 @@ pub enum Subcommand { /// Create and certify an identity /// /// Caller must be member, and the target account must exist. - Create { target: AccountId }, + Create { + #[clap(value_name = "ADDRESS")] + target: AccountId, + }, /// Confirm an identity /// /// To be called by the certified not-yet-member account, to become member. @@ -37,13 +40,22 @@ pub enum Subcommand { /// make sure that it's ok otherwise currency is slashed RequestDistanceEvaluation, /// Request distance evaluation for unvalidated identity - RequestDistanceEvaluationFor { target: String }, + RequestDistanceEvaluationFor { + #[clap(value_name = "USERNAME")] + target: String, + }, /// Certify an identity #[clap(alias = "cert")] - Certify { target: String }, + Certify { + #[clap(value_name = "USERNAME")] + target: String, + }, /// Renew a certification #[clap(alias = "renew")] - RenewCert { target: String }, + RenewCert { + #[clap(value_name = "USERNAME")] + target: String, + }, /// Revoke an identity immediately Revoke, /// Generate a revocation document for the provided account diff --git a/src/commands/smith.rs b/src/commands/smith.rs index 21e243f812a9747f2a54ab4cff935254399cd991..c2190c5c416f740ba772e89be9ea8a83703dea04 100644 --- a/src/commands/smith.rs +++ b/src/commands/smith.rs @@ -51,12 +51,18 @@ pub enum Subcommand { /// List online authorities ShowOnline, /// Invite identity to become smith - Invite { target: String }, + Invite { + #[clap(value_name = "USERNAME")] + target: String, + }, /// Accept invitation Accept, /// Certify smith #[clap(alias = "cert")] - Certify { target: String }, + Certify { + #[clap(value_name = "USERNAME")] + target: String, + }, } /// handle smith commands diff --git a/src/commands/vault.rs b/src/commands/vault.rs index f046df212e51d0a26483fa03d362744846065d62..7bb6dfe0fd779429c8fa6bbab78e98d94d51deff 100644 --- a/src/commands/vault.rs +++ b/src/commands/vault.rs @@ -45,9 +45,9 @@ pub enum Subcommand { /// Add a derivation to an existing account #[clap(long_about = "Add a derivation to an existing account.\n\ \n\ - Only \"substrate\" and \"seed\" format are supported for derivations.\n\ + Only \"sr25519\" crypto scheme is supported for derivations.\n\ \n\ - Use command `vault list base` to see available <Base> account and their format\n\ + Use command `vault list base` to see available <Base> account and their crypto scheme\n\ And then use command 'vault list for' to find all accounts linked to that <Base> account.")] #[clap(alias = "deriv")] #[clap(alias = "derivation")] @@ -262,13 +262,12 @@ pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliE if let Some(crypto_scheme) = base_account.crypto_scheme { if CryptoScheme::from(crypto_scheme) == CryptoScheme::Ed25519 { println!( - "Only \"{}\" and \"{}\" format are supported for derivations", - Into::<&str>::into(SecretFormat::Substrate), - Into::<&str>::into(SecretFormat::Seed) + "Only \"{}\" crypto scheme is supported for derivations.", + Into::<&str>::into(CryptoScheme::Sr25519), ); println!(); println!( - "Use command `vault list base` to see available <Base> account and their format\n\ + "Use command `vault list base` to see available <Base> account and their crypto scheme\n\ And then use command 'vault list for' to find all accounts linked to that <Base> account" ); return Ok(()); @@ -1004,6 +1003,8 @@ pub async fn try_fetch_key_pair( &address.to_string(), ); + println!("(Vault: {})", account_tree_node.borrow().account); + let password = inputs::prompt_password()?; let secret_suri = vault_account::compute_suri_account_tree_node(&account_tree_node, password)?; diff --git a/src/data.rs b/src/data.rs index bfcb7d5f34984da9e556599cb5972833c1fb6752..1e877c0977c8b760d4f00d0c4a596d22eb92957f 100644 --- a/src/data.rs +++ b/src/data.rs @@ -125,7 +125,21 @@ impl Data { None => loop { match fetch_or_get_keypair(self, self.cfg.address.clone()).await { Ok(pair) => return pair, - Err(e) => println!("{e:?} → retry"), + Err(e) => { + //Adapted code to still be able to go out of the loop when user hit "Esc" key or "ctrl+c" when prompted for a value + //otherwise only way was to kill the process ! + if let GcliError::Input(message) = &e { + match message.as_str() { + "Operation was interrupted by the user" + | "Operation was canceled by the user" => { + panic!("{}", e.to_string()); + } + _ => {} + } + } + + println!("{e:?} → retry") + } } }, } diff --git a/src/entities/vault_account.rs b/src/entities/vault_account.rs index 760582da15ef7ffc4446773c50636ff99f00b52f..cfb7003e6640b0c1ef1060aa6d6782ac2d3dfb5c 100644 --- a/src/entities/vault_account.rs +++ b/src/entities/vault_account.rs @@ -579,7 +579,8 @@ pub fn compute_suri_account_tree_node( if let Some(account_path) = &borrowed_node.account.path { suri.insert_str(0, account_path); } else if let Some(encrypted_suri) = &borrowed_node.account.encrypted_suri { - let decrypted_suri = vault::decrypt(encrypted_suri, password.clone()).unwrap(); + let decrypted_suri = vault::decrypt(encrypted_suri, password.clone()) + .map_err(|e| GcliError::Input(e.to_string()))?; let secret_suri = String::from_utf8(decrypted_suri).map_err(|e| anyhow!(e))?; suri.insert_str(0, &secret_suri); } else {