Skip to content

Commit

Permalink
Show Network ID when creating and inspecting (paritytech#10838)
Browse files Browse the repository at this point in the history
Signed-off-by: Antonio Yang <yanganto@gmail.com>
  • Loading branch information
yanganto authored and grishasobol committed Mar 28, 2022
1 parent 499f78e commit d88b0b5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions client/cli/src/commands/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ pub fn print_from_uri<Pair>(
Pair::Public: Into<MultiSigner>,
{
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);
Expand All @@ -81,6 +82,7 @@ pub fn print_from_uri<Pair>(
OutputType::Json => {
let json = json!({
"secretPhrase": uri,
"networkId": network_id,
"secretSeed": format_seed::<Pair>(seed),
"publicKey": format_public_key::<Pair>(public_key.clone()),
"ss58PublicKey": public_key.to_ss58check_with_version(network_override),
Expand All @@ -95,12 +97,14 @@ pub fn print_from_uri<Pair>(
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::<Pair>(seed),
format_public_key::<Pair>(public_key.clone()),
format_account_id::<Pair>(public_key.clone()),
Expand All @@ -117,6 +121,7 @@ pub fn print_from_uri<Pair>(
OutputType::Json => {
let json = json!({
"secretKeyUri": uri,
"networkId": network_id,
"secretSeed": if let Some(seed) = seed { format_seed::<Pair>(seed) } else { "n/a".into() },
"publicKey": format_public_key::<Pair>(public_key.clone()),
"ss58PublicKey": public_key.to_ss58check_with_version(network_override),
Expand All @@ -131,12 +136,14 @@ pub fn print_from_uri<Pair>(
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::<Pair>(seed) } else { "n/a".into() },
format_public_key::<Pair>(public_key.clone()),
format_account_id::<Pair>(public_key.clone()),
Expand Down Expand Up @@ -167,7 +174,7 @@ pub fn print_from_uri<Pair>(
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 \
Expand Down Expand Up @@ -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 \
Expand Down

0 comments on commit d88b0b5

Please sign in to comment.