Skip to content

Commit

Permalink
use Ext trait pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
nbaztec committed Dec 19, 2024
1 parent e5ccd9e commit 5e5536a
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 12 deletions.
4 changes: 2 additions & 2 deletions crates/cheatcodes/src/evm/fork.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
json::json_value_to_token, Cheatcode, Cheatcodes, CheatcodesExecutor, CheatsCtxt, DatabaseExt,
Result, Vm::*,
json::json_value_to_token, strategy::CheatcodeInspectorStrategyExt, Cheatcode, Cheatcodes,
CheatcodesExecutor, CheatsCtxt, DatabaseExt, Result, Vm::*,
};
use alloy_dyn_abi::DynSolValue;
use alloy_primitives::{B256, U256};
Expand Down
2 changes: 1 addition & 1 deletion crates/cheatcodes/src/inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
DealRecord, GasRecord,
},
script::{Broadcast, Wallets},
strategy::CheatcodeInspectorStrategy,
strategy::{CheatcodeInspectorStrategy, CheatcodeInspectorStrategyExt},
test::{
assume::AssumeNoRevert,
expect::{self, ExpectedEmit, ExpectedRevert, ExpectedRevertKind},
Expand Down
4 changes: 2 additions & 2 deletions crates/cheatcodes/src/strategy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::{
CheatsConfig, CheatsCtxt, Result,
};

pub trait CheatcodeInspectorStrategy: Debug + Send + Sync + CheatcodeInspectorStrategyExt {
pub trait CheatcodeInspectorStrategy: Debug + Send + Sync {
fn name(&self) -> &'static str;

fn new_cloned(&self) -> Box<dyn CheatcodeInspectorStrategy>;
Expand Down Expand Up @@ -326,7 +326,7 @@ impl CheatcodeInspectorStrategy for EvmCheatcodeInspectorStrategy {
}
}

impl CheatcodeInspectorStrategyExt for EvmCheatcodeInspectorStrategy {}
impl<'a> CheatcodeInspectorStrategyExt for dyn CheatcodeInspectorStrategy + 'a {}

impl Clone for Box<dyn CheatcodeInspectorStrategy> {
fn clone(&self) -> Self {
Expand Down
4 changes: 3 additions & 1 deletion crates/cheatcodes/src/test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//! Implementations of [`Testing`](spec::Group::Testing) cheatcodes.
use crate::{Cheatcode, Cheatcodes, CheatsCtxt, Result, Vm::*};
use crate::{
strategy::CheatcodeInspectorStrategyExt, Cheatcode, Cheatcodes, CheatsCtxt, Result, Vm::*,
};
use alloy_primitives::Address;
use alloy_sol_types::SolValue;
use chrono::DateTime;
Expand Down
4 changes: 2 additions & 2 deletions crates/evm/core/src/backend/strategy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub struct BackendStrategyForkInfo<'a> {
pub target_type: ForkType,
}

pub trait BackendStrategy: Debug + Send + Sync + BackendStrategyExt {
pub trait BackendStrategy: Debug + Send + Sync {
fn name(&self) -> &'static str;

fn new_cloned(&self) -> Box<dyn BackendStrategy>;
Expand Down Expand Up @@ -96,7 +96,7 @@ impl BackendStrategy for EvmBackendStrategy {
}
}

impl BackendStrategyExt for EvmBackendStrategy {}
impl<'a> BackendStrategyExt for dyn BackendStrategy + 'a {}

impl EvmBackendStrategy {
/// Merges the state of all `accounts` from the currently active db into the given `fork`
Expand Down
4 changes: 2 additions & 2 deletions crates/evm/evm/src/executors/strategy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use revm::{

use super::Executor;

pub trait ExecutorStrategy: Debug + Send + Sync + ExecutorStrategyExt {
pub trait ExecutorStrategy: Debug + Send + Sync {
fn name(&self) -> &'static str;

fn new_cloned(&self) -> Box<dyn ExecutorStrategy>;
Expand Down Expand Up @@ -163,4 +163,4 @@ impl ExecutorStrategy for EvmExecutorStrategy {
}
}

impl ExecutorStrategyExt for EvmExecutorStrategy {}
impl<'a> ExecutorStrategyExt for dyn ExecutorStrategy + 'a {}
1 change: 1 addition & 0 deletions crates/forge/bin/cmd/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use clap::{Parser, ValueHint};
use eyre::{Context, OptionExt, Result};
use forge::{
decode::decode_console_logs,
executors::strategy::ExecutorStrategyExt,
gas_report::GasReport,
multi_runner::matches_contract,
result::{SuiteResult, TestOutcome, TestStatus},
Expand Down
2 changes: 1 addition & 1 deletion crates/script/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use foundry_config::{
use foundry_evm::{
backend::Backend,
constants::DEFAULT_CREATE2_DEPLOYER,
executors::ExecutorBuilder,
executors::{strategy::ExecutorStrategyExt, ExecutorBuilder},
inspectors::{
cheatcodes::{BroadcastableTransactions, Wallets},
CheatsConfig,
Expand Down
2 changes: 1 addition & 1 deletion crates/strategy/zksync/src/cheatcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use foundry_cheatcodes::{
use foundry_common::TransactionMaybeSigned;
use foundry_config::fs_permissions::FsAccessKind;
use foundry_evm::{
backend::{DatabaseError, LocalForkId},
backend::{strategy::BackendStrategyExt, DatabaseError, LocalForkId},
constants::{DEFAULT_CREATE2_DEPLOYER, DEFAULT_CREATE2_DEPLOYER_CODE},
};
use foundry_evm_core::{
Expand Down

0 comments on commit 5e5536a

Please sign in to comment.