Skip to main content

anvil/eth/error/
base.rs

1//! Base-specific error conversions.
2
3use super::{BlockchainError, InvalidTransactionError};
4use base_common_evm::BaseTransactionError;
5use revm::context_interface::result::{EVMError, InvalidHeader};
6
7impl<T> From<EVMError<T, BaseTransactionError>> for BlockchainError
8where
9    T: Into<Self>,
10{
11    fn from(error: EVMError<T, BaseTransactionError>) -> Self {
12        match error {
13            EVMError::Transaction(error) => match error {
14                BaseTransactionError::Base(error) => InvalidTransactionError::from(error).into(),
15                BaseTransactionError::DepositSystemTxPostRegolith
16                | BaseTransactionError::HaltedDepositPostRegolith => {
17                    Self::DepositTransactionUnsupported
18                }
19                BaseTransactionError::MissingEnvelopedTx => {
20                    Self::InvalidTransaction(InvalidTransactionError::MissingEnvelopedTx)
21                }
22                BaseTransactionError::Eip8130(reason) => Self::Eip8130TransactionRejected(reason),
23            },
24            EVMError::Header(error) => match error {
25                InvalidHeader::ExcessBlobGasNotSet => Self::ExcessBlobGasNotSet,
26                InvalidHeader::PrevrandaoNotSet => Self::PrevrandaoNotSet,
27            },
28            EVMError::Database(error) => error.into(),
29            EVMError::Custom(error) => Self::Message(error),
30            EVMError::CustomAny(error) => Self::Message(error.to_string()),
31        }
32    }
33}