Introduce Metadata type (#974)

* WIP new Metadata type

* Finish basic Metadata impl inc hashing and validation

* remove caching from metadata; can add that higher up

* remove caches

* update retain to use Metadata

* clippy fixes

* update codegen to use Metadata

* clippy

* WIP fixing subxt lib

* WIP fixing tests, rebuild artifacts, fix OrderedMap::retain

* get --all-targets compiling

* move DispatchError type lookup back to being optional

* cargo clippy

* fix docs

* re-use VariantIndex to get variants

* add docs and enforce docs on metadata crate

* fix docs

* add test and fix docs

* cargo fmt

* address review comments

* update lockfiles

* ExactSizeIter so we can ask for len() of things (and hopefully soon is_empty()
This commit is contained in:
James Wilson
2023-05-25 10:35:21 +01:00
committed by GitHub
parent f344d0dd4d
commit b9f5419095
64 changed files with 6818 additions and 5719 deletions
+3 -9
View File
@@ -34,7 +34,6 @@
use std::sync::Arc;
use codec::{Decode, Encode};
use frame_metadata::RuntimeMetadataPrefixed;
use serde::Serialize;
use crate::{error::Error, utils::PhantomDataSendSync, Config, Metadata};
@@ -149,8 +148,7 @@ impl<T: Config> Rpc<T> {
.client
.request("state_getMetadata", rpc_params![at])
.await?;
let meta: RuntimeMetadataPrefixed = Decode::decode(&mut &bytes[..])?;
let metadata: Metadata = meta.try_into()?;
let metadata = Metadata::decode(&mut &bytes[..])?;
Ok(metadata)
}
@@ -387,9 +385,7 @@ impl<T: Config> Rpc<T> {
let bytes = opaque.ok_or(Error::Other("Metadata version not found".into()))?;
let meta: RuntimeMetadataPrefixed = Decode::decode(&mut &bytes.0[..])?;
let metadata: Metadata = meta.try_into()?;
let metadata: Metadata = Decode::decode(&mut &bytes.0[..])?;
Ok(metadata)
}
@@ -404,9 +400,7 @@ impl<T: Config> Rpc<T> {
let bytes: frame_metadata::OpaqueMetadata =
self.state_call("Metadata_metadata", None, None).await?;
let meta: RuntimeMetadataPrefixed = Decode::decode(&mut &bytes.0[..])?;
let metadata: Metadata = meta.try_into()?;
let metadata: Metadata = Decode::decode(&mut &bytes.0[..])?;
Ok(metadata)
}