mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 23:18:01 +00:00
Generate correct serde bound for GenesisConfig (#2585)
* Generate correct serde bound for GenesisConfig * Handle double map as well * Adapt double map test
This commit is contained in:
@@ -198,7 +198,7 @@ fn decl_store_extra_genesis(
|
||||
|
||||
let mut is_trait_needed = false;
|
||||
let mut has_trait_field = false;
|
||||
let mut serde_complete_bound = std::collections::HashSet::new();
|
||||
let mut serde_complete_bound = Vec::new();
|
||||
let mut config_field = TokenStream2::new();
|
||||
let mut config_field_default = TokenStream2::new();
|
||||
let mut builders = TokenStream2::new();
|
||||
@@ -239,9 +239,20 @@ fn decl_store_extra_genesis(
|
||||
has_trait_field = true;
|
||||
}
|
||||
|
||||
serde_complete_bound.insert(type_infos.value_type);
|
||||
if let DeclStorageTypeInfosKind::Map { key_type, .. } = type_infos.kind {
|
||||
serde_complete_bound.insert(key_type);
|
||||
let value_type = &type_infos.value_type;
|
||||
serde_complete_bound.push(quote!( #value_type ));
|
||||
match type_infos.kind {
|
||||
DeclStorageTypeInfosKind::Map { key_type, .. } =>
|
||||
serde_complete_bound.push(quote!( #key_type )),
|
||||
DeclStorageTypeInfosKind::DoubleMap { key1_type, key2_type, .. } => {
|
||||
serde_complete_bound.push(quote!( #key1_type ));
|
||||
serde_complete_bound.push(quote!( #key2_type ));
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
|
||||
if type_infos.is_option {
|
||||
serde_complete_bound.push(type_infos.typ.clone());
|
||||
}
|
||||
|
||||
// Propagate doc attributes.
|
||||
@@ -335,7 +346,7 @@ fn decl_store_extra_genesis(
|
||||
has_trait_field = true;
|
||||
}
|
||||
|
||||
serde_complete_bound.insert(extra_type);
|
||||
serde_complete_bound.push(quote!( #extra_type ));
|
||||
|
||||
let extrafield = &extra_field.content;
|
||||
genesis_extrafields.extend(quote!{
|
||||
@@ -363,7 +374,7 @@ fn decl_store_extra_genesis(
|
||||
let serde_bug_bound = if !serde_complete_bound.is_empty() {
|
||||
let mut b_ser = String::new();
|
||||
let mut b_dser = String::new();
|
||||
// panic!("{:#?}", serde_complete_bound);
|
||||
|
||||
serde_complete_bound.into_iter().for_each(|bound| {
|
||||
let stype = quote!(#bound);
|
||||
b_ser.push_str(&format!("{} : {}::serde::Serialize, ", stype, scrate));
|
||||
@@ -515,7 +526,7 @@ fn decl_storage_items(
|
||||
|
||||
impls.extend(quote! {
|
||||
/// Tag a type as an instance of a module.
|
||||
///
|
||||
///
|
||||
/// Defines storage prefixes, they must be unique.
|
||||
pub trait #instantiable: 'static {
|
||||
#const_impls
|
||||
|
||||
Reference in New Issue
Block a user