use alloc::vec::Vec;
use evm_interpreter::{Capture, ExitError, ExitResult, Interpreter};
pub enum InvokerControl<I, S> {
Enter(I),
DirectExit(InvokerExit<S>),
}
pub struct InvokerExit<S> {
pub result: ExitResult,
pub substate: Option<S>,
pub retval: Vec<u8>,
}
pub trait Invoker<H> {
type State;
type Interpreter: Interpreter<H, State = Self::State>;
type Interrupt;
type TransactArgs;
type TransactInvoke;
type TransactValue;
type SubstackInvoke;
#[allow(clippy::type_complexity)]
fn new_transact(
&self,
args: Self::TransactArgs,
handler: &mut H,
) -> Result<
(
Self::TransactInvoke,
InvokerControl<Self::Interpreter, Self::State>,
),
ExitError,
>;
fn finalize_transact(
&self,
invoke: &Self::TransactInvoke,
exit: InvokerExit<Self::State>,
handler: &mut H,
) -> Result<Self::TransactValue, ExitError>;
#[allow(clippy::type_complexity)]
fn enter_substack(
&self,
trap: <Self::Interpreter as Interpreter<H>>::Trap,
machine: &mut Self::Interpreter,
handler: &mut H,
depth: usize,
) -> Capture<
Result<
(
Self::SubstackInvoke,
InvokerControl<Self::Interpreter, Self::State>,
),
ExitError,
>,
Self::Interrupt,
>;
fn exit_substack(
&self,
trap_data: Self::SubstackInvoke,
exit: InvokerExit<Self::State>,
parent: &mut Self::Interpreter,
handler: &mut H,
) -> Result<(), ExitError>;
}