use bigint::{Address, U256};
#[derive(Debug, Clone)]
pub enum PreExecutionError {
InvalidCaller,
InvalidNonce,
InsufficientBalance,
InsufficientGasLimit,
}
#[derive(Debug, Clone)]
pub enum OnChainError {
StackOverflow,
StackUnderflow,
InvalidOpcode,
BadJumpDest,
PCOverflow,
EmptyGas,
InvalidRange,
NotStatic,
Revert,
}
impl From<OnChainError> for RuntimeError {
fn from(val: OnChainError) -> RuntimeError {
RuntimeError::OnChain(val)
}
}
impl From<OnChainError> for EvalOnChainError {
fn from(val: OnChainError) -> EvalOnChainError {
EvalOnChainError::OnChain(val)
}
}
impl From<OnChainError> for EvalError {
fn from(val: OnChainError) -> EvalError {
EvalError::OnChain(val)
}
}
#[derive(Debug, Clone)]
pub enum NotSupportedError {
MemoryIndexNotSupported,
PrecompiledNotSupported,
}
impl From<NotSupportedError> for RuntimeError {
fn from(val: NotSupportedError) -> RuntimeError {
RuntimeError::NotSupported(val)
}
}
impl From<NotSupportedError> for EvalError {
fn from(val: NotSupportedError) -> EvalError {
EvalError::NotSupported(val)
}
}
#[derive(Debug, Clone)]
pub enum RuntimeError {
OnChain(OnChainError),
NotSupported(NotSupportedError),
}
impl From<RuntimeError> for EvalError {
fn from(val: RuntimeError) -> EvalError {
match val {
RuntimeError::OnChain(err) =>
EvalError::OnChain(err),
RuntimeError::NotSupported(err) =>
EvalError::NotSupported(err),
}
}
}
#[derive(Debug, Clone)]
pub enum EvalOnChainError {
OnChain(OnChainError),
Require(RequireError),
}
impl From<EvalOnChainError> for EvalError {
fn from(val: EvalOnChainError) -> EvalError {
match val {
EvalOnChainError::OnChain(err) =>
EvalError::OnChain(err),
EvalOnChainError::Require(err) =>
EvalError::Require(err),
}
}
}
#[derive(Debug, Clone)]
pub enum EvalError {
OnChain(OnChainError),
NotSupported(NotSupportedError),
Require(RequireError),
}
#[derive(Debug, Clone)]
pub enum RequireError {
Account(Address),
AccountCode(Address),
AccountStorage(Address, U256),
Blockhash(U256),
}
impl From<RequireError> for EvalError {
fn from(val: RequireError) -> EvalError {
EvalError::Require(val)
}
}
impl From<RequireError> for EvalOnChainError {
fn from(val: RequireError) -> EvalOnChainError {
EvalOnChainError::Require(val)
}
}
#[derive(Debug, Clone)]
pub enum CommitError {
InvalidCommitment,
AlreadyCommitted,
}