use alloy_primitives::{hex::FromHexError, BlockNumber, TxHash, B256};
use alloy_provider::transport::TransportError;
use mega_evm::{alloy_evm::block::BlockExecutionError, revm::bytecode::BytecodeDecodeError};
#[derive(Debug, thiserror::Error)]
pub enum EvmeError {
#[error("RPC transport error: {0}")]
RpcTransportError(TransportError),
#[error("Transaction not found: {0}")]
TransactionNotFound(TxHash),
#[error("Block not found: {0}")]
BlockNotFound(BlockNumber),
#[error("Block execution error: {0}")]
BlockExecutionError(#[from] BlockExecutionError),
#[error("Invalid bytecode: {0}")]
InvalidBytecode(#[from] BytecodeDecodeError),
#[error("Failed to read file: {0}")]
FileRead(#[from] std::io::Error),
#[error("Invalid hex string: {0}")]
InvalidHex(#[from] FromHexError),
#[error("EVM execution error: {0}")]
ExecutionError(String),
#[error("Invalid input: {0}")]
InvalidInput(String),
#[error("RPC error: {0}")]
RpcError(String),
#[error("Unsupported transaction type: {0}")]
UnsupportedTxType(u8),
#[error("Code hash mismatch: expected {expected}, computed {computed}")]
CodeHashMismatch {
expected: B256,
computed: B256,
},
#[error("Other error: {0}")]
Other(String),
}
impl mega_evm::revm::database::DBErrorMarker for EvmeError {}
pub type Result<T> = std::result::Result<T, EvmeError>;