1use alloc::vec::Vec;
2use evm_interpreter::{Capture, ExitError, ExitResult, Interpreter};
3
4pub enum InvokerControl<I, S> {
6 Enter(I),
8 DirectExit(InvokerExit<S>),
10}
11
12pub struct InvokerExit<S> {
14 pub result: ExitResult,
16 pub substate: Option<S>,
18 pub retval: Vec<u8>,
20}
21
22pub trait Invoker<H> {
24 type State;
26 type Interpreter: Interpreter<H, State = Self::State>;
28 type Interrupt;
30
31 type TransactArgs;
33 type TransactInvoke;
36 type TransactValue;
38 type SubstackInvoke;
41
42 #[allow(clippy::type_complexity)]
44 fn new_transact(
45 &self,
46 args: Self::TransactArgs,
47 handler: &mut H,
48 ) -> Result<
49 (
50 Self::TransactInvoke,
51 InvokerControl<Self::Interpreter, Self::State>,
52 ),
53 ExitError,
54 >;
55
56 fn finalize_transact(
58 &self,
59 invoke: &Self::TransactInvoke,
60 exit: InvokerExit<Self::State>,
61 handler: &mut H,
62 ) -> Result<Self::TransactValue, ExitError>;
63
64 #[allow(clippy::type_complexity)]
66 fn enter_substack(
67 &self,
68 trap: <Self::Interpreter as Interpreter<H>>::Trap,
69 machine: &mut Self::Interpreter,
70 handler: &mut H,
71 depth: usize,
72 ) -> Capture<
73 Result<
74 (
75 Self::SubstackInvoke,
76 InvokerControl<Self::Interpreter, Self::State>,
77 ),
78 ExitError,
79 >,
80 Self::Interrupt,
81 >;
82
83 fn exit_substack(
85 &self,
86 trap_data: Self::SubstackInvoke,
87 exit: InvokerExit<Self::State>,
88 parent: &mut Self::Interpreter,
89 handler: &mut H,
90 ) -> Result<(), ExitError>;
91}