Restructure frame_support macro related exports (#14745)

* make reexports private

* make reexports private 2

* make reexports private for runtime-benchmarking

* make reexports private for try-runtime

* fix for try-runtime

* make reexports private for tests

* fmt

* make reexports private for tests

* make reexports private for experimental

* fix beefy

* fix ui test

* fix ui test

* fix benches

* ".git/.scripts/commands/fmt/fmt.sh"

* fix contracts use

* wip

* wip

* do not reexport sp_api::metadata_ir

* fix CI checks

* fix support tests

* ".git/.scripts/commands/fmt/fmt.sh"

* Update frame/support/src/lib.rs

Co-authored-by: Bastian Köcher <git@kchr.de>

* import codec directly

* fmt

* fix node-cli tests

---------

Co-authored-by: command-bot <>
Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
Juan
2023-08-23 14:30:12 +02:00
committed by GitHub
parent 574592d1cf
commit 878c562cd4
125 changed files with 449 additions and 398 deletions
@@ -35,8 +35,9 @@ impl<T, S: Get<u32>> StorageTryAppend<T> for BoundedVec<T, S> {
#[cfg(test)]
pub mod test {
use super::*;
use crate::{bounded_vec, traits::ConstU32, Twox128};
use crate::{traits::ConstU32, Twox128};
use sp_io::TestExternalities;
use sp_runtime::bounded_vec;
#[crate::storage_alias]
type Foo = StorageValue<Prefix, BoundedVec<u32, ConstU32<7>>>;
+2 -2
View File
@@ -21,10 +21,10 @@
// NOTE: could replace unhashed by having only one kind of storage (top trie being the child info
// of null length parent storage key).
pub use crate::sp_io::{KillStorageResult, MultiRemovalResults};
use crate::sp_std::prelude::*;
use codec::{Codec, Decode, Encode};
pub use sp_core::storage::{ChildInfo, ChildType, StateVersion};
pub use sp_io::{KillStorageResult, MultiRemovalResults};
use sp_std::prelude::*;
/// Return the value of the item in storage under `key`, or `None` if there is no explicit entry.
pub fn get<T: Decode + Sized>(child_info: &ChildInfo, key: &[u8]) -> Option<T> {
@@ -41,7 +41,7 @@ pub struct StorageNoopGuard(sp_std::vec::Vec<u8>);
impl Default for StorageNoopGuard {
fn default() -> Self {
Self(frame_support::storage_root(frame_support::StateVersion::V1))
Self(sp_io::storage::root(sp_runtime::StateVersion::V1))
}
}
@@ -52,7 +52,7 @@ impl Drop for StorageNoopGuard {
return
}
assert_eq!(
frame_support::storage_root(frame_support::StateVersion::V1),
sp_io::storage::root(sp_runtime::StateVersion::V1),
self.0,
"StorageNoopGuard detected wrongful storage changes.",
);
@@ -18,7 +18,6 @@
//! Storage counted map type.
use crate::{
metadata_ir::StorageEntryMetadataIR,
storage::{
generator::StorageMap as _,
types::{
@@ -32,6 +31,7 @@ use crate::{
};
use codec::{Decode, Encode, EncodeLike, FullCodec, MaxEncodedLen, Ref};
use sp_io::MultiRemovalResults;
use sp_metadata_ir::StorageEntryMetadataIR;
use sp_runtime::traits::Saturating;
use sp_std::prelude::*;
@@ -512,11 +512,11 @@ mod test {
use super::*;
use crate::{
hash::*,
metadata_ir::{StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR},
storage::{bounded_vec::BoundedVec, types::ValueQuery},
traits::ConstU32,
};
use sp_io::{hashing::twox_128, TestExternalities};
use sp_metadata_ir::{StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR};
struct Prefix;
impl StorageInstance for Prefix {
@@ -29,7 +29,7 @@ use crate::{
Never,
};
use codec::{Decode, Encode, EncodeLike, FullCodec, MaxEncodedLen, Ref};
use sp_api::metadata_ir::StorageEntryMetadataIR;
use sp_metadata_ir::StorageEntryMetadataIR;
use sp_runtime::traits::Saturating;
use sp_std::prelude::*;
@@ -638,8 +638,8 @@ mod test {
hash::{StorageHasher as _, *},
storage::types::{Key as NMapKey, ValueQuery},
};
use sp_api::metadata_ir::{StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR};
use sp_io::{hashing::twox_128, TestExternalities};
use sp_metadata_ir::{StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR};
struct Prefix;
impl StorageInstance for Prefix {
@@ -19,7 +19,6 @@
//! StoragePrefixedDoubleMap traits and their methods directly.
use crate::{
metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR},
storage::{
types::{OptionQuery, QueryKindTrait, StorageEntryMetadataBuilder},
KeyLenOf, StorageAppend, StorageDecodeLength, StoragePrefixedMap, StorageTryAppend,
@@ -29,6 +28,7 @@ use crate::{
};
use codec::{Decode, Encode, EncodeLike, FullCodec, MaxEncodedLen};
use sp_arithmetic::traits::SaturatedConversion;
use sp_metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR};
use sp_std::prelude::*;
/// A type that allow to store values for `(key1, key2)` couple. Similar to `StorageMap` but allow
@@ -734,12 +734,9 @@ where
#[cfg(test)]
mod test {
use super::*;
use crate::{
hash::*,
metadata_ir::{StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR},
storage::types::ValueQuery,
};
use crate::{hash::*, storage::types::ValueQuery};
use sp_io::{hashing::twox_128, TestExternalities};
use sp_metadata_ir::{StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR};
struct Prefix;
impl StorageInstance for Prefix {
@@ -41,7 +41,7 @@ pub trait KeyGenerator {
type HashFn: FnOnce(&[u8]) -> Vec<u8>;
type HArg;
const HASHER_METADATA: &'static [crate::metadata_ir::StorageHasherIR];
const HASHER_METADATA: &'static [sp_metadata_ir::StorageHasherIR];
/// Given a `key` tuple, calculate the final key by encoding each element individually and
/// hashing them using the corresponding hasher in the `KeyGenerator`.
@@ -74,7 +74,7 @@ impl<H: StorageHasher, K: FullCodec + StaticTypeInfo> KeyGenerator for Key<H, K>
type HashFn = Box<dyn FnOnce(&[u8]) -> Vec<u8>>;
type HArg = (Self::HashFn,);
const HASHER_METADATA: &'static [crate::metadata_ir::StorageHasherIR] = &[H::METADATA];
const HASHER_METADATA: &'static [sp_metadata_ir::StorageHasherIR] = &[H::METADATA];
fn final_key<KArg: EncodeLikeTuple<Self::KArg> + TupleToEncodedIter>(key: KArg) -> Vec<u8> {
H::hash(&key.to_encoded_iter().next().expect("should have at least one element!"))
@@ -114,7 +114,7 @@ impl KeyGenerator for Tuple {
for_tuples!( type HArg = ( #(Tuple::HashFn),* ); );
type HashFn = Box<dyn FnOnce(&[u8]) -> Vec<u8>>;
const HASHER_METADATA: &'static [crate::metadata_ir::StorageHasherIR] =
const HASHER_METADATA: &'static [sp_metadata_ir::StorageHasherIR] =
&[for_tuples!( #(Tuple::Hasher::METADATA),* )];
fn final_key<KArg: EncodeLikeTuple<Self::KArg> + TupleToEncodedIter>(key: KArg) -> Vec<u8> {
@@ -19,7 +19,6 @@
//! methods directly.
use crate::{
metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR},
storage::{
types::{OptionQuery, QueryKindTrait, StorageEntryMetadataBuilder},
KeyLenOf, StorageAppend, StorageDecodeLength, StoragePrefixedMap, StorageTryAppend,
@@ -29,6 +28,7 @@ use crate::{
};
use codec::{Decode, Encode, EncodeLike, FullCodec, MaxEncodedLen};
use sp_arithmetic::traits::SaturatedConversion;
use sp_metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR};
use sp_std::prelude::*;
/// A type that allow to store value for given key. Allowing to insert/remove/iterate on values.
@@ -511,10 +511,10 @@ mod test {
use super::*;
use crate::{
hash::*,
metadata_ir::{StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR},
storage::{types::ValueQuery, IterableStorageMap},
};
use sp_io::{hashing::twox_128, TestExternalities};
use sp_metadata_ir::{StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR};
struct Prefix;
impl StorageInstance for Prefix {
@@ -18,8 +18,8 @@
//! Storage types to build abstraction on storage, they implements storage traits such as
//! StorageMap and others.
use crate::metadata_ir::{StorageEntryMetadataIR, StorageEntryModifierIR};
use codec::FullCodec;
use sp_metadata_ir::{StorageEntryMetadataIR, StorageEntryModifierIR};
use sp_std::prelude::*;
mod counted_map;
@@ -19,7 +19,6 @@
//! traits and their methods directly.
use crate::{
metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR},
storage::{
types::{
EncodeLikeTuple, HasKeyPrefix, HasReversibleKeyPrefix, OptionQuery, QueryKindTrait,
@@ -30,6 +29,7 @@ use crate::{
traits::{Get, GetDefault, StorageInfo, StorageInstance},
};
use codec::{Decode, Encode, EncodeLike, FullCodec, MaxEncodedLen};
use sp_metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR};
use sp_runtime::SaturatedConversion;
use sp_std::prelude::*;
@@ -620,10 +620,10 @@ mod test {
use super::*;
use crate::{
hash::{StorageHasher as _, *},
metadata_ir::{StorageEntryModifierIR, StorageHasherIR},
storage::types::{Key as NMapKey, ValueQuery},
};
use sp_io::{hashing::twox_128, TestExternalities};
use sp_metadata_ir::{StorageEntryModifierIR, StorageHasherIR};
struct Prefix;
impl StorageInstance for Prefix {
@@ -18,7 +18,6 @@
//! Storage value type. Implements StorageValue trait and its method directly.
use crate::{
metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR},
storage::{
generator::StorageValue as StorageValueT,
types::{OptionQuery, QueryKindTrait, StorageEntryMetadataBuilder},
@@ -28,6 +27,7 @@ use crate::{
};
use codec::{Decode, Encode, EncodeLike, FullCodec, MaxEncodedLen};
use sp_arithmetic::traits::SaturatedConversion;
use sp_metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR};
use sp_std::prelude::*;
/// A type that allow to store a value.
@@ -278,8 +278,9 @@ where
#[cfg(test)]
mod test {
use super::*;
use crate::{metadata_ir::StorageEntryModifierIR, storage::types::ValueQuery};
use crate::storage::types::ValueQuery;
use sp_io::{hashing::twox_128, TestExternalities};
use sp_metadata_ir::StorageEntryModifierIR;
struct Prefix;
impl StorageInstance for Prefix {