This commit is contained in:
Niklas Adolfsson
2021-11-30 19:41:31 +01:00
parent a45bf143bb
commit c2a9c75481
2 changed files with 13 additions and 11 deletions
+3 -4
View File
@@ -35,10 +35,10 @@ use core::{
use frame_metadata::RuntimeMetadataPrefixed;
pub use jsonrpsee::{
client_transport::ws::{
Receiver as WsReceiver,
Sender as WsSender,
Uri,
WsTransportClientBuilder,
Sender as WsSender,
Receiver as WsReceiver,
},
core_client::{
Client as RpcClient,
@@ -663,8 +663,7 @@ pub async fn build_ws_client(url: &str) -> Result<RpcClient, RpcError> {
}
async fn ws_transport(url: &str) -> (WsSender, WsReceiver) {
// TODO: fix unwraps because I'm lazy.
// fix unwraps because I'm lazy.
let url: Uri = url.parse().unwrap();
WsTransportClientBuilder::default()
.build(url)
+10 -7
View File
@@ -27,7 +27,11 @@ use std::{
thread,
time,
};
use subxt::rpc::{Client as _, rpc_params, build_ws_client};
use subxt::rpc::{
build_ws_client,
rpc_params,
Client as _,
};
static SUBSTRATE_BIN_ENV_VAR: &str = "SUBSTRATE_NODE_PATH";
@@ -61,12 +65,11 @@ async fn main() {
if retries >= MAX_RETRIES {
panic!("Cannot connect to substrate node after {} retries", retries);
}
let res =
build_ws_client(&format!("ws://localhost:{}", port))
.await
.expect("should only error if malformed URL for an HTTP connection")
.request("state_getMetadata", rpc_params![])
.await;
let res = build_ws_client(&format!("ws://localhost:{}", port))
.await
.expect("should only error if malformed URL for an HTTP connection")
.request("state_getMetadata", rpc_params![])
.await;
match res {
Ok(res) => {
let _ = cmd.kill();