use crate::GotExpectedBoxed;
use alloy_primitives::U256;
#[derive(Debug, Clone, Eq, PartialEq, thiserror::Error)]
pub enum InvalidTransactionError {
#[error(
"sender does not have enough funds ({}) to cover transaction fees: {}", _0.got, _0.expected
)]
InsufficientFunds(GotExpectedBoxed<U256>),
#[error("transaction nonce is not consistent: next nonce {state}, tx nonce {tx}")]
NonceNotConsistent {
tx: u64,
state: u64,
},
#[error("transactions before Spurious Dragon should not have a chain ID")]
OldLegacyChainId,
#[error("transaction's chain ID does not match")]
ChainIdMismatch,
#[error("EIP-2930 transactions are disabled")]
Eip2930Disabled,
#[error("EIP-1559 transactions are disabled")]
Eip1559Disabled,
#[error("EIP-4844 transactions are disabled")]
Eip4844Disabled,
#[error("EIP-7702 transactions are disabled")]
Eip7702Disabled,
#[error("transaction type not supported")]
TxTypeNotSupported,
#[error("gas overflow (maximum of u64)")]
GasUintOverflow,
#[error("intrinsic gas too low")]
GasTooLow,
#[error("intrinsic gas too high")]
GasTooHigh,
#[error("max priority fee per gas higher than max fee per gas")]
TipAboveFeeCap,
#[error("max fee per gas less than block base fee")]
FeeCapTooLow,
#[error("transaction signer has bytecode set")]
SignerAccountHasBytecode,
#[error("gas limit too high")]
GasLimitTooHigh,
}
impl InvalidTransactionError {
pub fn is_nonce_too_low(&self) -> bool {
match self {
Self::NonceNotConsistent { tx, state } => tx < state,
_ => false,
}
}
}
#[derive(Debug, Clone, Eq, PartialEq, derive_more::Display, derive_more::Error)]
pub enum TransactionConversionError {
#[display("Transaction is not supported for p2p")]
UnsupportedForP2P,
}
#[derive(Debug, Clone, Eq, PartialEq, thiserror::Error)]
pub enum TryFromRecoveredTransactionError {
#[error("Unsupported transaction type: {_0}")]
UnsupportedTransactionType(u8),
#[error("Blob sidecar missing for an EIP-4844 transaction")]
BlobSidecarMissing,
}