use sc_transaction_pool_api::error::{Error as PError, IntoPoolError};
use sp_runtime::transaction_validity::InvalidTransaction;
use fp_evm::TransactionValidationError as VError;
pub struct Geth;
impl Geth {
pub fn pool_error(err: impl IntoPoolError) -> String {
match err.into_pool_error() {
Ok(PError::AlreadyImported(_)) => "already known".to_string(),
Ok(PError::TemporarilyBanned) => "already known".into(),
Ok(PError::TooLowPriority { .. }) => "replacement transaction underpriced".into(),
Ok(PError::InvalidTransaction(inner)) => match inner {
InvalidTransaction::Stale => "nonce too low".into(),
InvalidTransaction::Payment => "insufficient funds for gas * price + value".into(),
InvalidTransaction::ExhaustsResources => "exceeds block gas limit".into(),
InvalidTransaction::Custom(inner) => match inner.into() {
VError::UnknownError => "unknown error".into(),
VError::InvalidChainId => "invalid chain id".into(),
VError::InvalidSignature => "invalid sender".into(),
VError::GasLimitTooLow => "intrinsic gas too low".into(),
VError::GasLimitTooHigh => "exceeds block gas limit".into(),
VError::GasPriceTooLow => "gas price less than block base fee".into(),
VError::PriorityFeeTooHigh => {
"max priority fee per gas higher than max fee per gas".into()
}
VError::InvalidFeeInput => "invalid fee input".into(),
_ => "transaction validation error".into(),
},
_ => "unknown error".into(),
},
err => format!("submit transaction to pool failed: {:?}", err),
}
}
}