Adds ability to use default hasher in dev_mode for explicit key binding (#14164)

* Initial setup

* Minor update

* Minor update

* Addresses review comments

* Addresses review comments

* Updates doc

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

* Renames file

* Updates path in test

---------

Co-authored-by: command-bot <>
This commit is contained in:
gupnik
2023-05-19 18:54:32 +05:30
committed by GitHub
parent 580efaec85
commit 958f4aaa38
5 changed files with 82 additions and 12 deletions
@@ -0,0 +1,33 @@
#![cfg_attr(not(feature = "std"), no_std)]
pub use pallet::*;
#[frame_support::pallet]
pub mod pallet {
use frame_support::pallet_prelude::*;
// The struct on which we build all of our Pallet logic.
#[pallet::pallet]
pub struct Pallet<T>(_);
// Your Pallet's configuration trait, representing custom external types and interfaces.
#[pallet::config]
pub trait Config: frame_system::Config {}
#[pallet::storage]
type MyStorage<T: Config> = StorageValue<_, Vec<u8>>;
#[pallet::storage]
type MyStorageMap<T: Config> = StorageMap<Key = u32, Value = u64>;
#[pallet::storage]
type MyStorageDoubleMap<T: Config> = StorageDoubleMap<Key1 = u32, Key2 = u64, Value = u64>;
#[pallet::storage]
type MyCountedStorageMap<T: Config> = CountedStorageMap<Key = u32, Value = u64>;
// Your Pallet's internal functions.
impl<T: Config> Pallet<T> {}
}
fn main() {}
@@ -0,0 +1,11 @@
error: Invalid pallet::storage, cannot find `Hasher` generic, required for `StorageMap`.
--> tests/pallet_ui/non_dev_mode_storage_map_explicit_key_default_hasher.rs:21:43
|
21 | type MyStorageMap<T: Config> = StorageMap<Key = u32, Value = u64>;
| ^
error[E0432]: unresolved import `pallet`
--> tests/pallet_ui/non_dev_mode_storage_map_explicit_key_default_hasher.rs:3:9
|
3 | pub use pallet::*;
| ^^^^^^ help: a similar path exists: `test_pallet::pallet`
@@ -35,6 +35,15 @@ pub mod pallet {
#[pallet::storage]
type MyCountedStorageMap<T: Config> = CountedStorageMap<_, _, u32, u64>;
#[pallet::storage]
pub type MyStorageMap2<T: Config> = StorageMap<Key = u32, Value = u64>;
#[pallet::storage]
type MyStorageDoubleMap2<T: Config> = StorageDoubleMap<Key1 = u32, Key2 = u64, Value = u64>;
#[pallet::storage]
type MyCountedStorageMap2<T: Config> = CountedStorageMap<Key = u32, Value = u64>;
// Your Pallet's callable functions.
#[pallet::call]
impl<T: Config> Pallet<T> {