eth: return explicit rpc errors to process

This commit is contained in:
bitful-pannul 2024-06-05 22:23:58 -07:00
parent 4302bf323b
commit 9e200de6c9
4 changed files with 9 additions and 0 deletions

1
Cargo.lock generated
View File

@ -3074,6 +3074,7 @@ dependencies = [
"aes-gcm", "aes-gcm",
"alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=6f8ebb4)", "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=6f8ebb4)",
"alloy-contract", "alloy-contract",
"alloy-json-rpc 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=6f8ebb4)",
"alloy-network", "alloy-network",
"alloy-primitives 0.6.4", "alloy-primitives 0.6.4",
"alloy-providers", "alloy-providers",

View File

@ -30,6 +30,7 @@ alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "6f8ebb4" }
alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "6f8ebb4" } alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "6f8ebb4" }
alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "6f8ebb4" } alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "6f8ebb4" }
alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "6f8ebb4" } alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "6f8ebb4" }
alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "6f8ebb4" }
alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "6f8ebb4", features = ["ws"]} alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "6f8ebb4", features = ["ws"]}
alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "6f8ebb4" } alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "6f8ebb4" }
alloy-providers = { git = "https://github.com/alloy-rs/alloy", rev = "6f8ebb4" } alloy-providers = { git = "https://github.com/alloy-rs/alloy", rev = "6f8ebb4" }

View File

@ -1,3 +1,4 @@
use alloy_json_rpc::RpcError;
use alloy_providers::provider::Provider; use alloy_providers::provider::Provider;
use alloy_pubsub::PubSubFrontend; use alloy_pubsub::PubSubFrontend;
use alloy_rpc_client::ClientBuilder; use alloy_rpc_client::ClientBuilder;
@ -618,6 +619,10 @@ async fn fulfill_request(
return EthResponse::Response { value }; return EthResponse::Response { value };
} }
Err(rpc_error) => { Err(rpc_error) => {
// if rpc_error is of type ErrResponse, return to user!
if let RpcError::ErrorResp(err) = rpc_error {
return EthResponse::Err(EthError::RpcError(err.to_string()));
}
verbose_print( verbose_print(
print_tx, print_tx,
&format!( &format!(

View File

@ -61,6 +61,8 @@ pub enum EthResponse {
#[derive(Debug, Serialize, Deserialize, PartialEq)] #[derive(Debug, Serialize, Deserialize, PartialEq)]
pub enum EthError { pub enum EthError {
/// RPC provider returned an error
RpcError(String),
/// provider module cannot parse message /// provider module cannot parse message
MalformedRequest, MalformedRequest,
/// No RPC provider for the chain /// No RPC provider for the chain