From cef6d697b8b9e2490ab78dd367d7f9fdfc2a52d0 Mon Sep 17 00:00:00 2001 From: Liu-Cheng Xu Date: Fri, 21 May 2021 18:45:34 +0800 Subject: [PATCH] Expose the rpc client in Client (#267) When we build a `Client` for a substrate chain, we can only access the methods exposed in `Client` which does not cover all the RPC interfaces in the chain, it's not feasible to request the methods like `chain_getKeys` with `Client` only. The downstream user of this library has to build another `RpcClient` for the uncovered RPC interfaces, which can be unneccessary. --- src/lib.rs | 5 +++++ src/rpc.rs | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 170800f589..a8b8f6936c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -353,6 +353,11 @@ impl Client { &self.properties } + /// Returns the rpc client. + pub fn rpc_client(&self) -> &RpcClient { + &self.rpc.client + } + /// Fetch the value under an unhashed storage key pub async fn fetch_unhashed( &self, diff --git a/src/rpc.rs b/src/rpc.rs index 75c67b22d5..22b8e7e310 100644 --- a/src/rpc.rs +++ b/src/rpc.rs @@ -258,7 +258,8 @@ pub struct ReadProof { /// Client for substrate rpc interfaces pub struct Rpc { - client: RpcClient, + /// Rpc client for sending requests. + pub client: RpcClient, marker: PhantomData, accept_weak_inclusion: bool, }