use crate::{driver::BundleDriver, BlockDriver, ChainDriver, Trevm};
use revm::{primitives::EVMError, Database};
use sealed::*;
pub type EvmNeedsCfg<'a, Ext, Db> = Trevm<'a, Ext, Db, NeedsCfg>;
pub type EvmNeedsBlock<'a, Ext, Db> = Trevm<'a, Ext, Db, NeedsBlock>;
pub type EvmNeedsTx<'a, Ext, Db> = Trevm<'a, Ext, Db, NeedsTx>;
pub type EvmReady<'a, Ext, Db> = Trevm<'a, Ext, Db, Ready>;
pub type EvmTransacted<'a, Ext, Db> = Trevm<'a, Ext, Db, TransactedState>;
pub type EvmErrored<'a, Ext, Db, E = EVMError<<Db as Database>::Error>> =
Trevm<'a, Ext, Db, ErroredState<E>>;
pub type EvmBlockDriverErrored<'a, Ext, Db, T> =
EvmErrored<'a, Ext, Db, <T as BlockDriver<Ext>>::Error<Db>>;
pub type EvmChainDriverErrored<'a, Ext, Db, T> =
EvmErrored<'a, Ext, Db, <T as ChainDriver<Ext>>::Error<Db>>;
pub type EvmBundleDriverErrored<'a, Ext, Db, T> =
EvmErrored<'a, Ext, Db, <T as BundleDriver<Ext>>::Error<Db>>;
#[allow(unnameable_types, dead_code, unreachable_pub)]
pub(crate) mod sealed {
use revm::primitives::ResultAndState;
macro_rules! states {
($($name:ident),+) => {
$(
#[derive(Debug, Copy, Clone)]
pub struct $name { _private: () }
impl $name {
pub(crate) const fn new() -> Self {
Self { _private: () }
}
}
)*
};
}
states!(NeedsCfg, NeedsBlock, NeedsTx, Ready);
#[derive(Debug, Clone)]
pub struct TransactedState {
pub result: ResultAndState,
}
#[derive(Debug, Copy, Clone)]
pub struct ErroredState<E> {
pub error: E,
}
pub struct Seal;
pub trait HasCfg {}
impl HasCfg for NeedsBlock {}
impl HasCfg for NeedsTx {}
impl HasCfg for TransactedState {}
impl<E> HasCfg for ErroredState<E> {}
impl HasCfg for Ready {}
pub trait HasBlock: HasCfg {}
impl HasBlock for NeedsTx {}
impl HasBlock for TransactedState {}
impl<E> HasBlock for ErroredState<E> {}
impl HasBlock for Ready {}
pub trait HasTx: HasBlock + HasCfg {}
impl HasTx for TransactedState {}
impl<E> HasTx for ErroredState<E> {}
impl HasTx for Ready {}
}
#[macro_export]
macro_rules! trevm_aliases {
($db:ty) => {
trevm_aliases!((), $db);
};
(lifetime: $ext:ty, $db:ty) => {
#[allow(unused_imports, unreachable_pub, dead_code)]
pub use __aliases::*;
#[allow(unused_imports, unreachable_pub, dead_code)]
mod __aliases {
use super::*;
use $crate::{Block, BlockDriver, ChainDriver, Trevm, Tx};
pub type EvmNeedsCfg<'a> = $crate::EvmNeedsCfg<'a, $ext, $db>;
pub type EvmNeedsBlock<'a> = $crate::EvmNeedsBlock<'a, $ext, $db>;
pub type EvmNeedsTx<'a> = $crate::EvmNeedsTx<'a, $ext, $db>;
pub type EvmReady<'a> = $crate::EvmReady<'a, $ext, $db>;
pub type EvmTransacted<'a> = $crate::EvmTransacted<'a, $ext, $db>;
pub type EvmErrored<
'a,
E = $crate::revm::primitives::EVMError<<$db as $crate::revm::Database>::Error>,
> = $crate::EvmErrored<'a, $ext, $db, E>;
pub type EvmBlockDriverErrored<'a, T> = $crate::EvmBlockDriverErrored<'a, $ext, $db, T>;
pub type EvmChainDriverErrored<'a, T> = $crate::EvmChainDriverErrored<'a, $ext, $db, T>;
pub type EvmBundleDriverErrored<'a, T> =
$crate::EvmBundleDriverErrored<'a, $ext, $db, T>;
}
};
($ext:ty, $db:ty) => {
#[allow(unused_imports, unreachable_pub, dead_code)]
pub use __aliases::*;
#[allow(unused_imports, unreachable_pub, dead_code)]
mod __aliases {
use super::*;
use $crate::{Block, BlockDriver, ChainDriver, Trevm, Tx};
pub type EvmNeedsCfg = $crate::EvmNeedsCfg<'static, $ext, $db>;
pub type EvmNeedsBlock = $crate::EvmNeedsBlock<'static, $ext, $db>;
pub type EvmNeedsTx = $crate::EvmNeedsTx<'static, $ext, $db>;
pub type EvmReady = $crate::EvmReady<'static, $ext, $db>;
pub type EvmTransacted = $crate::EvmTransacted<'static, $ext, $db>;
pub type EvmErrored<E> = $crate::EvmErrored<'static, $ext, $db, E>;
pub type EvmBlockDriverErrored<'a, T> =
$crate::EvmBlockDriverErrored<'static, $ext, $db, T>;
pub type EvmChainDriverErrored<'a, T> =
$crate::EvmChainDriverErrored<'static, $ext, $db, T>;
pub type EvmBundleDriverErrored<'a, T> =
$crate::EvmBundleDriverErrored<'static, $ext, $db, T>;
}
};
}