chore: add InvalidChainId error variant (#1657)

This commit is contained in:
Matthias Seitz
2023-03-07 11:33:05 +01:00
committed by GitHub
parent 32e31b240d
commit ce39c9810d
2 changed files with 10 additions and 7 deletions

8
Cargo.lock generated
View File

@@ -5160,7 +5160,7 @@ dependencies = [
[[package]]
name = "revm"
version = "3.0.0"
source = "git+https://github.com/bluealloy/revm#3a17ca8556ee2933100d1e1ed4e200712715f76f"
source = "git+https://github.com/bluealloy/revm#7bb73da23d0278829f9669f175a6eede247c0538"
dependencies = [
"auto_impl",
"revm-interpreter",
@@ -5170,7 +5170,7 @@ dependencies = [
[[package]]
name = "revm-interpreter"
version = "1.0.0"
source = "git+https://github.com/bluealloy/revm#3a17ca8556ee2933100d1e1ed4e200712715f76f"
source = "git+https://github.com/bluealloy/revm#7bb73da23d0278829f9669f175a6eede247c0538"
dependencies = [
"bitvec 1.0.1",
"derive_more",
@@ -5182,7 +5182,7 @@ dependencies = [
[[package]]
name = "revm-precompile"
version = "2.0.0"
source = "git+https://github.com/bluealloy/revm#3a17ca8556ee2933100d1e1ed4e200712715f76f"
source = "git+https://github.com/bluealloy/revm#7bb73da23d0278829f9669f175a6eede247c0538"
dependencies = [
"k256",
"num",
@@ -5198,7 +5198,7 @@ dependencies = [
[[package]]
name = "revm-primitives"
version = "1.0.0"
source = "git+https://github.com/bluealloy/revm#3a17ca8556ee2933100d1e1ed4e200712715f76f"
source = "git+https://github.com/bluealloy/revm#7bb73da23d0278829f9669f175a6eede247c0538"
dependencies = [
"arbitrary",
"auto_impl",

View File

@@ -179,15 +179,17 @@ pub enum InvalidTransactionError {
/// Unspecific evm halt error
#[error("EVM error {0:?}")]
EvmHalt(Halt),
#[error("Invalid chain id")]
InvalidChainId,
}
impl InvalidTransactionError {
/// Returns the rpc error code for this error.
fn error_code(&self) -> i32 {
match self {
InvalidTransactionError::GasTooLow | InvalidTransactionError::GasTooHigh => {
EthRpcErrorCode::InvalidInput.code()
}
InvalidTransactionError::InvalidChainId |
InvalidTransactionError::GasTooLow |
InvalidTransactionError::GasTooHigh => EthRpcErrorCode::InvalidInput.code(),
InvalidTransactionError::Revert(_) => EthRpcErrorCode::ExecutionError.code(),
_ => EthRpcErrorCode::TransactionRejected.code(),
}
@@ -214,6 +216,7 @@ impl From<revm::primitives::InvalidTransaction> for InvalidTransactionError {
fn from(err: revm::primitives::InvalidTransaction) -> Self {
use revm::primitives::InvalidTransaction;
match err {
InvalidTransaction::InvalidChainId => InvalidTransactionError::InvalidChainId,
InvalidTransaction::GasMaxFeeGreaterThanPriorityFee => {
InvalidTransactionError::TipAboveFeeCap
}