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 2c5050f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cmd/soroban-cli/src/fee.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use clap::arg;
use soroban_env_host::xdr;
use soroban_rpc::Assembled;
use soroban_sdk::xdr::WriteXdr;

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 2c5050f

Please sign in to comment.