Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/networking/rpc/clients/eth/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub enum EthClientError {
#[error("eth_gasPrice request error: {0}")]
GetGasPriceError(#[from] GetGasPriceError),
#[error("eth_estimateGas request error: {0}")]
EstimateGasPriceError(#[from] EstimateGasPriceError),
EstimateGasError(#[from] EstimateGasError),
#[error("eth_sendRawTransaction request error: {0}")]
SendRawTransactionError(#[from] SendRawTransactionError),
#[error("eth_call request error: {0}")]
Expand Down Expand Up @@ -67,7 +67,7 @@ pub enum GetGasPriceError {
}

#[derive(Debug, thiserror::Error)]
pub enum EstimateGasPriceError {
pub enum EstimateGasError {
#[error("{0}")]
ReqwestError(#[from] reqwest::Error),
#[error("{0}")]
Expand Down
15 changes: 7 additions & 8 deletions crates/networking/rpc/clients/eth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ use crate::{
};
use bytes::Bytes;
use errors::{
EstimateGasPriceError, EthClientError, GetBalanceError, GetBlockByHashError,
GetBlockByNumberError, GetBlockNumberError, GetCodeError, GetGasPriceError, GetLogsError,
GetMaxPriorityFeeError, GetNonceError, GetTransactionByHashError, GetTransactionReceiptError,
SendRawTransactionError,
EstimateGasError, EthClientError, GetBalanceError, GetBlockByHashError, GetBlockByNumberError,
GetBlockNumberError, GetCodeError, GetGasPriceError, GetLogsError, GetMaxPriorityFeeError,
GetNonceError, GetTransactionByHashError, GetTransactionReceiptError, SendRawTransactionError,
};
use eth_sender::Overrides;
use ethrex_common::{
Expand Down Expand Up @@ -448,13 +447,13 @@ impl EthClient {
match self.send_request(request).await {
Ok(RpcResponse::Success(result)) => {
let res = serde_json::from_value::<String>(result.result)
.map_err(EstimateGasPriceError::SerdeJSONError)?;
let res = res.get(2..).ok_or(EstimateGasPriceError::Custom(
.map_err(EstimateGasError::SerdeJSONError)?;
let res = res.get(2..).ok_or(EstimateGasError::Custom(
"Failed to slice index response in estimate_gas".to_owned(),
))?;
u64::from_str_radix(res, 16)
}
.map_err(EstimateGasPriceError::ParseIntError)
.map_err(EstimateGasError::ParseIntError)
.map_err(EthClientError::from),
Ok(RpcResponse::Error(error_response)) => {
let error_data = if let Some(error_data) = error_response.error.data {
Expand Down Expand Up @@ -503,7 +502,7 @@ impl EthClient {
} else {
"unknown error".to_owned()
};
Err(EstimateGasPriceError::RPCError(format!(
Err(EstimateGasError::RPCError(format!(
"{}: {}",
error_response.error.message, error_data
))
Expand Down
Loading