Add support for RPC state_getReadProof (#106)

* Add support for RPC `state_getReadProof`

* Format code

* Add test
This commit is contained in:
Yuanchao Sun
2020-05-07 14:41:27 +08:00
committed by GitHub
parent f2c42f88cf
commit 825f3ab64c
3 changed files with 48 additions and 0 deletions
+12
View File
@@ -38,6 +38,7 @@ use jsonrpsee::{
use num_traits::bounds::Bounded;
use frame_metadata::RuntimeMetadataPrefixed;
use sc_rpc_api::state::ReadProof;
use serde::Serialize;
use sp_core::{
storage::{
@@ -230,6 +231,17 @@ impl<T: System> Rpc<T> {
Ok(block)
}
/// Get proof of storage entries at a specific block's state.
pub async fn read_proof(
&self,
keys: Vec<StorageKey>,
hash: Option<T::Hash>,
) -> Result<ReadProof<T::Hash>, Error> {
let params = Params::Array(vec![to_json_value(keys)?, to_json_value(hash)?]);
let proof = self.client.request("state_getReadProof", params).await?;
Ok(proof)
}
/// Fetch the runtime version
pub async fn runtime_version(
&self,