Upgrade jsonrpc to 0.18.0 (#9547)

* Upgrade jsonrpc to 0.18.0

I think this says all :P

* 🤦

* Fmt etc

* Fix tests

* Fix tests again...

* Better impl

* Revert "Tell dependabot to ignore jsonrpc-* updates (#9518)"

This reverts commit 6e0cd5587d.
This commit is contained in:
Bastian Köcher
2021-08-13 08:46:07 +02:00
committed by GitHub
parent 199b2883af
commit c44aba89e6
65 changed files with 1422 additions and 1291 deletions
+3 -5
View File
@@ -23,7 +23,6 @@
use codec::{DecodeAll, FullCodec, FullEncode};
use core::marker::PhantomData;
use frame_support::storage::generator::{StorageDoubleMap, StorageMap, StorageValue};
use futures::compat::Future01CompatExt;
use jsonrpc_client_transports::RpcError;
use sc_rpc_api::state::StateClient;
use serde::{de::DeserializeOwned, Serialize};
@@ -32,7 +31,6 @@ use sp_storage::{StorageData, StorageKey};
/// A typed query on chain state usable from an RPC client.
///
/// ```no_run
/// # use futures::compat::Future01CompatExt;
/// # use jsonrpc_client_transports::RpcError;
/// # use jsonrpc_client_transports::transports::http;
/// # use codec::Encode;
@@ -69,7 +67,7 @@ use sp_storage::{StorageData, StorageKey};
/// }
///
/// # async fn test() -> Result<(), RpcError> {
/// let conn = http::connect("http://[::1]:9933").compat().await?;
/// let conn = http::connect("http://[::1]:9933").await?;
/// let cl = StateClient::<Hash>::new(conn);
///
/// let q = StorageQuery::value::<LastActionId>();
@@ -127,9 +125,9 @@ impl<V: FullCodec> StorageQuery<V> {
state_client: &StateClient<Hash>,
block_index: Option<Hash>,
) -> Result<Option<V>, RpcError> {
let opt: Option<StorageData> = state_client.storage(self.key, block_index).compat().await?;
let opt: Option<StorageData> = state_client.storage(self.key, block_index).await?;
opt.map(|encoded| V::decode_all(&encoded.0))
.transpose()
.map_err(|decode_err| RpcError::Other(decode_err.into()))
.map_err(|decode_err| RpcError::Other(Box::new(decode_err)))
}
}