mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 01:11:10 +00:00
BoundedVec + Shims for Append/DecodeLength (#8556)
* prototype for shawn * Clean and document it * Add more docs * Move imports * Some changes for easier compat. * revert exmaple pallet * rename * BoundedVec for AccountLocks (#8580) * Example with balances * Fix tests * Make it indexable * fix * Fix tests * fix test * Fix collective as well * Fix test * Update frame/support/src/storage/mod.rs Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com> * Repot and add for value * Add for map and double map * Final touches. * Update frame/support/src/storage/bounded_vec.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Add a few more tests * Add import Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com> Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
@@ -75,7 +75,8 @@ pub use self::hash::{
|
||||
};
|
||||
pub use self::storage::{
|
||||
StorageValue, StorageMap, StorageDoubleMap, StoragePrefixedMap, IterableStorageMap,
|
||||
IterableStorageDoubleMap, migration
|
||||
IterableStorageDoubleMap, migration,
|
||||
bounded_vec::{self, BoundedVec},
|
||||
};
|
||||
pub use self::dispatch::{Parameter, Callable};
|
||||
pub use sp_runtime::{self, ConsensusEngineId, print, traits::Printable};
|
||||
@@ -112,20 +113,20 @@ impl TypeId for PalletId {
|
||||
///
|
||||
/// // generate a double map from `(u32, u32)` (with hasher `Twox64Concat`) to `Vec<u8>`
|
||||
/// generate_storage_alias!(
|
||||
/// OtherPrefix, OtherStorageName => DoubleMap<
|
||||
/// OtherPrefix, OtherStorageName => DoubleMap<
|
||||
/// (u32, u32),
|
||||
/// (u32, u32),
|
||||
/// Vec<u8>
|
||||
/// >
|
||||
/// >
|
||||
/// );
|
||||
///
|
||||
/// // generate a map from `Config::AccountId` (with hasher `Twox64Concat`) to `Vec<u8>`
|
||||
/// trait Config { type AccountId: codec::FullCodec; }
|
||||
/// generate_storage_alias!(
|
||||
/// Prefix, GenericStorage<T: Config> => Map<(Twox64Concat, T::AccountId), Vec<u8>>
|
||||
/// Prefix, GenericStorage<T: Config> => Map<(Twox64Concat, T::AccountId), Vec<u8>>
|
||||
/// );
|
||||
/// # fn main() {}
|
||||
///```
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! generate_storage_alias {
|
||||
// without generic for $name.
|
||||
@@ -143,7 +144,7 @@ macro_rules! generate_storage_alias {
|
||||
($pallet:ident, $name:ident => DoubleMap<($key1:ty, $hasher1:ty), ($key2:ty, $hasher2:ty), $value:ty>) => {
|
||||
$crate::paste::paste! {
|
||||
$crate::generate_storage_alias!(@GENERATE_INSTANCE_STRUCT $pallet, $name);
|
||||
type $name = $crate::storage::types::StorageMap<
|
||||
type $name = $crate::storage::types::StorageDoubleMap<
|
||||
[<$name Instance>],
|
||||
$hasher1,
|
||||
$key1,
|
||||
@@ -178,12 +179,11 @@ macro_rules! generate_storage_alias {
|
||||
(
|
||||
$pallet:ident,
|
||||
$name:ident<$t:ident : $bounds:tt>
|
||||
=> DoubleMap<($key1:ty, $hasher1:ty), ($key2:ty, $hasher2:ty), $value:ty>)
|
||||
=> {
|
||||
=> DoubleMap<($key1:ty, $hasher1:ty), ($key2:ty, $hasher2:ty), $value:ty>) => {
|
||||
$crate::paste::paste! {
|
||||
$crate::generate_storage_alias!(@GENERATE_INSTANCE_STRUCT $pallet, $name);
|
||||
#[allow(type_alias_bounds)]
|
||||
type $name<$t : $bounds> = $crate::storage::types::StorageMap<
|
||||
type $name<$t : $bounds> = $crate::storage::types::StorageDoubleMap<
|
||||
[<$name Instance>],
|
||||
$key1,
|
||||
$hasher1,
|
||||
@@ -213,7 +213,7 @@ macro_rules! generate_storage_alias {
|
||||
const STORAGE_PREFIX: &'static str = stringify!($name);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// Create new implementations of the [`Get`](crate::traits::Get) trait.
|
||||
|
||||
Reference in New Issue
Block a user