diff --git a/subxt/src/client/online_client.rs b/subxt/src/client/online_client.rs index fc85fad5fd..3042471b60 100644 --- a/subxt/src/client/online_client.rs +++ b/subxt/src/client/online_client.rs @@ -77,7 +77,7 @@ impl OnlineClient { pub async fn from_url(url: impl AsRef) -> Result, Error> { let client = jsonrpsee_helpers::client(url.as_ref()) .await - .map_err(|e| crate::error::RpcError::ClientError(Box::new(e)))?; + .map_err(|e| crate::error::RpcError::ClientError(e))?; OnlineClient::from_rpc_client(Arc::new(client)).await } } diff --git a/subxt/src/error.rs b/subxt/src/error.rs index dd87277646..88c9520e48 100644 --- a/subxt/src/error.rs +++ b/subxt/src/error.rs @@ -9,6 +9,7 @@ use codec::Decode; use core::fmt::Debug; use scale_info::TypeDef; use std::borrow::Cow; +use crate::rpc::jsonrpsee_impl::JsonRpseeError; // Re-expose the errors we use from other crates here: pub use crate::metadata::{ @@ -112,7 +113,7 @@ pub enum RpcError { // Dev note: We need the error to be safely sent between threads // for `subscribe_to_block_headers_filling_in_gaps` and friends. /// Error related to the RPC client. - ClientError(Box), + ClientError(#[from] JsonRpseeError), /// The RPC subscription dropped. SubscriptionDropped, } diff --git a/subxt/src/rpc/jsonrpsee_impl.rs b/subxt/src/rpc/jsonrpsee_impl.rs index 09dbfe663b..e73a552945 100644 --- a/subxt/src/rpc/jsonrpsee_impl.rs +++ b/subxt/src/rpc/jsonrpsee_impl.rs @@ -19,10 +19,10 @@ use jsonrpsee::core::{ SubscriptionClientT, }, traits::ToRpcParams, - Error as JsonRpseeError, }; use serde_json::value::RawValue; - +pub use jsonrpsee::core::{Error as JsonRpseeError, +}; struct Params(Option>); impl ToRpcParams for Params { @@ -39,8 +39,7 @@ impl RpcClientT for Client { ) -> RpcFuture<'a, Box> { Box::pin(async move { let res = ClientT::request(self, method, Params(params)) - .await - .map_err(|e| RpcError::ClientError(Box::new(e)))?; + .await?; Ok(res) }) } @@ -59,8 +58,8 @@ impl RpcClientT for Client { unsub, ) .await - .map_err(|e| RpcError::ClientError(Box::new(e)))? - .map_err(|e| RpcError::ClientError(Box::new(e))) + .map_err(|e| RpcError::ClientError(e))? + .map_err(|e| RpcError::ClientError(e)) .boxed(); Ok(sub) }) diff --git a/subxt/src/rpc/mod.rs b/subxt/src/rpc/mod.rs index ad08b55d59..e3838ccb44 100644 --- a/subxt/src/rpc/mod.rs +++ b/subxt/src/rpc/mod.rs @@ -52,8 +52,8 @@ // with other file names for their types. #![allow(clippy::module_inception)] -#[cfg(feature = "jsonrpsee")] -mod jsonrpsee_impl; +#[allow(missing_docs)] +pub mod jsonrpsee_impl; mod rpc; mod rpc_client;