mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 16:17:59 +00:00
Implement a CountedStorageMap (#9125)
* initial impl * expose in pallet_prelude * temp test * Apply suggestions from code review Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com> Co-authored-by: Xiliang Chen <xlchen1291@gmail.com> * implement with macro help. * test for macro generation * add iterable functions, some test and fixes * fix merge * doc * Update frame/support/src/storage/types/counted_map.rs Co-authored-by: Zeke Mostov <32168567+emostov@users.noreply.github.com> * fix merge * fmt * fix spelling * improve on removal * fix partial storage info * fmt * add license * suggested renames * fix typo * fix test * fmt * fix ui tests * clearer doc * better doc * add metadata test Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com> Co-authored-by: Xiliang Chen <xlchen1291@gmail.com> Co-authored-by: Zeke Mostov <32168567+emostov@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
49b6dfd2e5
commit
65e5fa3aa3
@@ -1,6 +1,6 @@
|
||||
#[frame_support::pallet]
|
||||
mod pallet {
|
||||
use frame_support::pallet_prelude::StorageValue;
|
||||
use frame_support::pallet_prelude::*;
|
||||
|
||||
#[pallet::config]
|
||||
pub trait Config: frame_system::Config {}
|
||||
@@ -12,9 +12,15 @@ mod pallet {
|
||||
#[pallet::storage]
|
||||
type Foo<T> = StorageValue<_, u8>;
|
||||
|
||||
#[pallet::storage]
|
||||
#[pallet::storage_prefix = "Foo"]
|
||||
type NotFoo<T> = StorageValue<_, u16>;
|
||||
#[pallet::storage]
|
||||
#[pallet::storage_prefix = "Foo"]
|
||||
type NotFoo<T> = StorageValue<_, u16>;
|
||||
|
||||
#[pallet::storage]
|
||||
type CounterForBar<T> = StorageValue<_, u16>;
|
||||
|
||||
#[pallet::storage]
|
||||
type Bar<T> = CountedStorageMap<_, Twox64Concat, u16, u16>;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
||||
@@ -1,17 +1,47 @@
|
||||
error: Duplicate storage prefixes found for `Foo`
|
||||
--> $DIR/duplicate_storage_prefix.rs:16:32
|
||||
--> $DIR/duplicate_storage_prefix.rs:16:29
|
||||
|
|
||||
16 | #[pallet::storage_prefix = "Foo"]
|
||||
| ^^^^^
|
||||
|
||||
error: Duplicate storage prefixes found for `Foo`
|
||||
--> $DIR/duplicate_storage_prefix.rs:13:7
|
||||
|
|
||||
13 | type Foo<T> = StorageValue<_, u8>;
|
||||
| ^^^
|
||||
|
||||
error: Duplicate storage prefixes found for `CounterForBar`, used for counter associated to counted storage map
|
||||
--> $DIR/duplicate_storage_prefix.rs:23:7
|
||||
|
|
||||
23 | type Bar<T> = CountedStorageMap<_, Twox64Concat, u16, u16>;
|
||||
| ^^^
|
||||
|
||||
error: Duplicate storage prefixes found for `CounterForBar`
|
||||
--> $DIR/duplicate_storage_prefix.rs:20:7
|
||||
|
|
||||
20 | type CounterForBar<T> = StorageValue<_, u16>;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error[E0412]: cannot find type `_GeneratedPrefixForStorageFoo` in this scope
|
||||
--> $DIR/duplicate_storage_prefix.rs:13:7
|
||||
|
|
||||
13 | type Foo<T> = StorageValue<_, u8>;
|
||||
| ^^^ not found in this scope
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/duplicate_storage_prefix.rs:17:35
|
||||
error[E0412]: cannot find type `_GeneratedPrefixForStorageNotFoo` in this scope
|
||||
--> $DIR/duplicate_storage_prefix.rs:17:7
|
||||
|
|
||||
17 | type NotFoo<T> = StorageValue<_, u16>;
|
||||
| ^ not allowed in type signatures
|
||||
| ^^^^^^ not found in this scope
|
||||
|
||||
error[E0412]: cannot find type `_GeneratedPrefixForStorageCounterForBar` in this scope
|
||||
--> $DIR/duplicate_storage_prefix.rs:20:7
|
||||
|
|
||||
20 | type CounterForBar<T> = StorageValue<_, u16>;
|
||||
| ^^^^^^^^^^^^^ not found in this scope
|
||||
|
||||
error[E0412]: cannot find type `_GeneratedPrefixForStorageBar` in this scope
|
||||
--> $DIR/duplicate_storage_prefix.rs:23:7
|
||||
|
|
||||
23 | type Bar<T> = CountedStorageMap<_, Twox64Concat, u16, u16>;
|
||||
| ^^^ not found in this scope
|
||||
|
||||
+8
-8
@@ -5,8 +5,8 @@ error[E0277]: the trait bound `Bar: TypeInfo` is not satisfied
|
||||
| ^^^^^^^ the trait `TypeInfo` is not implemented for `Bar`
|
||||
|
|
||||
= note: required because of the requirements on the impl of `StaticTypeInfo` for `Bar`
|
||||
= note: required because of the requirements on the impl of `frame_support::storage::StorageEntryMetadata` for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo<T>, Bar>`
|
||||
= note: required by `NAME`
|
||||
= note: required because of the requirements on the impl of `StorageEntryMetadataBuilder` for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo<T>, Bar>`
|
||||
= note: required by `build_metadata`
|
||||
|
||||
error[E0277]: the trait bound `Bar: WrapperTypeDecode` is not satisfied
|
||||
--> $DIR/storage_ensure_span_are_ok_on_wrong_gen.rs:20:12
|
||||
@@ -16,8 +16,8 @@ error[E0277]: the trait bound `Bar: WrapperTypeDecode` is not satisfied
|
||||
|
|
||||
= note: required because of the requirements on the impl of `Decode` for `Bar`
|
||||
= note: required because of the requirements on the impl of `FullCodec` for `Bar`
|
||||
= note: required because of the requirements on the impl of `frame_support::storage::StorageEntryMetadata` for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo<T>, Bar>`
|
||||
= note: required by `NAME`
|
||||
= note: required because of the requirements on the impl of `StorageEntryMetadataBuilder` for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo<T>, Bar>`
|
||||
= note: required by `build_metadata`
|
||||
|
||||
error[E0277]: the trait bound `Bar: EncodeLike` is not satisfied
|
||||
--> $DIR/storage_ensure_span_are_ok_on_wrong_gen.rs:20:12
|
||||
@@ -27,8 +27,8 @@ error[E0277]: the trait bound `Bar: EncodeLike` is not satisfied
|
||||
|
|
||||
= note: required because of the requirements on the impl of `FullEncode` for `Bar`
|
||||
= note: required because of the requirements on the impl of `FullCodec` for `Bar`
|
||||
= note: required because of the requirements on the impl of `frame_support::storage::StorageEntryMetadata` for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo<T>, Bar>`
|
||||
= note: required by `NAME`
|
||||
= note: required because of the requirements on the impl of `StorageEntryMetadataBuilder` for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo<T>, Bar>`
|
||||
= note: required by `build_metadata`
|
||||
|
||||
error[E0277]: the trait bound `Bar: WrapperTypeEncode` is not satisfied
|
||||
--> $DIR/storage_ensure_span_are_ok_on_wrong_gen.rs:20:12
|
||||
@@ -39,8 +39,8 @@ error[E0277]: the trait bound `Bar: WrapperTypeEncode` is not satisfied
|
||||
= note: required because of the requirements on the impl of `Encode` for `Bar`
|
||||
= note: required because of the requirements on the impl of `FullEncode` for `Bar`
|
||||
= note: required because of the requirements on the impl of `FullCodec` for `Bar`
|
||||
= note: required because of the requirements on the impl of `frame_support::storage::StorageEntryMetadata` for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo<T>, Bar>`
|
||||
= note: required by `NAME`
|
||||
= note: required because of the requirements on the impl of `StorageEntryMetadataBuilder` for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo<T>, Bar>`
|
||||
= note: required by `build_metadata`
|
||||
|
||||
error[E0277]: the trait bound `Bar: WrapperTypeDecode` is not satisfied
|
||||
--> $DIR/storage_ensure_span_are_ok_on_wrong_gen.rs:9:12
|
||||
|
||||
+8
-8
@@ -5,8 +5,8 @@ error[E0277]: the trait bound `Bar: TypeInfo` is not satisfied
|
||||
| ^^^^^^^ the trait `TypeInfo` is not implemented for `Bar`
|
||||
|
|
||||
= note: required because of the requirements on the impl of `StaticTypeInfo` for `Bar`
|
||||
= note: required because of the requirements on the impl of `frame_support::storage::StorageEntryMetadata` for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo<T>, Bar>`
|
||||
= note: required by `NAME`
|
||||
= note: required because of the requirements on the impl of `StorageEntryMetadataBuilder` for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo<T>, Bar>`
|
||||
= note: required by `build_metadata`
|
||||
|
||||
error[E0277]: the trait bound `Bar: WrapperTypeDecode` is not satisfied
|
||||
--> $DIR/storage_ensure_span_are_ok_on_wrong_gen_unnamed.rs:20:12
|
||||
@@ -16,8 +16,8 @@ error[E0277]: the trait bound `Bar: WrapperTypeDecode` is not satisfied
|
||||
|
|
||||
= note: required because of the requirements on the impl of `Decode` for `Bar`
|
||||
= note: required because of the requirements on the impl of `FullCodec` for `Bar`
|
||||
= note: required because of the requirements on the impl of `frame_support::storage::StorageEntryMetadata` for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo<T>, Bar>`
|
||||
= note: required by `NAME`
|
||||
= note: required because of the requirements on the impl of `StorageEntryMetadataBuilder` for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo<T>, Bar>`
|
||||
= note: required by `build_metadata`
|
||||
|
||||
error[E0277]: the trait bound `Bar: EncodeLike` is not satisfied
|
||||
--> $DIR/storage_ensure_span_are_ok_on_wrong_gen_unnamed.rs:20:12
|
||||
@@ -27,8 +27,8 @@ error[E0277]: the trait bound `Bar: EncodeLike` is not satisfied
|
||||
|
|
||||
= note: required because of the requirements on the impl of `FullEncode` for `Bar`
|
||||
= note: required because of the requirements on the impl of `FullCodec` for `Bar`
|
||||
= note: required because of the requirements on the impl of `frame_support::storage::StorageEntryMetadata` for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo<T>, Bar>`
|
||||
= note: required by `NAME`
|
||||
= note: required because of the requirements on the impl of `StorageEntryMetadataBuilder` for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo<T>, Bar>`
|
||||
= note: required by `build_metadata`
|
||||
|
||||
error[E0277]: the trait bound `Bar: WrapperTypeEncode` is not satisfied
|
||||
--> $DIR/storage_ensure_span_are_ok_on_wrong_gen_unnamed.rs:20:12
|
||||
@@ -39,8 +39,8 @@ error[E0277]: the trait bound `Bar: WrapperTypeEncode` is not satisfied
|
||||
= note: required because of the requirements on the impl of `Encode` for `Bar`
|
||||
= note: required because of the requirements on the impl of `FullEncode` for `Bar`
|
||||
= note: required because of the requirements on the impl of `FullCodec` for `Bar`
|
||||
= note: required because of the requirements on the impl of `frame_support::storage::StorageEntryMetadata` for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo<T>, Bar>`
|
||||
= note: required by `NAME`
|
||||
= note: required because of the requirements on the impl of `StorageEntryMetadataBuilder` for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo<T>, Bar>`
|
||||
= note: required by `build_metadata`
|
||||
|
||||
error[E0277]: the trait bound `Bar: WrapperTypeDecode` is not satisfied
|
||||
--> $DIR/storage_ensure_span_are_ok_on_wrong_gen_unnamed.rs:9:12
|
||||
|
||||
@@ -4,6 +4,6 @@ error[E0277]: the trait bound `Bar: MaxEncodedLen` is not satisfied
|
||||
10 | #[pallet::generate_storage_info]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ the trait `MaxEncodedLen` is not implemented for `Bar`
|
||||
|
|
||||
= note: required because of the requirements on the impl of `KeyGeneratorMaxEncodedLen` for `NMapKey<frame_support::Twox64Concat, Bar>`
|
||||
= note: required because of the requirements on the impl of `StorageInfoTrait` for `frame_support::pallet_prelude::StorageNMap<_GeneratedPrefixForStorageFoo<T>, NMapKey<frame_support::Twox64Concat, Bar>, u32>`
|
||||
= note: required because of the requirements on the impl of `KeyGeneratorMaxEncodedLen` for `Key<frame_support::Twox64Concat, Bar>`
|
||||
= note: required because of the requirements on the impl of `StorageInfoTrait` for `frame_support::pallet_prelude::StorageNMap<_GeneratedPrefixForStorageFoo<T>, Key<frame_support::Twox64Concat, Bar>, u32>`
|
||||
= note: required by `storage_info`
|
||||
|
||||
Reference in New Issue
Block a user