mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 07:41:08 +00:00
Convert to std futures (#58)
* WIP * Begin converting rpc layer to use std futures and jsonrpsee * Convert metadata to async/await * Convert block_hash to async/await * Convert more methods to async/await * Remove sp_rpc * Fix more compilation errors * Remove connect * Starting to convert subscription functions * Use jsonrpsee branch from PR for public client types * Implement subscribe events with jsonrpsee subscription * Converting subscriptions and wait_for_block_events * WIP converting lib methods to async * Use shared client reference directly for rpc call `rpc_api!` macro currently only supports RawClient (which cannot be shared). Also supports named params only which is not currently compatible with substrate rpd which accepts only positional params. * Use &self instead of &mut self for shared Client * Convert submit_and_watch to async/await * Convert more Client fns to async * Pin some trait futures * Add serde error * Fix client creation * Fix client request compiler errors * Unify metadata errors * Add WS handshake error variant * Fix some more compiler errors * Fix more compiler errors * Convert submit_extrinsic to async * Convert submit and submit_and_watch * Add Send + Sync constraints * Clone clients * Fix EventArg conversion error * Fix remaining warnings/errors * Replace deny warnings with specific lints * Infallable subscription loops * Use jsonrpsee wss branch * Fix example * Start to fix up tests * Make contracts tests compile * Make some more tests pass * Fix up remaining tests * Fmt * Use correct event storage key type * Fix finding events * Use master jsonrpsee
This commit is contained in:
+21
-10
@@ -16,16 +16,13 @@
|
||||
|
||||
//! Implements support for the frame_system module.
|
||||
|
||||
use std::fmt::Debug;
|
||||
|
||||
use codec::Codec;
|
||||
use frame_support::Parameter;
|
||||
use futures::future::{
|
||||
self,
|
||||
Future,
|
||||
};
|
||||
use serde::de::DeserializeOwned;
|
||||
|
||||
use frame_support::Parameter;
|
||||
use sp_runtime::traits::{
|
||||
Bounded,
|
||||
CheckEqual,
|
||||
@@ -39,6 +36,10 @@ use sp_runtime::traits::{
|
||||
SimpleArithmetic,
|
||||
SimpleBitOps,
|
||||
};
|
||||
use std::{
|
||||
fmt::Debug,
|
||||
pin::Pin,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
error::Error,
|
||||
@@ -123,17 +124,22 @@ pub trait SystemStore {
|
||||
fn account_nonce(
|
||||
&self,
|
||||
account_id: <Self::System as System>::AccountId,
|
||||
) -> Box<dyn Future<Item = <Self::System as System>::Index, Error = Error> + Send>;
|
||||
) -> Pin<
|
||||
Box<dyn Future<Output = Result<<Self::System as System>::Index, Error>> + Send>,
|
||||
>;
|
||||
}
|
||||
|
||||
impl<T: System + Balances + 'static, S: 'static> SystemStore for Client<T, S> {
|
||||
impl<T: System + Balances + Sync + Send + 'static, S: 'static> SystemStore
|
||||
for Client<T, S>
|
||||
{
|
||||
type System = T;
|
||||
|
||||
fn account_nonce(
|
||||
&self,
|
||||
account_id: <Self::System as System>::AccountId,
|
||||
) -> Box<dyn Future<Item = <Self::System as System>::Index, Error = Error> + Send>
|
||||
{
|
||||
) -> Pin<
|
||||
Box<dyn Future<Output = Result<<Self::System as System>::Index, Error>> + Send>,
|
||||
> {
|
||||
let account_nonce_map = || {
|
||||
Ok(self
|
||||
.metadata
|
||||
@@ -143,9 +149,14 @@ impl<T: System + Balances + 'static, S: 'static> SystemStore for Client<T, S> {
|
||||
};
|
||||
let map = match account_nonce_map() {
|
||||
Ok(map) => map,
|
||||
Err(err) => return Box::new(future::err(err)),
|
||||
Err(err) => return Box::pin(future::err(err)),
|
||||
};
|
||||
Box::new(self.fetch_or(map.key(account_id), None, map.default()))
|
||||
let client = self.clone();
|
||||
Box::pin(async move {
|
||||
client
|
||||
.fetch_or(map.key(account_id), None, map.default())
|
||||
.await
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user