mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-18 18:45:41 +00:00
Metadata V16: Be more dynamic over which hasher is used. (#1974)
* Use DynamicHasher256 to support Blake2 or Keccack depending on chain * remove Config::Hash associated type, replace with HashFor<Config> alias * Fix doc links * fix wasm tests * Don't strip system pallet associated types. check System.Hashing, not Hash. Rename BlockHash trait to Hash * Tweak comment * fmt * fix merge * Fix typo
This commit is contained in:
+6
-4
@@ -45,7 +45,7 @@ pub trait RpcConfig {
|
||||
/// The block header type.
|
||||
type Header: Header;
|
||||
/// The block hash type.
|
||||
type Hash: BlockHash;
|
||||
type Hash: Hash;
|
||||
/// The Account ID type.
|
||||
type AccountId: AccountId;
|
||||
}
|
||||
@@ -55,8 +55,8 @@ pub trait Header: std::fmt::Debug + codec::Decode + serde::de::DeserializeOwned
|
||||
impl<T> Header for T where T: std::fmt::Debug + codec::Decode + serde::de::DeserializeOwned {}
|
||||
|
||||
/// A trait which is applied to any type that is a valid block hash.
|
||||
pub trait BlockHash: serde::de::DeserializeOwned + serde::Serialize {}
|
||||
impl<T> BlockHash for T where T: serde::de::DeserializeOwned + serde::Serialize {}
|
||||
pub trait Hash: serde::de::DeserializeOwned + serde::Serialize {}
|
||||
impl<T> Hash for T where T: serde::de::DeserializeOwned + serde::Serialize {}
|
||||
|
||||
/// A trait which is applied to any type that is a valid Account ID.
|
||||
pub trait AccountId: serde::Serialize {}
|
||||
@@ -67,12 +67,14 @@ impl<T> AccountId for T where T: serde::Serialize {}
|
||||
#[cfg(feature = "subxt")]
|
||||
mod impl_config {
|
||||
use super::*;
|
||||
use subxt_core::config::HashFor;
|
||||
|
||||
impl<T> RpcConfig for T
|
||||
where
|
||||
T: subxt_core::Config,
|
||||
{
|
||||
type Header = T::Header;
|
||||
type Hash = T::Hash;
|
||||
type Hash = HashFor<T>;
|
||||
type AccountId = T::AccountId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
//! methods exposed here.
|
||||
|
||||
use crate::client::{rpc_params, RpcClient, RpcSubscription};
|
||||
use crate::BlockHash;
|
||||
use crate::Hash;
|
||||
use crate::{Error, RpcConfig};
|
||||
use derive_where::derive_where;
|
||||
use futures::{Stream, StreamExt};
|
||||
@@ -871,7 +871,7 @@ pub struct FollowSubscription<Hash> {
|
||||
done: bool,
|
||||
}
|
||||
|
||||
impl<Hash: BlockHash> FollowSubscription<Hash> {
|
||||
impl<H: Hash> FollowSubscription<H> {
|
||||
/// Fetch the next item in the stream.
|
||||
pub async fn next(&mut self) -> Option<<Self as Stream>::Item> {
|
||||
<Self as StreamExt>::next(self).await
|
||||
@@ -882,8 +882,8 @@ impl<Hash: BlockHash> FollowSubscription<Hash> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<Hash: BlockHash> Stream for FollowSubscription<Hash> {
|
||||
type Item = <RpcSubscription<FollowEvent<Hash>> as Stream>::Item;
|
||||
impl<H: Hash> Stream for FollowSubscription<H> {
|
||||
type Item = <RpcSubscription<FollowEvent<H>> as Stream>::Item;
|
||||
fn poll_next(
|
||||
mut self: std::pin::Pin<&mut Self>,
|
||||
cx: &mut std::task::Context<'_>,
|
||||
@@ -910,15 +910,15 @@ pub struct TransactionSubscription<Hash> {
|
||||
done: bool,
|
||||
}
|
||||
|
||||
impl<Hash: BlockHash> TransactionSubscription<Hash> {
|
||||
impl<H: Hash> TransactionSubscription<H> {
|
||||
/// Fetch the next item in the stream.
|
||||
pub async fn next(&mut self) -> Option<<Self as Stream>::Item> {
|
||||
<Self as StreamExt>::next(self).await
|
||||
}
|
||||
}
|
||||
|
||||
impl<Hash: BlockHash> Stream for TransactionSubscription<Hash> {
|
||||
type Item = <RpcSubscription<TransactionStatus<Hash>> as Stream>::Item;
|
||||
impl<H: Hash> Stream for TransactionSubscription<H> {
|
||||
type Item = <RpcSubscription<TransactionStatus<H>> as Stream>::Item;
|
||||
fn poll_next(
|
||||
mut self: std::pin::Pin<&mut Self>,
|
||||
cx: &mut std::task::Context<'_>,
|
||||
@@ -1031,7 +1031,7 @@ pub struct ArchiveStorageSubscription<Hash> {
|
||||
done: bool,
|
||||
}
|
||||
|
||||
impl<Hash: BlockHash> ArchiveStorageSubscription<Hash> {
|
||||
impl<H: Hash> ArchiveStorageSubscription<H> {
|
||||
/// Fetch the next item in the stream.
|
||||
pub async fn next(&mut self) -> Option<<Self as Stream>::Item> {
|
||||
<Self as StreamExt>::next(self).await
|
||||
@@ -1042,8 +1042,8 @@ impl<Hash: BlockHash> ArchiveStorageSubscription<Hash> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<Hash: BlockHash> Stream for ArchiveStorageSubscription<Hash> {
|
||||
type Item = <RpcSubscription<ArchiveStorageEvent<Hash>> as Stream>::Item;
|
||||
impl<H: Hash> Stream for ArchiveStorageSubscription<H> {
|
||||
type Item = <RpcSubscription<ArchiveStorageEvent<H>> as Stream>::Item;
|
||||
fn poll_next(
|
||||
mut self: std::pin::Pin<&mut Self>,
|
||||
cx: &mut std::task::Context<'_>,
|
||||
|
||||
Reference in New Issue
Block a user