mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-09 23:28:00 +00:00
GenesisBuild<T,I> deprecated. BuildGenesisConfig added. (#14306)
* frame::support: GenesisConfig types for Runtime enabled * frame::support: macro generating GenesisBuild::build for RuntimeGenesisConfig * frame: ambiguity BuildStorage vs GenesisBuild fixed * fix * RuntimeGenesisBuild added * Revert "frame: ambiguity BuildStorage vs GenesisBuild fixed" This reverts commit 950f3d019d0e21c55a739c44cc19cdabd3ff0293. * Revert "fix" This reverts commit a2f76dd24e9a16cf9230d45825ed28787211118b. * Revert "RuntimeGenesisBuild added" This reverts commit 3c131b618138ced29c01ab8d15d8c6410c9e128b. * Revert "Revert "frame: ambiguity BuildStorage vs GenesisBuild fixed"" This reverts commit 2b1ecd467231eddec69f8d328039ba48a380da3d. * Revert "Revert "fix"" This reverts commit fd7fa629adf579d83e30e6ae9fd162637fc45e30. * Code review suggestions * frame: BuildGenesisConfig added, BuildGenesis deprecated * frame: some pallets updated with BuildGenesisConfig * constuct_runtime: support for BuildGenesisConfig * frame::support: genesis_build macro supports BuildGenesisConfig * frame: BuildGenesisConfig added, BuildGenesis deprecated * Cargo.lock update * test-runtime: fixes * Revert "fix" This reverts commit a2f76dd24e9a16cf9230d45825ed28787211118b. * Revert "frame: ambiguity BuildStorage vs GenesisBuild fixed" This reverts commit 950f3d019d0e21c55a739c44cc19cdabd3ff0293. * self review * doc fixed * ui tests fixed * fmt * tests fixed * genesis_build macrto fixed for non-generic GenesisConfig * BuildGenesisConfig constraints added * warning fixed * some duplication removed * fmt * fix * doc tests fix * doc fix * cleanup: remove BuildModuleGenesisStorage * self review comments * fix * Update frame/treasury/src/tests.rs Co-authored-by: Sebastian Kunert <skunert49@gmail.com> * Update frame/support/src/traits/hooks.rs Co-authored-by: Sebastian Kunert <skunert49@gmail.com> * doc fix: GenesisBuild exposed * ".git/.scripts/commands/fmt/fmt.sh" * frame: more serde(skip) + cleanup * Update frame/support/src/traits/hooks.rs Co-authored-by: Davide Galassi <davxy@datawok.net> * frame: phantom fields moved to the end of structs * chain-spec: Default::default cleanup * test-runtime: phantom at the end * merge master fixes * fix * fix * fix * fix * fix (facepalm) * Update frame/support/procedural/src/pallet/expand/genesis_build.rs Co-authored-by: Bastian Köcher <git@kchr.de> * fmt * fix * fix --------- Co-authored-by: parity-processbot <> Co-authored-by: Sebastian Kunert <skunert49@gmail.com> Co-authored-by: Davide Galassi <davxy@datawok.net> Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
committed by
GitHub
parent
49150ee583
commit
87d41d0a89
@@ -29,7 +29,7 @@ pub fn expand_outer_config(
|
||||
) -> TokenStream {
|
||||
let mut types = TokenStream::new();
|
||||
let mut fields = TokenStream::new();
|
||||
let mut build_storage_calls = TokenStream::new();
|
||||
let mut genesis_build_calls = TokenStream::new();
|
||||
let mut query_genesis_config_part_macros = Vec::new();
|
||||
|
||||
for decl in pallet_decls {
|
||||
@@ -52,8 +52,8 @@ pub fn expand_outer_config(
|
||||
|
||||
types.extend(expand_config_types(attr, runtime, decl, &config, part_is_generic));
|
||||
fields.extend(quote!(#attr pub #field_name: #config,));
|
||||
build_storage_calls
|
||||
.extend(expand_config_build_storage_call(scrate, attr, runtime, decl, field_name));
|
||||
genesis_build_calls
|
||||
.extend(expand_config_build_storage_call(scrate, &config, attr, field_name));
|
||||
query_genesis_config_part_macros.push(quote! {
|
||||
#path::__substrate_genesis_config_check::is_genesis_config_defined!(#pallet_name);
|
||||
#[cfg(feature = "std")]
|
||||
@@ -67,9 +67,7 @@ pub fn expand_outer_config(
|
||||
|
||||
#types
|
||||
|
||||
#[cfg(any(feature = "std", test))]
|
||||
use #scrate::serde as __genesis_config_serde_import__;
|
||||
#[cfg(any(feature = "std", test))]
|
||||
#[derive(#scrate::serde::Serialize, #scrate::serde::Deserialize, Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[serde(deny_unknown_fields)]
|
||||
@@ -88,13 +86,17 @@ pub fn expand_outer_config(
|
||||
&self,
|
||||
storage: &mut #scrate::sp_runtime::Storage,
|
||||
) -> std::result::Result<(), String> {
|
||||
#build_storage_calls
|
||||
|
||||
#scrate::BasicExternalities::execute_with_storage(storage, || {
|
||||
<AllPalletsWithSystem as #scrate::traits::OnGenesis>::on_genesis();
|
||||
});
|
||||
<Self as #scrate::traits::BuildGenesisConfig>::build(&self);
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
impl #scrate::traits::BuildGenesisConfig for RuntimeGenesisConfig {
|
||||
fn build(&self) {
|
||||
#genesis_build_calls
|
||||
<AllPalletsWithSystem as #scrate::traits::OnGenesis>::on_genesis();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -112,17 +114,14 @@ fn expand_config_types(
|
||||
match (decl.instance.as_ref(), part_is_generic) {
|
||||
(Some(inst), true) => quote! {
|
||||
#attr
|
||||
#[cfg(any(feature = "std", test))]
|
||||
pub type #config = #path::GenesisConfig<#runtime, #path::#inst>;
|
||||
},
|
||||
(None, true) => quote! {
|
||||
#attr
|
||||
#[cfg(any(feature = "std", test))]
|
||||
pub type #config = #path::GenesisConfig<#runtime>;
|
||||
},
|
||||
(_, false) => quote! {
|
||||
#attr
|
||||
#[cfg(any(feature = "std", test))]
|
||||
pub type #config = #path::GenesisConfig;
|
||||
},
|
||||
}
|
||||
@@ -130,21 +129,12 @@ fn expand_config_types(
|
||||
|
||||
fn expand_config_build_storage_call(
|
||||
scrate: &TokenStream,
|
||||
pallet_genesis_config: &Ident,
|
||||
attr: &TokenStream,
|
||||
runtime: &Ident,
|
||||
decl: &Pallet,
|
||||
field_name: &Ident,
|
||||
) -> TokenStream {
|
||||
let path = &decl.path;
|
||||
let instance = if let Some(inst) = decl.instance.as_ref() {
|
||||
quote!(#path::#inst)
|
||||
} else {
|
||||
quote!(#path::__InherentHiddenInstance)
|
||||
};
|
||||
|
||||
quote! {
|
||||
#attr
|
||||
#scrate::sp_runtime::BuildModuleGenesisStorage::
|
||||
<#runtime, #instance>::build_module_genesis_storage(&self.#field_name, storage)?;
|
||||
<#pallet_genesis_config as #scrate::traits::BuildGenesisConfig>::build(&self.#field_name);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user