mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
chore(rpc): move EthRpcErrorCode to rpc-types (#1690)
This commit is contained in:
23
crates/rpc/rpc-types/src/eth/error.rs
Normal file
23
crates/rpc/rpc-types/src/eth/error.rs
Normal file
@ -0,0 +1,23 @@
|
||||
//! Commonly used errors for the `eth_` namespace.
|
||||
|
||||
/// List of JSON-RPC error codes
|
||||
#[derive(Debug, Copy, PartialEq, Eq, Clone)]
|
||||
pub enum EthRpcErrorCode {
|
||||
/// Failed to send transaction, See also <https://github.com/MetaMask/eth-rpc-errors/blob/main/src/error-constants.ts>
|
||||
TransactionRejected,
|
||||
/// Custom geth error code, <https://github.com/vapory-legacy/wiki/blob/master/JSON-RPC-Error-Codes-Improvement-Proposal.md>
|
||||
ExecutionError,
|
||||
/// <https://eips.ethereum.org/EIPS/eip-1898>
|
||||
InvalidInput,
|
||||
}
|
||||
|
||||
impl EthRpcErrorCode {
|
||||
/// Returns the error code as `i32`
|
||||
pub const fn code(&self) -> i32 {
|
||||
match *self {
|
||||
EthRpcErrorCode::TransactionRejected => -32003,
|
||||
EthRpcErrorCode::ExecutionError => 3,
|
||||
EthRpcErrorCode::InvalidInput => -32000,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4,6 +4,7 @@ mod account;
|
||||
mod block;
|
||||
mod call;
|
||||
pub mod engine;
|
||||
pub mod error;
|
||||
mod fee;
|
||||
mod filter;
|
||||
mod index;
|
||||
|
||||
@ -1,37 +1,15 @@
|
||||
//! Error variants for the `eth_` namespace.
|
||||
//! Implementation specific Errors for the `eth_` namespace.
|
||||
|
||||
use crate::result::{internal_rpc_err, rpc_err};
|
||||
use jsonrpsee::{core::Error as RpcError, types::error::INVALID_PARAMS_CODE};
|
||||
use reth_primitives::{constants::SELECTOR_LEN, Address, U128, U256};
|
||||
use reth_rpc_types::BlockError;
|
||||
use reth_rpc_types::{error::EthRpcErrorCode, BlockError};
|
||||
use reth_transaction_pool::error::PoolError;
|
||||
use revm::primitives::{EVMError, Halt};
|
||||
|
||||
/// Result alias
|
||||
pub(crate) type EthResult<T> = Result<T, EthApiError>;
|
||||
|
||||
/// List of JSON-RPC error codes
|
||||
#[derive(Debug, Copy, PartialEq, Eq, Clone)]
|
||||
pub(crate) enum EthRpcErrorCode {
|
||||
/// Failed to send transaction, See also <https://github.com/MetaMask/eth-rpc-errors/blob/main/src/error-constants.ts>
|
||||
TransactionRejected,
|
||||
/// Custom geth error code, <https://github.com/vapory-legacy/wiki/blob/master/JSON-RPC-Error-Codes-Improvement-Proposal.md>
|
||||
ExecutionError,
|
||||
/// <https://eips.ethereum.org/EIPS/eip-1898>
|
||||
InvalidInput,
|
||||
}
|
||||
|
||||
impl EthRpcErrorCode {
|
||||
/// Returns the error code as `i32`
|
||||
pub(crate) const fn code(&self) -> i32 {
|
||||
match *self {
|
||||
EthRpcErrorCode::TransactionRejected => -32003,
|
||||
EthRpcErrorCode::ExecutionError => 3,
|
||||
EthRpcErrorCode::InvalidInput => -32000,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Errors that can occur when interacting with the `eth_` namespace
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
#[allow(missing_docs)]
|
||||
|
||||
Reference in New Issue
Block a user