Makes storage hashers optional in dev mode (#13815)

* Initial changes

* Adds UI test for error when _ is used without dev_mode

* Minor

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

* Adds test to verify hasher

---------

Co-authored-by: command-bot <>
This commit is contained in:
gupnik
2023-04-11 20:40:10 +05:30
committed by GitHub
parent 4e32ae1fbe
commit 9c35b9c846
5 changed files with 182 additions and 12 deletions
@@ -269,6 +269,19 @@ pub fn process_generics(def: &mut Def) -> syn::Result<Vec<ResultOnEmptyStructMet
Metadata::DoubleMap { .. } => (5, 6, 7),
};
if storage_def.use_default_hasher {
let hasher_indices: Vec<usize> = match storage_def.metadata {
Metadata::Map { .. } | Metadata::CountedMap { .. } => vec![1],
Metadata::DoubleMap { .. } => vec![1, 3],
_ => vec![],
};
for hasher_idx in hasher_indices {
args.args[hasher_idx] = syn::GenericArgument::Type(
syn::parse_quote!(#frame_support::Blake2_128Concat),
);
}
}
if query_idx < args.args.len() {
if let syn::GenericArgument::Type(query_kind) = args.args.index_mut(query_idx) {
set_result_query_type_parameter(query_kind)?;