Skip to content

Commit

Permalink
update jsonrspee to v21 (#707)
Browse files Browse the repository at this point in the history
  • Loading branch information
haerdib authored Feb 12, 2024
1 parent 3098812 commit b618912
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 58 deletions.
137 changes: 88 additions & 49 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ serde_json = { version = "1.0.79", default-features = false }
url = { version = "2.0.0", optional = true }

# websocket dependent features
jsonrpsee = { version = "0.16", optional = true, features = ["async-client", "client-ws-transport", "jsonrpsee-types"] }
jsonrpsee = { version = "0.21", optional = true, features = ["async-client", "client-ws-transport-native-tls", "jsonrpsee-types"] }
tungstenite = { version = "0.21", optional = true, features = ["native-tls"] }
ws = { version = "0.9.2", optional = true, features = ["ssl"] }

Expand Down
14 changes: 6 additions & 8 deletions src/rpc/jsonrpsee_client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use crate::rpc::{Error, Request, Result, RpcParams, Subscribe};
use jsonrpsee::{
client_transport::ws::{Uri, WsTransportClientBuilder},
client_transport::ws::{Url, WsTransportClientBuilder},
core::{
client::{Client, ClientBuilder, ClientT, SubscriptionClientT},
traits::ToRpcParams,
Expand All @@ -38,13 +38,13 @@ impl JsonrpseeClient {
}

pub async fn new(url: &str) -> Result<Self> {
let uri: Uri = url.parse().map_err(|e| Error::Client(Box::new(e)))?;
let parsed_url: Url = url.parse().map_err(|e| Error::Client(Box::new(e)))?;
let (tx, rx) = WsTransportClientBuilder::default()
.build(uri)
.build(parsed_url)
.await
.map_err(|e| Error::Client(Box::new(e)))?;
let client = ClientBuilder::default()
.max_notifs_per_subscription(4096)
.max_buffer_capacity_per_subscription(4096)
.build_with_tokio(tx, rx);
Ok(Self { inner: Arc::new(client) })
}
Expand Down Expand Up @@ -81,11 +81,9 @@ impl Subscribe for JsonrpseeClient {
struct RpcParamsWrapper(RpcParams);

impl ToRpcParams for RpcParamsWrapper {
fn to_rpc_params(self) -> core::result::Result<Option<Box<RawValue>>, jsonrpsee::core::Error> {
fn to_rpc_params(self) -> core::result::Result<Option<Box<RawValue>>, serde_json::Error> {
if let Some(json) = self.0.build() {
RawValue::from_string(json)
.map(Some)
.map_err(jsonrpsee::core::Error::ParseError)
RawValue::from_string(json).map(Some)
} else {
Ok(None)
}
Expand Down

0 comments on commit b618912

Please sign in to comment.