refactor: replace reconnecting-jsonrpsee-ws-client with subxt-reconnecting-rpc-client (#1705)

* feat: add native subxt rpc reconn client

* add jsonrpsee dep to reconnecting-client

* Update subxt/src/backend/rpc/reconnecting_rpc_client/tests.rs

* fix grumbles

* add simple wasm test for reconnecting client

* fix test build

* cargo fmt

* remove reconnect apis

* Update testing/wasm-rpc-tests/tests/wasm.rs

* Update subxt/src/backend/rpc/reconnecting_rpc_client/tests.rs

* Update subxt/src/backend/rpc/reconnecting_rpc_client/tests.rs
This commit is contained in:
Niklas Adolfsson
2024-08-27 15:18:06 +02:00
committed by GitHub
parent 193452e95f
commit 4bc27d4977
14 changed files with 1102 additions and 343 deletions
+3 -24
View File
@@ -307,12 +307,6 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "cfg_aliases"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
[[package]]
name = "chacha20"
version = "0.9.1"
@@ -1793,23 +1787,6 @@ dependencies = [
"getrandom",
]
[[package]]
name = "reconnecting-jsonrpsee-ws-client"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06fa4f17e09edfc3131636082faaec633c7baa269396b4004040bc6c52f49f65"
dependencies = [
"cfg_aliases",
"finito",
"futures",
"jsonrpsee",
"serde_json",
"thiserror",
"tokio",
"tracing",
"wasm-bindgen-futures",
]
[[package]]
name = "ring"
version = "0.17.8"
@@ -2494,6 +2471,7 @@ dependencies = [
"async-trait",
"derive-where",
"either",
"finito",
"frame-metadata 16.0.0",
"futures",
"getrandom",
@@ -2503,7 +2481,6 @@ dependencies = [
"jsonrpsee",
"parity-scale-codec",
"primitive-types",
"reconnecting-jsonrpsee-ws-client",
"scale-bits",
"scale-decode",
"scale-encode",
@@ -2517,8 +2494,10 @@ dependencies = [
"subxt-macro",
"subxt-metadata",
"thiserror",
"tokio",
"tracing",
"url",
"wasm-bindgen-futures",
]
[[package]]
+1 -1
View File
@@ -15,4 +15,4 @@ futures-util = "0.3.30"
# This crate is not a part of the workspace, because it
# requires the "jsonrpsee web" features to be enabled, which we don't
# want enabled for workspace builds in general.
subxt = { path = "../../subxt", default-features = false, features = ["web", "jsonrpsee"] }
subxt = { path = "../../subxt", default-features = false, features = ["web", "jsonrpsee", "unstable-reconnecting-rpc-client"] }
+11 -1
View File
@@ -1,6 +1,7 @@
#![cfg(target_arch = "wasm32")]
use subxt::config::SubstrateConfig;
use subxt::backend::rpc::reconnecting_rpc_client::RpcClient as ReconnectingRpcClient;
use wasm_bindgen_test::*;
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
@@ -32,5 +33,14 @@ async fn wasm_ws_transport_works() {
.unwrap();
let mut stream = client.backend().stream_best_block_headers().await.unwrap();
stream.next().await;
assert!(stream.next().await.is_some());
}
#[wasm_bindgen_test]
async fn reconnecting_rpc_client_ws_transport_works() {
let rpc = ReconnectingRpcClient::builder().build("ws://127.0.0.1:9944".to_string()).await.unwrap();
let client = subxt::client::OnlineClient::<SubstrateConfig>::from_rpc_client(rpc.clone()).await.unwrap();
let mut stream = client.backend().stream_best_block_headers().await.unwrap();
assert!(stream.next().await.is_some());
}