From d88b0b5da7c6c1ab9fe905b9c1ceac54260143ae Mon Sep 17 00:00:00 2001 From: Antonio Yang Date: Fri, 11 Feb 2022 17:14:13 +0800 Subject: [PATCH] Show Network ID when creating and inspecting (#10838) Signed-off-by: Antonio Yang --- client/cli/src/commands/utils.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/client/cli/src/commands/utils.rs b/client/cli/src/commands/utils.rs index 7f0413f596012..d20df01e5a90e 100644 --- a/client/cli/src/commands/utils.rs +++ b/client/cli/src/commands/utils.rs @@ -73,6 +73,7 @@ pub fn print_from_uri( Pair::Public: Into, { let password = password.as_ref().map(|s| s.expose_secret().as_str()); + let network_id = String::from(unwrap_or_default_ss58_version(network_override)); if let Ok((pair, seed)) = Pair::from_phrase(uri, password.clone()) { let public_key = pair.public(); let network_override = unwrap_or_default_ss58_version(network_override); @@ -81,6 +82,7 @@ pub fn print_from_uri( OutputType::Json => { let json = json!({ "secretPhrase": uri, + "networkId": network_id, "secretSeed": format_seed::(seed), "publicKey": format_public_key::(public_key.clone()), "ss58PublicKey": public_key.to_ss58check_with_version(network_override), @@ -95,12 +97,14 @@ pub fn print_from_uri( OutputType::Text => { println!( "Secret phrase: {}\n \ + Network ID: {}\n \ Secret seed: {}\n \ Public key (hex): {}\n \ Account ID: {}\n \ Public key (SS58): {}\n \ SS58 Address: {}", uri, + network_id, format_seed::(seed), format_public_key::(public_key.clone()), format_account_id::(public_key.clone()), @@ -117,6 +121,7 @@ pub fn print_from_uri( OutputType::Json => { let json = json!({ "secretKeyUri": uri, + "networkId": network_id, "secretSeed": if let Some(seed) = seed { format_seed::(seed) } else { "n/a".into() }, "publicKey": format_public_key::(public_key.clone()), "ss58PublicKey": public_key.to_ss58check_with_version(network_override), @@ -131,12 +136,14 @@ pub fn print_from_uri( OutputType::Text => { println!( "Secret Key URI `{}` is account:\n \ + Network ID: {} \n \ Secret seed: {}\n \ Public key (hex): {}\n \ Account ID: {}\n \ Public key (SS58): {}\n \ SS58 Address: {}", uri, + network_id, if let Some(seed) = seed { format_seed::(seed) } else { "n/a".into() }, format_public_key::(public_key.clone()), format_account_id::(public_key.clone()), @@ -167,7 +174,7 @@ pub fn print_from_uri( OutputType::Text => { println!( "Public Key URI `{}` is account:\n \ - Network ID/version: {}\n \ + Network ID/Version: {}\n \ Public key (hex): {}\n \ Account ID: {}\n \ Public key (SS58): {}\n \ @@ -217,7 +224,7 @@ where }, OutputType::Text => { println!( - "Network ID/version: {}\n \ + "Network ID/Version: {}\n \ Public key (hex): {}\n \ Account ID: {}\n \ Public key (SS58): {}\n \