update jsonrpsee

This commit is contained in:
Niklas
2021-12-21 11:06:59 +01:00
parent 8e6b277e34
commit 752c19e2f4
4 changed files with 18 additions and 29 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ chameleon = "0.1.0"
scale-info = { version = "1.0.0", features = ["bit-vec"] }
futures = "0.3.13"
hex = "0.4.3"
jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee/", branch = "extract-async-client", features = ["macros", "client"] }
jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee/", branch = "master", features = ["macros", "core-client", "client", "client-ws-transport"] }
log = "0.4.14"
num-traits = { version = "0.2.14", default-features = false }
serde = { version = "1.0.124", features = ["derive"] }
+2 -2
View File
@@ -22,7 +22,7 @@ use crate::{
},
Metadata,
};
use jsonrpsee::types::Error as RequestError;
use jsonrpsee::core::Error as RpcError;
use sp_core::crypto::SecretStringError;
use sp_runtime::{
transaction_validity::TransactionValidityError,
@@ -41,7 +41,7 @@ pub enum Error {
Codec(#[from] codec::Error),
/// Rpc error.
#[error("Rpc error: {0}")]
Rpc(#[from] RequestError),
Rpc(#[from] RpcError),
/// Serde serialization error
#[error("Serde json error: {0}")]
Serialization(#[from] serde_json::error::Error),
+11 -19
View File
@@ -41,22 +41,20 @@ pub use jsonrpsee::{
Uri,
WsTransportClientBuilder,
},
core_client::{
Client as RpcClient,
ClientBuilder as RpcClientBuilder,
},
rpc_params,
types::{
to_json_value,
traits::{
Client,
SubscriptionClient,
core::{
client::{
Client as RpcClient,
ClientBuilder as RpcClientBuilder,
ClientT,
Subscription,
SubscriptionClientT,
},
to_json_value,
DeserializeOwned,
Error as RpcError,
JsonValue,
Subscription,
},
rpc_params,
};
use serde::{
Deserialize,
@@ -488,10 +486,10 @@ impl<T: Config> Rpc<T> {
}?;
let mut xt_sub = self.watch_extrinsic(extrinsic).await?;
while let Ok(Some(status)) = xt_sub.next().await {
while let Some(status) = xt_sub.next().await {
log::info!("Received status {:?}", status);
let status = status?;
match status {
// ignore in progress extrinsic for now
TransactionStatus::Future
| TransactionStatus::Ready
| TransactionStatus::Broadcast(_)
@@ -640,12 +638,6 @@ impl<T: Config> ExtrinsicSuccess<T> {
}
}
/// Example to check that `From<(Sender, Receiver) for RpcClient` works.
pub async fn build_ws_client_default(url: &str) -> Result<RpcClient, RpcError> {
let client = ws_transport(url).await?.into();
Ok(client)
}
/// Build WS RPC client from URL
pub async fn build_ws_client(url: &str) -> Result<RpcClient, RpcError> {
let (sender, receiver) = ws_transport(url).await?;
+4 -7
View File
@@ -14,10 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with subxt. If not, see <http://www.gnu.org/licenses/>.
use jsonrpsee::types::{
DeserializeOwned,
Subscription,
};
use jsonrpsee::core::{DeserializeOwned, client::Subscription};
use sp_core::{
storage::{
StorageChangeSet,
@@ -253,9 +250,9 @@ where
T: DeserializeOwned,
{
match sub.next().await {
Ok(Some(next)) => Some(next),
Ok(None) => None,
Err(e) => {
None => None,
Some(Ok(next)) => Some(next),
Some(Err(e)) => {
log::error!("Subscription {} failed: {:?} dropping", sub_name, e);
None
}