Skip to content

Commit

Permalink
feat: add no-build option for fee::Args
Browse files Browse the repository at this point in the history
  • Loading branch information
willemneal authored and gitbutler-client committed Mar 20, 2024
1 parent 5f367ed commit dc2e10d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion cmd/soroban-cli/src/fee.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use clap::arg;
use soroban_env_host::xdr;

use soroban_env_host::xdr::{self, WriteXdr};
use soroban_rpc::Assembled;

use crate::commands::HEADING_RPC;
Expand All @@ -16,9 +17,20 @@ pub struct Args {
/// Number of instructions to simulate
#[arg(long, help_heading = HEADING_RPC)]
pub instructions: Option<u32>,
/// Build the transaction only write the output to stdout
#[arg(long, help_heading = HEADING_RPC)]
build_only: bool,
}

impl Args {
pub fn build_only(&self, txn: &xdr::Transaction) -> Result<(), xdr::Error> {
if self.build_only {
println!("{}", txn.to_xdr_base64(xdr::Limits::none())?);
std::process::exit(0);
}
Ok(())
}

pub fn apply_to_assembled_txn(&self, txn: Assembled) -> Assembled {
if let Some(instructions) = self.instructions {
txn.set_max_instructions(instructions)
Expand Down Expand Up @@ -47,6 +59,7 @@ impl Default for Args {
fee: 100,
cost: false,
instructions: None,
build_only: false,
}
}
}

0 comments on commit dc2e10d

Please sign in to comment.