Skip to content

Commit

Permalink
hack: remove the transport layer generalization s.t. we have concrete…
Browse files Browse the repository at this point in the history
… errors
  • Loading branch information
sander2 committed Nov 22, 2022
1 parent 37392f3 commit 50dee0e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion subxt/src/client/online_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl<T: Config> OnlineClient<T> {
pub async fn from_url(url: impl AsRef<str>) -> Result<OnlineClient<T>, 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
}
}
Expand Down
3 changes: 2 additions & 1 deletion subxt/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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<dyn std::error::Error + Send + Sync + 'static>),
ClientError(#[from] JsonRpseeError),
/// The RPC subscription dropped.
SubscriptionDropped,
}
Expand Down
11 changes: 5 additions & 6 deletions subxt/src/rpc/jsonrpsee_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Box<RawValue>>);

impl ToRpcParams for Params {
Expand All @@ -39,8 +39,7 @@ impl RpcClientT for Client {
) -> RpcFuture<'a, Box<RawValue>> {
Box::pin(async move {
let res = ClientT::request(self, method, Params(params))
.await
.map_err(|e| RpcError::ClientError(Box::new(e)))?;
.await?;
Ok(res)
})
}
Expand All @@ -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)
})
Expand Down
4 changes: 2 additions & 2 deletions subxt/src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 50dee0e

Please sign in to comment.