Skip to content

Commit b51a3f2

Browse files
authored
chore(evm): use method instead of get_create_address util (#6738)
1 parent 0792dc7 commit b51a3f2

File tree

3 files changed

+3
-14
lines changed

3 files changed

+3
-14
lines changed

crates/cheatcodes/src/inspector.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ use foundry_common::{evm::Breakpoints, provider::alloy::RpcUrl, types::ToEthers}
2323
use foundry_evm_core::{
2424
backend::{DatabaseError, DatabaseExt, RevertDiagnostic},
2525
constants::{CHEATCODE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, HARDHAT_CONSOLE_ADDRESS, MAGIC_SKIP},
26-
utils::get_create_address,
2726
};
2827
use itertools::Itertools;
2928
use revm::{
@@ -258,7 +257,7 @@ impl Cheatcodes {
258257
.get(&inputs.caller)
259258
.map(|acc| acc.info.nonce)
260259
.unwrap_or_default();
261-
let created_address = get_create_address(inputs, old_nonce);
260+
let created_address = inputs.created_address(old_nonce);
262261

263262
if data.journaled_state.depth > 1 && !data.db.has_cheatcode_access(inputs.caller) {
264263
// we only grant cheat code access for new contracts if the caller also has

crates/evm/core/src/utils.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -268,16 +268,6 @@ pub fn configure_tx_env(env: &mut revm::primitives::Env, tx: &Transaction) {
268268
env.tx.transact_to = tx.to.map(TransactTo::Call).unwrap_or_else(TransactTo::create)
269269
}
270270

271-
/// Get the address of a contract creation
272-
pub fn get_create_address(call: &CreateInputs, nonce: u64) -> Address {
273-
match call.scheme {
274-
CreateScheme::Create => call.caller.create(nonce),
275-
CreateScheme::Create2 { salt } => {
276-
call.caller.create2_from_code(B256::from(salt), &call.init_code)
277-
}
278-
}
279-
}
280-
281271
/// Get the gas used, accounting for refunds
282272
pub fn gas_used(spec: SpecId, spent: u64, refunded: u64) -> u64 {
283273
let refund_quotient = if SpecId::enabled(spec, SpecId::LONDON) { 5 } else { 2 };

crates/evm/evm/src/inspectors/debugger.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use foundry_evm_core::{
44
backend::DatabaseExt,
55
constants::CHEATCODE_ADDRESS,
66
debug::{DebugArena, DebugNode, DebugStep, Instruction},
7-
utils::{gas_used, get_create_address, CallKind},
7+
utils::{gas_used, CallKind},
88
};
99
use revm::{
1010
interpreter::{
@@ -133,7 +133,7 @@ impl<DB: DatabaseExt> Inspector<DB> for Debugger {
133133
let nonce = data.journaled_state.account(call.caller).info.nonce;
134134
self.enter(
135135
data.journaled_state.depth() as usize,
136-
get_create_address(call, nonce),
136+
call.created_address(nonce),
137137
CallKind::Create,
138138
);
139139

0 commit comments

Comments
 (0)