diff --git a/src/frame/balances.rs b/src/frame/balances.rs index 4b8e3d01ba..ade21eeee8 100644 --- a/src/frame/balances.rs +++ b/src/frame/balances.rs @@ -98,7 +98,7 @@ impl BalancesStore for Client { Ok(map) => map, Err(err) => return Box::new(future::err(err)), }; - Box::new(self.fetch_or(map.key(account_id), map.default())) + Box::new(self.fetch_or(map.key(account_id), None, map.default())) } } diff --git a/src/frame/system.rs b/src/frame/system.rs index 7039595356..ee803cdc04 100644 --- a/src/frame/system.rs +++ b/src/frame/system.rs @@ -29,6 +29,7 @@ use frame_support::Parameter; use sp_runtime::traits::{ Bounded, CheckEqual, + Extrinsic, Hash, Header, MaybeDisplay, @@ -108,6 +109,9 @@ pub trait System: 'static + Eq + Clone + Debug { type Header: Parameter + Header + DeserializeOwned; + + /// Extrinsic type within blocks. + type Extrinsic: Parameter + Member + Extrinsic + Debug + MaybeSerializeDeserialize; } /// The System extension trait for the Client. @@ -141,7 +145,7 @@ impl SystemStore for Client { Ok(map) => map, Err(err) => return Box::new(future::err(err)), }; - Box::new(self.fetch_or(map.key(account_id), map.default())) + Box::new(self.fetch_or(map.key(account_id), None, map.default())) } } diff --git a/src/lib.rs b/src/lib.rs index 2fe4b74663..fc3619213e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -180,34 +180,37 @@ impl Client { pub fn fetch( &self, key: StorageKey, + hash: Option, ) -> impl Future, Error = Error> { - self.connect().and_then(|rpc| rpc.storage::(key)) + self.connect().and_then(move |rpc| rpc.storage::(key, hash)) } /// Fetch a StorageKey or return the default. pub fn fetch_or( &self, key: StorageKey, + hash: Option, default: V, ) -> impl Future { - self.fetch(key).map(|value| value.unwrap_or(default)) + self.fetch(key, hash).map(|value| value.unwrap_or(default)) } /// Fetch a StorageKey or return the default. pub fn fetch_or_default( &self, key: StorageKey, + hash: Option, ) -> impl Future { - self.fetch(key).map(|value| value.unwrap_or_default()) + self.fetch(key, hash).map(|value| value.unwrap_or_default()) } /// Get a block hash. By default returns the latest block hash pub fn block_hash( &self, - hash: Option>, + height: Option>, ) -> impl Future, Error = Error> { self.connect() - .and_then(|rpc| rpc.block_hash(hash.map(|h| h))) + .and_then(|rpc| rpc.block_hash(height.map(|h| h))) } /// Get a block hash of the latest finalized block diff --git a/src/rpc.rs b/src/rpc.rs index 7dee1301eb..069186dd5f 100644 --- a/src/rpc.rs +++ b/src/rpc.rs @@ -61,7 +61,6 @@ use sp_runtime::{ SignedBlock, }, traits::Hash, - OpaqueExtrinsic, }; use sp_transaction_pool::TransactionStatus; use sp_version::RuntimeVersion; @@ -84,7 +83,7 @@ use crate::{ metadata::Metadata, }; -pub type ChainBlock = SignedBlock::Header, OpaqueExtrinsic>>; +pub type ChainBlock = SignedBlock::Header, ::Extrinsic>>; pub type BlockNumber = NumberOrHex<::BlockNumber>; /// Client for substrate rpc interfaces @@ -110,9 +109,10 @@ impl Rpc { pub fn storage( &self, key: StorageKey, + hash: Option, ) -> impl Future, Error = Error> { self.state - .storage(key, None) + .storage(key, hash) .map_err(Into::into) .and_then(|data| { match data { diff --git a/src/runtimes.rs b/src/runtimes.rs index aded4394e0..7815b418d9 100644 --- a/src/runtimes.rs +++ b/src/runtimes.rs @@ -22,6 +22,7 @@ use sp_runtime::{ Verify, }, MultiSignature, + OpaqueExtrinsic, }; use crate::frame::{ @@ -47,6 +48,7 @@ impl System for DefaultNodeRuntime { type AccountId = <::Signer as IdentifyAccount>::AccountId; type Address = pallet_indices::address::Address; type Header = Header; + type Extrinsic = OpaqueExtrinsic; } impl Balances for DefaultNodeRuntime {