1use crate::{Evm, EvmEnv};
2use alloy_primitives::{Address, Bytes};
3use revm::context::either;
4
5impl<L, R> Evm for either::Either<L, R>
6where
7 L: Evm,
8 R: Evm<
9 DB = L::DB,
10 Tx = L::Tx,
11 Error = L::Error,
12 HaltReason = L::HaltReason,
13 Spec = L::Spec,
14 BlockEnv = L::BlockEnv,
15 Precompiles = L::Precompiles,
16 Inspector = L::Inspector,
17 >,
18{
19 type DB = L::DB;
20 type Tx = L::Tx;
21 type Error = L::Error;
22 type HaltReason = L::HaltReason;
23 type Spec = L::Spec;
24 type BlockEnv = L::BlockEnv;
25 type Precompiles = L::Precompiles;
26 type Inspector = L::Inspector;
27
28 fn block(&self) -> &Self::BlockEnv {
29 either::for_both!(self, evm => evm.block())
30 }
31
32 fn chain_id(&self) -> u64 {
33 either::for_both!(self, evm => evm.chain_id())
34 }
35
36 fn transact_raw(
37 &mut self,
38 tx: Self::Tx,
39 ) -> Result<revm::context::result::ResultAndState<Self::HaltReason>, Self::Error> {
40 either::for_both!(self, evm => evm.transact_raw(tx))
41 }
42
43 fn transact(
44 &mut self,
45 tx: impl crate::IntoTxEnv<Self::Tx>,
46 ) -> Result<revm::context::result::ResultAndState<Self::HaltReason>, Self::Error> {
47 either::for_both!(self, evm => evm.transact(tx))
48 }
49
50 fn transact_system_call(
51 &mut self,
52 caller: Address,
53 contract: Address,
54 data: Bytes,
55 ) -> Result<revm::context::result::ResultAndState<Self::HaltReason>, Self::Error> {
56 either::for_both!(self, evm => evm.transact_system_call(caller, contract, data))
57 }
58
59 fn transact_commit(
60 &mut self,
61 tx: impl crate::IntoTxEnv<Self::Tx>,
62 ) -> Result<revm::context::result::ExecutionResult<Self::HaltReason>, Self::Error>
63 where
64 Self::DB: revm::DatabaseCommit,
65 {
66 either::for_both!(self, evm => evm.transact_commit(tx))
67 }
68
69 fn finish(self) -> (Self::DB, EvmEnv<Self::Spec, Self::BlockEnv>)
70 where
71 Self: Sized,
72 {
73 either::for_both!(self, evm => evm.finish())
74 }
75
76 fn into_db(self) -> Self::DB
77 where
78 Self: Sized,
79 {
80 either::for_both!(self, evm => evm.into_db())
81 }
82
83 fn into_env(self) -> EvmEnv<Self::Spec, Self::BlockEnv>
84 where
85 Self: Sized,
86 {
87 either::for_both!(self, evm => evm.into_env())
88 }
89
90 fn set_inspector_enabled(&mut self, enabled: bool) {
91 either::for_both!(self, evm => evm.set_inspector_enabled(enabled))
92 }
93
94 fn enable_inspector(&mut self) {
95 either::for_both!(self, evm => evm.enable_inspector())
96 }
97
98 fn disable_inspector(&mut self) {
99 either::for_both!(self, evm => evm.disable_inspector())
100 }
101
102 fn components(&self) -> (&Self::DB, &Self::Inspector, &Self::Precompiles) {
103 either::for_both!(self, evm => evm.components())
104 }
105
106 fn components_mut(&mut self) -> (&mut Self::DB, &mut Self::Inspector, &mut Self::Precompiles) {
107 either::for_both!(self, evm => evm.components_mut())
108 }
109}