Skip to content

Commit

Permalink
[rooch-networkgh-2471] resolve issues arisen in the comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
Feliciss committed Aug 21, 2024
1 parent 0a7c569 commit 39ae1ad
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions crates/rooch/src/commands/transaction/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ pub struct BuildCommand {
#[clap(flatten)]
context: WalletContextOptions,

/// Output result in command line, otherwise write to a file
#[clap(long, default_value = "false")]
output: bool,

/// File destination for the file being written
#[clap(long)]
file_destination: Option<String>,
Expand Down Expand Up @@ -88,7 +84,13 @@ impl CommandAction<Option<String>> for BuildCommand {
.build_tx_data(sender, action, max_gas_amount)
.await?;

if self.output {
if let Some(file_destination) = self.file_destination {
let mut file = File::create(file_destination)?;
file.write_all(&tx_data.encode())?;
println!("Write transaction hex succeeded in the destination");

Ok(None)
} else {
let tx_data_hex = hex::encode(tx_data.encode());
if self.json {
Ok(Some(tx_data_hex))
Expand All @@ -100,16 +102,6 @@ impl CommandAction<Option<String>> for BuildCommand {

Ok(None)
}
} else if let Some(file_destination) = self.file_destination {
let mut file = File::create(file_destination)?;
file.write_all(&tx_data.encode())?;
println!("Write encoded tx data succeeded in the destination");

Ok(None)
} else {
return Err(RoochError::CommandArgumentError(
"Argument --file-destination is not provided".to_owned(),
));
}
}
}

0 comments on commit 39ae1ad

Please sign in to comment.