Use frame-decode for core extrinsic decode logic (#1785)

* WIP using frame-decode for core extrinsic decode logic

* fmt

* Fix dependabot config

* clippy

* tidy some imports

* Fix a couple of tests

* Update to frame-decode 0.0.7

* fix docs

* Decode exts earlier to avoid doing it every iter/find step

* frame-decode to 0.1.0

* fmt

* clippy

* fix wasm example

* doc test fixes

* Fix test

* Fix a couple of subxt_core tests
This commit is contained in:
James Wilson
2024-10-01 11:21:51 +01:00
committed by GitHub
parent 72db833def
commit b5209a162e
18 changed files with 226 additions and 324 deletions
+2 -2
View File
@@ -84,12 +84,12 @@ where
return Err(BlockError::not_found(block_hash).into());
};
Ok(Extrinsics::new(
Extrinsics::new(
self.client.clone(),
extrinsics,
self.cached_events.clone(),
block_hash,
)?)
)
}
/// Work with storage.
+5 -13
View File
@@ -6,7 +6,7 @@ use crate::{
blocks::block_types::{get_events, CachedEvents},
client::{OfflineClientT, OnlineClientT},
config::{Config, Hasher},
error::{BlockError, Error},
error::Error,
events,
};
@@ -37,7 +37,7 @@ where
extrinsics: Vec<Vec<u8>>,
cached_events: CachedEvents<T>,
hash: T::Hash,
) -> Result<Self, BlockError> {
) -> Result<Self, Error> {
let inner = CoreExtrinsics::decode_from(extrinsics, client.metadata())?;
Ok(Self {
inner,
@@ -65,21 +65,13 @@ where
/// Returns an iterator over the extrinsics in the block body.
// Dev note: The returned iterator is 'static + Send so that we can box it up and make
// use of it with our `FilterExtrinsic` stuff.
pub fn iter(
&self,
) -> impl Iterator<Item = Result<ExtrinsicDetails<T, C>, Error>> + Send + Sync + 'static {
pub fn iter(&self) -> impl Iterator<Item = ExtrinsicDetails<T, C>> + Send + Sync + 'static {
let client = self.client.clone();
let cached_events = self.cached_events.clone();
let block_hash = self.hash;
self.inner.iter().map(move |res| {
let inner = res?;
Ok(ExtrinsicDetails::new(
inner,
client.clone(),
block_hash,
cached_events.clone(),
))
self.inner.iter().map(move |inner| {
ExtrinsicDetails::new(inner, client.clone(), block_hash, cached_events.clone())
})
}