diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 2288553000b2c..98a342094df28 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -2483,8 +2483,6 @@ contract DryRunTest is Script { "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", "--rpc-url", &handle.http_endpoint(), - "--dry-run", - "--broadcast", ]) .execute() .stdout_lossy(); diff --git a/crates/script/src/broadcast.rs b/crates/script/src/broadcast.rs index 5abcc4ba9b95b..24368bc3d74c6 100644 --- a/crates/script/src/broadcast.rs +++ b/crates/script/src/broadcast.rs @@ -1,6 +1,6 @@ use crate::{ - build::LinkedBuildData, dryrun::format_transaction_details, progress::ScriptProgress, - sequence::ScriptSequenceKind, verify::BroadcastedState, ScriptArgs, ScriptConfig, + build::LinkedBuildData, progress::ScriptProgress, sequence::ScriptSequenceKind, + verify::BroadcastedState, ScriptArgs, ScriptConfig, }; use alloy_chains::Chain; use alloy_consensus::TxEnvelope; @@ -21,7 +21,7 @@ use foundry_cheatcodes::Wallets; use foundry_cli::utils::{has_batch_support, has_different_gas_calc}; use foundry_common::{ provider::{get_http_provider, try_get_http_provider, RetryProvider}, - sh_print, shell, TransactionMaybeSigned, + shell, TransactionMaybeSigned, }; use foundry_config::Config; use futures::{future::join_all, StreamExt}; @@ -207,24 +207,6 @@ impl BundledState { Ok(self) } - /// Show the transactions that will be broadcasted. - pub fn show_transactions(self) -> Result<()> { - if !shell::is_json() { - sh_println!("\n=== Transactions that will be broadcast ===\n")?; - - for sequence in self.sequence.sequences() { - if !sequence.transactions.is_empty() { - sh_println!("\nChain {}\n", sequence.chain)?; - - for (i, tx) in sequence.transactions.iter().enumerate() { - sh_print!("{}", format_transaction_details(i + 1, tx))?; - } - } - } - } - Ok(()) - } - /// Broadcasts transactions from all sequences. pub async fn broadcast(mut self) -> Result { let required_addresses = self diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index 870199cc58d82..696d97e9e5efb 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -119,10 +119,6 @@ pub struct ScriptArgs { #[arg(long)] pub broadcast: bool, - /// Only shows the transactions that would be sent without actually broadcasting them. - #[arg(long)] - pub dry_run: bool, - /// Batch size of transactions. /// /// This is ignored and set to 1 if batching is not available or `--slow` is enabled. @@ -305,10 +301,21 @@ impl ScriptArgs { pre_simulation.fill_metadata().await?.bundle().await? }; - let dry_run = bundled.args.dry_run; // Exit early in case user didn't provide any broadcast/verify related flags. - if !bundled.args.should_broadcast() && !dry_run { + if !bundled.args.should_broadcast() { if !shell::is_json() { + sh_println!("\n=== Transactions that will be broadcast ===\n")?; + + for sequence in bundled.sequence.sequences() { + if !sequence.transactions.is_empty() { + sh_println!("\nChain {}\n", sequence.chain)?; + + for (i, tx) in sequence.transactions.iter().enumerate() { + sh_print!("{}", dryrun::format_transaction_details(i + 1, tx))?; + } + } + } + sh_println!("\nSIMULATION COMPLETE. To broadcast these transactions, add --broadcast and wallet configuration(s) to the previous command. See forge script --help for more.")?; } return Ok(()); @@ -320,15 +327,8 @@ impl ScriptArgs { } // Wait for pending txes and broadcast others. - let bundle_state = bundled.wait_for_pending().await?; - - // Print all transactions if --dry-run is set - if dry_run { - bundle_state.show_transactions()?; - return Ok(()); - } + let broadcasted = bundled.wait_for_pending().await?.broadcast().await?; - let broadcasted = bundle_state.broadcast().await?; if broadcasted.args.verify { broadcasted.verify().await?; }