mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-24 00:45:43 +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:
@@ -3,7 +3,12 @@
|
||||
// see LICENSE for license details.
|
||||
|
||||
use crate::backend::{Backend, BackendExt, BlockRef};
|
||||
use crate::{client::OnlineClientT, error::Error, events::Events, Config};
|
||||
use crate::{
|
||||
client::OnlineClientT,
|
||||
config::{Config, HashFor},
|
||||
error::Error,
|
||||
events::Events,
|
||||
};
|
||||
use derive_where::derive_where;
|
||||
use std::future::Future;
|
||||
|
||||
@@ -38,7 +43,7 @@ where
|
||||
/// but may run into errors attempting to work with them.
|
||||
pub fn at(
|
||||
&self,
|
||||
block_ref: impl Into<BlockRef<T::Hash>>,
|
||||
block_ref: impl Into<BlockRef<HashFor<T>>>,
|
||||
) -> impl Future<Output = Result<Events<T>, Error>> + Send + 'static {
|
||||
self.at_or_latest(Some(block_ref.into()))
|
||||
}
|
||||
@@ -51,7 +56,7 @@ where
|
||||
/// Obtain events at some block hash.
|
||||
fn at_or_latest(
|
||||
&self,
|
||||
block_ref: Option<BlockRef<T::Hash>>,
|
||||
block_ref: Option<BlockRef<HashFor<T>>>,
|
||||
) -> impl Future<Output = Result<Events<T>, Error>> + Send + 'static {
|
||||
// Clone and pass the client in like this so that we can explicitly
|
||||
// return a Future that's Send + 'static, rather than tied to &self.
|
||||
@@ -82,7 +87,7 @@ fn system_events_key() -> [u8; 32] {
|
||||
// Get the event bytes from the provided client, at the provided block hash.
|
||||
pub(crate) async fn get_event_bytes<T: Config>(
|
||||
backend: &dyn Backend<T>,
|
||||
block_hash: T::Hash,
|
||||
block_hash: HashFor<T>,
|
||||
) -> Result<Vec<u8>, Error> {
|
||||
Ok(backend
|
||||
.storage_fetch_value(system_events_key().to_vec(), block_hash)
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
use crate::{Config, Error, Metadata};
|
||||
use crate::{
|
||||
config::{Config, HashFor},
|
||||
Error, Metadata,
|
||||
};
|
||||
use derive_where::derive_where;
|
||||
use scale_decode::DecodeAsType;
|
||||
use subxt_core::events::{EventDetails as CoreEventDetails, Events as CoreEvents};
|
||||
@@ -153,7 +156,7 @@ impl<T: Config> EventDetails<T> {
|
||||
}
|
||||
|
||||
/// Return the topics associated with this event.
|
||||
pub fn topics(&self) -> &[T::Hash] {
|
||||
pub fn topics(&self) -> &[HashFor<T>] {
|
||||
self.inner.topics()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,10 @@ mod events_type;
|
||||
|
||||
use crate::client::OnlineClientT;
|
||||
use crate::Error;
|
||||
use subxt_core::{Config, Metadata};
|
||||
use subxt_core::{
|
||||
config::{Config, HashFor},
|
||||
Metadata,
|
||||
};
|
||||
|
||||
pub use events_client::EventsClient;
|
||||
pub use events_type::{EventDetails, EventMetadataDetails, Events, Phase, StaticEvent};
|
||||
@@ -19,7 +22,7 @@ pub use events_type::{EventDetails, EventMetadataDetails, Events, Phase, StaticE
|
||||
/// Creates a new [`Events`] instance by fetching the corresponding bytes at `block_hash` from the client.
|
||||
pub async fn new_events_from_client<T, C>(
|
||||
metadata: Metadata,
|
||||
block_hash: T::Hash,
|
||||
block_hash: HashFor<T>,
|
||||
client: C,
|
||||
) -> Result<Events<T>, Error>
|
||||
where
|
||||
|
||||
Reference in New Issue
Block a user