anvil/eth/backend/
env.rs

1use alloy_evm::EvmEnv;
2use foundry_evm::{EnvMut, core::AsEnvMut};
3use foundry_evm_networks::NetworkConfigs;
4use op_revm::OpTransaction;
5use revm::context::{BlockEnv, CfgEnv, TxEnv};
6
7/// Helper container type for [`EvmEnv`] and [`OpTransaction<TxEnd>`].
8#[derive(Clone, Debug, Default)]
9pub struct Env {
10    pub evm_env: EvmEnv,
11    pub tx: OpTransaction<TxEnv>,
12    pub networks: NetworkConfigs,
13}
14
15/// Helper container type for [`EvmEnv`] and [`OpTransaction<TxEnv>`].
16impl Env {
17    pub fn new(
18        cfg: CfgEnv,
19        block: BlockEnv,
20        tx: OpTransaction<TxEnv>,
21        networks: NetworkConfigs,
22    ) -> Self {
23        Self { evm_env: EvmEnv { cfg_env: cfg, block_env: block }, tx, networks }
24    }
25}
26
27impl AsEnvMut for Env {
28    fn as_env_mut(&mut self) -> EnvMut<'_> {
29        EnvMut {
30            block: &mut self.evm_env.block_env,
31            cfg: &mut self.evm_env.cfg_env,
32            tx: &mut self.tx.base,
33        }
34    }
35}