From f53570e29176a0953af3d5d11b5451bb93248926 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sat, 20 Apr 2024 23:45:21 +0400 Subject: [PATCH 1/2] fix: do not require --sender with --unlocked --- crates/script/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index dc4e05e1a0bf..928a44fab1aa 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -120,7 +120,6 @@ pub struct ScriptArgs { /// Send via `eth_sendTransaction` using the `--from` argument or `$ETH_FROM` as sender #[arg( long, - requires = "sender", conflicts_with_all = &["private_key", "private_keys", "froms", "ledger", "trezor", "aws"], )] pub unlocked: bool, From 84d93795dc54b445eff7b10dfba3d20f53ca75ec Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sun, 21 Apr 2024 01:40:21 +0400 Subject: [PATCH 2/2] test --- crates/forge/tests/cli/script.rs | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 21b5837bb1bc..70b97b58fe10 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -1288,3 +1288,36 @@ contract SimpleScript is Script { let output = cmd.stdout_lossy(); assert!(output.contains("ONCHAIN EXECUTION COMPLETE & SUCCESSFUL")); }); + +// https://github.com/foundry-rs/foundry/pull/7742 +forgetest_async!(unlocked_no_sender, |prj, cmd| { + foundry_test_utils::util::initialize(prj.root()); + prj.add_script( + "Foo", + r#" +import "forge-std/Script.sol"; + +contract SimpleScript is Script { + function run() external { + vm.startBroadcast(0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266); + address(0).call(""); + } +} + "#, + ) + .unwrap(); + + let (_api, handle) = spawn(NodeConfig::test()).await; + + cmd.args([ + "script", + "SimpleScript", + "--fork-url", + &handle.http_endpoint(), + "--broadcast", + "--unlocked", + ]); + + let output = cmd.stdout_lossy(); + assert!(output.contains("ONCHAIN EXECUTION COMPLETE & SUCCESSFUL")); +});