Skip to content

Commit

Permalink
Merge branch 'master' into ab/fix-parentchain-block-import-for-all-ta…
Browse files Browse the repository at this point in the history
…rgets
  • Loading branch information
brenzi authored Oct 16, 2024
2 parents 0f1b435 + 039a3e4 commit 22e147f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
9 changes: 8 additions & 1 deletion cli/src/trusted_base_cli/commands/get_fingerprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ use itp_utils::FromHexPrefixed;
use log::*;

#[derive(Parser)]
pub struct GetFingerprintCommand {}
pub struct GetFingerprintCommand {
/// also print as hex
#[clap(short = 'x', long = "hex")]
hex: bool,
}

impl GetFingerprintCommand {
pub(crate) fn run(&self, cli: &Cli, _trusted_args: &TrustedCli) -> CliResult {
Expand Down Expand Up @@ -59,6 +63,9 @@ impl GetFingerprintCommand {
})?;
let fingerprint_b58 = fingerprint.encode().to_base58();
println!("{}", fingerprint_b58);
if self.hex {
println!("0x{}", hex::encode(fingerprint.encode()));
}
Ok(CliResultOk::FingerprintBase58 { fingerprints: vec![fingerprint_b58] })
}
}
15 changes: 14 additions & 1 deletion cli/src/trusted_base_cli/commands/get_shard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,14 @@ use log::*;
use sp_core::H256;

#[derive(Parser)]
pub struct GetShardCommand {}
pub struct GetShardCommand {
/// also print as hex
#[clap(short = 'x', long = "hex")]
hex: bool,
/// also print as ASCII
#[clap(short = 'a', long = "ascii")]
ascii: bool,
}

impl GetShardCommand {
pub(crate) fn run(&self, cli: &Cli, _trusted_args: &TrustedCli) -> CliResult {
Expand Down Expand Up @@ -62,6 +69,12 @@ impl GetShardCommand {
CliError::WorkerRpcApi { msg: err.to_string() }
})?;
println!("{}", shard.encode().to_base58());
if self.hex {
println!("0x{}", hex::encode(shard));
}
if self.ascii {
println!("{}", String::from_utf8_lossy(&shard.encode()));
}
Ok(CliResultOk::H256 { hash: shard })
}
}

0 comments on commit 22e147f

Please sign in to comment.