1use crate::{evm::OpEvm, transaction::OpTxTr, L1BlockInfo, OpSpecId};
2use revm::{
3 context::{Cfg, JournalOutput},
4 context_interface::{Block, JournalTr},
5 handler::instructions::EthInstructions,
6 interpreter::interpreter::EthInterpreter,
7 Context, Database,
8};
9
10pub trait OpBuilder: Sized {
12 type Context;
14
15 fn build_op(self) -> OpEvm<Self::Context, (), EthInstructions<EthInterpreter, Self::Context>>;
17
18 fn build_op_with_inspector<INSP>(
20 self,
21 inspector: INSP,
22 ) -> OpEvm<Self::Context, INSP, EthInstructions<EthInterpreter, Self::Context>>;
23}
24
25impl<BLOCK, TX, CFG, DB, JOURNAL> OpBuilder for Context<BLOCK, TX, CFG, DB, JOURNAL, L1BlockInfo>
26where
27 BLOCK: Block,
28 TX: OpTxTr,
29 CFG: Cfg<Spec = OpSpecId>,
30 DB: Database,
31 JOURNAL: JournalTr<Database = DB, FinalOutput = JournalOutput>,
32{
33 type Context = Self;
34
35 fn build_op(self) -> OpEvm<Self::Context, (), EthInstructions<EthInterpreter, Self::Context>> {
36 OpEvm::new(self, ())
37 }
38
39 fn build_op_with_inspector<INSP>(
40 self,
41 inspector: INSP,
42 ) -> OpEvm<Self::Context, INSP, EthInstructions<EthInterpreter, Self::Context>> {
43 OpEvm::new(self, inspector)
44 }
45}