Skip to content

Commit f824e29

Browse files
klkvrrplusq
authored andcommitted
fix: vm.broadcastRawTransaction (foundry-rs#9378)
fix: vm.broadcastRawTransaction
1 parent 0d733b2 commit f824e29

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

crates/common/src/transactions.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ impl TransactionMaybeSigned {
179179
Ok(Self::Signed { tx, from })
180180
}
181181

182+
pub fn is_unsigned(&self) -> bool {
183+
matches!(self, Self::Unsigned(_))
184+
}
185+
182186
pub fn as_unsigned_mut(&mut self) -> Option<&mut WithOtherFields<TransactionRequest>> {
183187
match self {
184188
Self::Unsigned(tx) => Some(tx),

crates/forge/tests/cli/script.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Contains various tests related to `forge script`.
22
33
use crate::constants::TEMPLATE_CONTRACT;
4-
use alloy_primitives::{hex, Address, Bytes};
4+
use alloy_primitives::{address, hex, Address, Bytes};
55
use anvil::{spawn, NodeConfig};
66
use forge_script_sequence::ScriptSequence;
77
use foundry_test_utils::{
@@ -2039,8 +2039,7 @@ forgetest_async!(can_deploy_library_create2_different_sender, |prj, cmd| {
20392039

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

20452044
foundry_test_utils::util::initialize(prj.root());
20462045
prj.add_script(
@@ -2051,7 +2050,7 @@ import "forge-std/Script.sol";
20512050
contract SimpleScript is Script {
20522051
function run() external {
20532052
// send funds to create2 factory deployer
2054-
vm.broadcast();
2053+
vm.startBroadcast();
20552054
payable(0x3fAB184622Dc19b6109349B94811493BF2a45362).transfer(10000000 gwei);
20562055
// deploy create2 factory
20572056
vm.broadcastRawTransaction(
@@ -2104,6 +2103,12 @@ ONCHAIN EXECUTION COMPLETE & SUCCESSFUL.
21042103
21052104
21062105
"#]]);
2106+
2107+
assert!(!api
2108+
.get_code(address!("4e59b44847b379578588920cA78FbF26c0B4956C"), Default::default())
2109+
.await
2110+
.unwrap()
2111+
.is_empty());
21072112
});
21082113

21092114
forgetest_init!(can_get_script_wallets, |prj, cmd| {

crates/script/src/broadcast.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,12 @@ impl BundledState {
213213
.sequence
214214
.sequences()
215215
.iter()
216-
.flat_map(|sequence| sequence.transactions().map(|tx| tx.from().expect("missing from")))
216+
.flat_map(|sequence| {
217+
sequence
218+
.transactions()
219+
.filter(|tx| tx.is_unsigned())
220+
.map(|tx| tx.from().expect("missing from"))
221+
})
217222
.collect::<AddressHashSet>();
218223

219224
if required_addresses.contains(&Config::DEFAULT_SENDER) {

0 commit comments

Comments
 (0)