Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: vm.broadcastRawTransaction #9378

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions crates/common/src/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ impl TransactionMaybeSigned {
Ok(Self::Signed { tx, from })
}

pub fn is_unsigned(&self) -> bool {
matches!(self, Self::Unsigned(_))
}

pub fn as_unsigned_mut(&mut self) -> Option<&mut WithOtherFields<TransactionRequest>> {
match self {
Self::Unsigned(tx) => Some(tx),
Expand Down
13 changes: 9 additions & 4 deletions crates/forge/tests/cli/script.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Contains various tests related to `forge script`.
use crate::constants::TEMPLATE_CONTRACT;
use alloy_primitives::{hex, Address, Bytes};
use alloy_primitives::{address, hex, Address, Bytes};
use anvil::{spawn, NodeConfig};
use forge_script_sequence::ScriptSequence;
use foundry_test_utils::{
Expand Down Expand Up @@ -2039,8 +2039,7 @@ forgetest_async!(can_deploy_library_create2_different_sender, |prj, cmd| {

// <https://github.com/foundry-rs/foundry/issues/8993>
forgetest_async!(test_broadcast_raw_create2_deployer, |prj, cmd| {
let (_api, handle) =
spawn(NodeConfig::test().with_disable_default_create2_deployer(true)).await;
let (api, handle) = spawn(NodeConfig::test().with_disable_default_create2_deployer(true)).await;

foundry_test_utils::util::initialize(prj.root());
prj.add_script(
Expand All @@ -2051,7 +2050,7 @@ import "forge-std/Script.sol";
contract SimpleScript is Script {
function run() external {
// send funds to create2 factory deployer
vm.broadcast();
vm.startBroadcast();
payable(0x3fAB184622Dc19b6109349B94811493BF2a45362).transfer(10000000 gwei);
// deploy create2 factory
vm.broadcastRawTransaction(
Expand Down Expand Up @@ -2104,6 +2103,12 @@ ONCHAIN EXECUTION COMPLETE & SUCCESSFUL.
"#]]);

assert!(!api
.get_code(address!("4e59b44847b379578588920cA78FbF26c0B4956C"), Default::default())
.await
.unwrap()
.is_empty());
});

forgetest_init!(can_get_script_wallets, |prj, cmd| {
Expand Down
7 changes: 6 additions & 1 deletion crates/script/src/broadcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,12 @@ impl BundledState {
.sequence
.sequences()
.iter()
.flat_map(|sequence| sequence.transactions().map(|tx| tx.from().expect("missing from")))
.flat_map(|sequence| {
sequence
.transactions()
.filter(|tx| tx.is_unsigned())
.map(|tx| tx.from().expect("missing from"))
})
.collect::<AddressHashSet>();

if required_addresses.contains(&Config::DEFAULT_SENDER) {
Expand Down
Loading