diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index 1b1645698f3d..c51fc91f7123 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -8,7 +8,7 @@ use foundry_cli::{ opts::{EthereumOpts, TransactionOpts}, utils::{self, handle_traces, parse_ether_value, TraceResult}, }; -use foundry_common::ens::NameOrAddress; +use foundry_common::{ens::NameOrAddress, shell}; use foundry_compilers::artifacts::EvmVersion; use foundry_config::{ figment::{ @@ -50,10 +50,6 @@ pub struct CallArgs { #[arg(long, requires = "trace")] debug: bool, - /// Prints the state changes - #[arg(long)] - with_state_changes: bool, - #[arg(long, requires = "trace")] decode_internal: bool, @@ -132,7 +128,6 @@ impl CallArgs { trace, evm_version, debug, - with_state_changes, decode_internal, labels, data, @@ -193,7 +188,7 @@ impl CallArgs { evm_version, debug, decode_internal, - false, + shell::verbosity() > 1, alphanet, ); @@ -220,7 +215,6 @@ impl CallArgs { with_local_artifacts, debug, decode_internal, - with_state_changes, ) .await?; diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index 51b7a8d0c1c6..804bfa67f03f 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -50,10 +50,6 @@ pub struct RunArgs { #[arg(long)] quick: bool, - /// Prints the state changes - #[arg(long)] - with_state_changes: bool, - /// Label addresses in the trace. /// /// Example: 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045:vitalik.eth @@ -173,7 +169,7 @@ impl RunArgs { evm_version, self.debug, self.decode_internal, - self.with_state_changes, + shell::verbosity() > 1, alphanet, ); let mut env = @@ -265,7 +261,6 @@ impl RunArgs { self.with_local_artifacts, self.debug, self.decode_internal, - self.with_state_changes, ) .await?; diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 92f23a457435..ba4a8619de68 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -1713,3 +1713,60 @@ Transaction successfully executed. "#]]); }); + +// tests cast can decode traces when using project artifacts +forgetest_async!(show_state_changes_in_traces, |prj, cmd| { + let (api, handle) = anvil::spawn(NodeConfig::test()).await; + + foundry_test_utils::util::initialize(prj.root()); + // Deploy counter contract. + cmd.args([ + "script", + "--private-key", + "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", + "--rpc-url", + &handle.http_endpoint(), + "--broadcast", + "CounterScript", + ]) + .assert_success(); + + // Send tx to change counter storage value. + cmd.cast_fuse() + .args([ + "send", + "0x5FbDB2315678afecb367f032d93F642f64180aa3", + "setNumber(uint256)", + "111", + "--private-key", + "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", + "--rpc-url", + &handle.http_endpoint(), + ]) + .assert_success(); + + let tx_hash = api + .transaction_by_block_number_and_index(BlockNumberOrTag::Latest, Index::from(0)) + .await + .unwrap() + .unwrap() + .tx_hash(); + + // Assert cast with verbosity displays storage changes. + cmd.cast_fuse() + .args(["run", format!("{tx_hash}").as_str(), "-vv", "--rpc-url", &handle.http_endpoint()]) + .assert_success() + .stdout_eq(str![[r#" +Executing previous transactions from the block. +Traces: + [22287] 0x5FbDB2315678afecb367f032d93F642f64180aa3::setNumber(111) + ├─ storage changes: + │ @ 0: 0 → 111 + └─ ← [Stop] + + +Transaction successfully executed. +[GAS] + +"#]]); +}); diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 2f6810cfdbff..7eb58e49503e 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -377,7 +377,6 @@ impl TryFrom> for TraceResult { } /// labels the traces, conditionally prints them or opens the debugger -#[allow(clippy::too_many_arguments)] pub async fn handle_traces( mut result: TraceResult, config: &Config, @@ -386,7 +385,6 @@ pub async fn handle_traces( with_local_artifacts: bool, debug: bool, decode_internal: bool, - with_state_changes: bool, ) -> Result<()> { let (known_contracts, mut sources) = if with_local_artifacts { let _ = sh_println!("Compiling project to generate artifacts"); @@ -451,7 +449,7 @@ pub async fn handle_traces( decoder.debug_identifier = Some(DebugTraceIdentifier::new(sources)); } - print_traces(&mut result, &decoder, shell::verbosity() > 0, with_state_changes).await?; + print_traces(&mut result, &decoder, shell::verbosity() > 0, shell::verbosity() > 1).await?; Ok(()) }