mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 18:41:03 +00:00
Make export-genesis-wasm output hex (#236)
* Add --raw flag to export-genesis-state * Switch export-genesis-wasm to hex by default Also add --raw flag. This makes it similar to `export-genesis-state`.
This commit is contained in:
@@ -63,6 +63,10 @@ pub struct ExportGenesisStateCommand {
|
|||||||
#[structopt(long, default_value = "100")]
|
#[structopt(long, default_value = "100")]
|
||||||
pub parachain_id: u32,
|
pub parachain_id: u32,
|
||||||
|
|
||||||
|
/// Write output in binary. Default is to write in hex.
|
||||||
|
#[structopt(short, long)]
|
||||||
|
pub raw: bool,
|
||||||
|
|
||||||
/// The name of the chain for that the genesis state should be exported.
|
/// The name of the chain for that the genesis state should be exported.
|
||||||
#[structopt(long)]
|
#[structopt(long)]
|
||||||
pub chain: Option<String>,
|
pub chain: Option<String>,
|
||||||
@@ -75,6 +79,10 @@ pub struct ExportGenesisWasmCommand {
|
|||||||
#[structopt(parse(from_os_str))]
|
#[structopt(parse(from_os_str))]
|
||||||
pub output: Option<PathBuf>,
|
pub output: Option<PathBuf>,
|
||||||
|
|
||||||
|
/// Write output in binary. Default is to write in hex.
|
||||||
|
#[structopt(short, long)]
|
||||||
|
pub raw: bool,
|
||||||
|
|
||||||
/// The name of the chain for that the genesis wasm file should be exported.
|
/// The name of the chain for that the genesis wasm file should be exported.
|
||||||
#[structopt(long)]
|
#[structopt(long)]
|
||||||
pub chain: Option<String>,
|
pub chain: Option<String>,
|
||||||
|
|||||||
@@ -223,12 +223,17 @@ pub fn run() -> Result<()> {
|
|||||||
¶ms.chain.clone().unwrap_or_default(),
|
¶ms.chain.clone().unwrap_or_default(),
|
||||||
params.parachain_id.into(),
|
params.parachain_id.into(),
|
||||||
)?)?;
|
)?)?;
|
||||||
let header_hex = format!("0x{:?}", HexDisplay::from(&block.header().encode()));
|
let raw_header = block.header().encode();
|
||||||
|
let output_buf = if params.raw {
|
||||||
|
raw_header
|
||||||
|
} else {
|
||||||
|
format!("0x{:?}", HexDisplay::from(&block.header().encode())).into_bytes()
|
||||||
|
};
|
||||||
|
|
||||||
if let Some(output) = ¶ms.output {
|
if let Some(output) = ¶ms.output {
|
||||||
std::fs::write(output, header_hex)?;
|
std::fs::write(output, output_buf)?;
|
||||||
} else {
|
} else {
|
||||||
print!("{}", header_hex);
|
std::io::stdout().write_all(&output_buf)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -236,13 +241,18 @@ pub fn run() -> Result<()> {
|
|||||||
Some(Subcommand::ExportGenesisWasm(params)) => {
|
Some(Subcommand::ExportGenesisWasm(params)) => {
|
||||||
sc_cli::init_logger("", sc_tracing::TracingReceiver::Log, None)?;
|
sc_cli::init_logger("", sc_tracing::TracingReceiver::Log, None)?;
|
||||||
|
|
||||||
let wasm_file =
|
let raw_wasm_blob =
|
||||||
extract_genesis_wasm(&cli.load_spec(¶ms.chain.clone().unwrap_or_default())?)?;
|
extract_genesis_wasm(&cli.load_spec(¶ms.chain.clone().unwrap_or_default())?)?;
|
||||||
|
let output_buf = if params.raw {
|
||||||
|
raw_wasm_blob
|
||||||
|
} else {
|
||||||
|
format!("0x{:?}", HexDisplay::from(&raw_wasm_blob)).into_bytes()
|
||||||
|
};
|
||||||
|
|
||||||
if let Some(output) = ¶ms.output {
|
if let Some(output) = ¶ms.output {
|
||||||
std::fs::write(output, wasm_file)?;
|
std::fs::write(output, output_buf)?;
|
||||||
} else {
|
} else {
|
||||||
std::io::stdout().write_all(&wasm_file)?;
|
std::io::stdout().write_all(&output_buf)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user