mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-10 13:27:30 +00:00
connect to substrate using ws (#417)
This commit is contained in:
committed by
Bastian Köcher
parent
ede0ff8656
commit
55d22a0d1e
@@ -22,7 +22,7 @@ use crate::{ConnectionParams, Result};
|
||||
|
||||
use jsonrpsee::common::DeserializeOwned;
|
||||
use jsonrpsee::raw::RawClient;
|
||||
use jsonrpsee::transport::http::HttpTransportClient;
|
||||
use jsonrpsee::transport::ws::WsTransportClient;
|
||||
use jsonrpsee::Client as RpcClient;
|
||||
use num_traits::Zero;
|
||||
use sp_core::Bytes;
|
||||
@@ -49,10 +49,10 @@ impl<C: Chain> std::fmt::Debug for Client<C> {
|
||||
}
|
||||
|
||||
impl<C: Chain> Client<C> {
|
||||
/// Returns client that is able to call RPCs on Substrate node.
|
||||
/// Returns client that is able to call RPCs on Substrate node over websocket connection.
|
||||
pub async fn new(params: ConnectionParams) -> Result<Self> {
|
||||
let uri = format!("http://{}:{}", params.host, params.port);
|
||||
let transport = HttpTransportClient::new(&uri);
|
||||
let uri = format!("ws://{}:{}", params.host, params.port);
|
||||
let transport = WsTransportClient::new(&uri).await?;
|
||||
let raw_client = RawClient::new(transport);
|
||||
let client: RpcClient = raw_client.into();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user