mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 22:37:57 +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")]
|
||||
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.
|
||||
#[structopt(long)]
|
||||
pub chain: Option<String>,
|
||||
@@ -75,6 +79,10 @@ pub struct ExportGenesisWasmCommand {
|
||||
#[structopt(parse(from_os_str))]
|
||||
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.
|
||||
#[structopt(long)]
|
||||
pub chain: Option<String>,
|
||||
|
||||
@@ -223,12 +223,17 @@ pub fn run() -> Result<()> {
|
||||
¶ms.chain.clone().unwrap_or_default(),
|
||||
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 {
|
||||
std::fs::write(output, header_hex)?;
|
||||
std::fs::write(output, output_buf)?;
|
||||
} else {
|
||||
print!("{}", header_hex);
|
||||
std::io::stdout().write_all(&output_buf)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -236,13 +241,18 @@ pub fn run() -> Result<()> {
|
||||
Some(Subcommand::ExportGenesisWasm(params)) => {
|
||||
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())?)?;
|
||||
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 {
|
||||
std::fs::write(output, wasm_file)?;
|
||||
std::fs::write(output, output_buf)?;
|
||||
} else {
|
||||
std::io::stdout().write_all(&wasm_file)?;
|
||||
std::io::stdout().write_all(&output_buf)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user