remove prelude from subxt-metadata

This commit is contained in:
Tadeo hepperle
2024-02-01 18:42:47 +01:00
parent fbee16dfb6
commit 7aa69891a9
12 changed files with 29 additions and 94 deletions
Generated
-1
View File
@@ -4578,7 +4578,6 @@ version = "0.34.0"
dependencies = [
"assert_matches",
"bitvec",
"cfg-if",
"criterion",
"derive_more",
"frame-metadata 16.0.0",
-1
View File
@@ -24,7 +24,6 @@ codec = { package = "parity-scale-codec", workspace = true, default-features = f
sp-core-hashing = { workspace = true }
hashbrown = { workspace = true }
derive_more = { workspace = true }
cfg-if = { workspace = true }
[dev-dependencies]
bitvec = { workspace = true, features = ["alloc"] }
+1 -2
View File
@@ -2,9 +2,8 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use crate::prelude::*;
use alloc::string::String;
use derive_more::Display;
use string::String;
mod v14;
mod v15;
+8 -7
View File
@@ -3,15 +3,15 @@
// see LICENSE for license details.
use super::TryFromError;
use crate::prelude::*;
use crate::Metadata;
use borrow::ToOwned;
use fmt::Write;
use alloc::borrow::ToOwned;
use alloc::string::String;
use alloc::vec;
use alloc::vec::Vec;
use frame_metadata::{v14, v15};
use hashbrown::HashMap;
use scale_info::TypeDef;
use string::String;
use vec::Vec;
impl TryFrom<v14::RuntimeMetadataV14> for Metadata {
type Error = TryFromError;
@@ -374,8 +374,9 @@ fn generate_outer_error_enum_type(
// Note: using the `format!` macro like in `let path = format!("{}Error", pallet.name);`
// leads to linker errors about extern function `_Unwind_Resume` not being defined.
let mut path = String::new();
write!(path, "{}Error", pallet.name).expect("Cannot panic, qed;");
// let mut path = String::new();
// write!(path, "{}Error", pallet.name).expect("Cannot panic, qed;");
let path = alloc::format!("{}Error", pallet.name);
let ty = error.ty.id.into();
Some(scale_info::Variant {
+2 -2
View File
@@ -3,7 +3,7 @@
// see LICENSE for license details.
use super::TryFromError;
use crate::prelude::*;
use crate::utils::variant_index::VariantIndex;
use crate::{
utils::ordered_map::OrderedMap, ArcStr, ConstantMetadata, ExtrinsicMetadata, Metadata,
@@ -11,7 +11,7 @@ use crate::{
RuntimeApiMethodParamMetadata, SignedExtensionMetadata, StorageEntryMetadata,
StorageEntryModifier, StorageEntryType, StorageHasher, StorageMetadata,
};
use borrow::ToOwned;
use alloc::borrow::ToOwned;
use frame_metadata::v15;
use hashbrown::HashMap;
use scale_info::form::PortableForm;
+6 -6
View File
@@ -17,18 +17,18 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![deny(missing_docs)]
extern crate alloc;
mod from_into;
mod prelude;
mod utils;
use alloc::string::String;
use alloc::sync::Arc;
use alloc::vec::Vec;
use hashbrown::HashMap;
use prelude::*;
use scale_info::{form::PortableForm, PortableRegistry, Variant};
use string::String;
use sync::Arc;
use utils::variant_index::VariantIndex;
use utils::{ordered_map::OrderedMap, validation::outer_enum_hashes::OuterEnumHashes};
use vec::Vec;
type ArcStr = Arc<str>;
@@ -205,7 +205,7 @@ impl Metadata {
// its name to ensure that every unique type has a unique path, too.
if *visited_count > 1 {
if let Some(name) = ty.ty.path.segments.last_mut() {
*name = format!("{name}{visited_count}");
*name = alloc::format!("{name}{visited_count}");
}
}
}
-59
View File
@@ -1,59 +0,0 @@
// Copyright 2019-2023 Parity Technologies (UK) Ltd.
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
#[cfg(not(feature = "std"))]
extern crate alloc;
use cfg_if::cfg_if;
cfg_if! {
if #[cfg(feature = "std")] {
#[allow(unused)]
pub use std::{
any,
borrow,
boxed,
cmp,
collections,
fmt,
format,
hash,
marker,
mem,
num,
ops,
string,
sync,
time,
vec,
rc,
iter,
};
} else {
#[allow(unused)]
pub use alloc::{
borrow,
boxed,
collections,
format,
string,
sync,
vec,
rc
};
#[allow(unused)]
pub use core::{
any,
cmp,
fmt,
hash,
marker,
mem,
num,
ops,
time,
iter,
};
}
}
+6 -6
View File
@@ -2,9 +2,9 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use crate::prelude::*;
use alloc::vec::Vec;
use core::mem;
use hashbrown::HashMap;
use vec::Vec;
/// A minimal ordered map to let one search for
/// things by key or get the values in insert order.
@@ -25,7 +25,7 @@ impl<K, V> Default for OrderedMap<K, V> {
impl<K, V> OrderedMap<K, V>
where
K: PartialEq + Eq + hash::Hash,
K: PartialEq + Eq + core::hash::Hash,
{
/// Create a new, empty [`OrderedMap`].
pub fn new() -> Self {
@@ -80,8 +80,8 @@ where
/// Get an item by its key.
pub fn get_by_key<Q>(&self, key: &Q) -> Option<&V>
where
K: borrow::Borrow<Q>,
Q: hash::Hash + Eq + ?Sized,
K: alloc::borrow::Borrow<Q>,
Q: core::hash::Hash + Eq + ?Sized,
{
self.map.get(key).and_then(|&v| self.values.get(v))
}
@@ -109,7 +109,7 @@ where
impl<K, V> FromIterator<(K, V)> for OrderedMap<K, V>
where
K: PartialEq + Eq + hash::Hash,
K: PartialEq + Eq + core::hash::Hash,
{
fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> Self {
let mut map = OrderedMap::new();
+1 -2
View File
@@ -4,12 +4,11 @@
//! Utility functions to generate a subset of the metadata.
use crate::prelude::*;
use crate::{
ExtrinsicMetadata, Metadata, OuterEnumsMetadata, PalletMetadataInner, RuntimeApiMetadataInner,
StorageEntryType,
};
use collections::BTreeMap;
use alloc::collections::BTreeMap;
use hashbrown::HashSet;
use scale_info::TypeDef;
+1 -2
View File
@@ -4,15 +4,14 @@
//! Utility functions for metadata validation.
use crate::prelude::*;
use crate::{
CustomMetadata, CustomValueMetadata, ExtrinsicMetadata, Metadata, PalletMetadata,
RuntimeApiMetadata, RuntimeApiMethodMetadata, StorageEntryMetadata, StorageEntryType,
};
use alloc::vec::Vec;
use hashbrown::HashMap;
use outer_enum_hashes::OuterEnumHashes;
use scale_info::{form::PortableForm, Field, PortableRegistry, TypeDef, TypeDefVariant, Variant};
use vec::Vec;
pub mod outer_enum_hashes;
+4 -5
View File
@@ -2,11 +2,10 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use crate::prelude::*;
use borrow::ToOwned;
use alloc::borrow::ToOwned;
use alloc::string::String;
use hashbrown::HashMap;
use scale_info::{form::PortableForm, PortableRegistry, TypeDef, Variant};
use string::String;
/// Given some type ID and type registry, build a couple of
/// indexes to look up variants by index or name. If the ID provided
@@ -65,8 +64,8 @@ impl VariantIndex {
types: &'a PortableRegistry,
) -> Option<&'a Variant<PortableForm>>
where
String: borrow::Borrow<K>,
K: hash::Hash + Eq + ?Sized,
String: alloc::borrow::Borrow<K>,
K: core::hash::Hash + Eq + ?Sized,
{
let pos = *self.by_name.get(name)?;
let variants = Self::get(variant_id, types)?;
-1
View File
@@ -371,7 +371,6 @@ dependencies = [
name = "subxt-metadata"
version = "0.34.0"
dependencies = [
"cfg-if",
"derive_more",
"frame-metadata",
"hashbrown",