Do not use Option to wrap GenesisConfig fields (#8275)

Currently we wrap every `GenesisConfig` field in an `Option`, while
we require `Default` being implemented for all pallet genesisconfigs.
Passing `None` also results in the genesis not being initialized, which
is a bug as seen from the perspective of a pallet developer?

This pr changes the fields of the `GenesisConfig` to non `Option` types.
This commit is contained in:
Bastian Köcher
2021-03-06 14:42:21 +01:00
committed by GitHub
parent 1680422f1f
commit b0ebf6498f
10 changed files with 111 additions and 113 deletions
+10 -12
View File
@@ -82,7 +82,7 @@ macro_rules! impl_outer_config {
#[serde(deny_unknown_fields)]
pub struct $main {
$(
pub [< $snake $(_ $instance )? >]: Option<$config>,
pub [< $snake $(_ $instance )? >]: $config,
)*
}
#[cfg(any(feature = "std", test))]
@@ -92,15 +92,13 @@ macro_rules! impl_outer_config {
storage: &mut $crate::sp_runtime::Storage,
) -> std::result::Result<(), String> {
$(
if let Some(ref extra) = self.[< $snake $(_ $instance )? >] {
$crate::impl_outer_config! {
@CALL_FN
$concrete;
$snake;
$( $instance )?;
extra;
storage;
}
$crate::impl_outer_config! {
@CALL_FN
$concrete;
$snake;
$( $instance )?;
&self.[< $snake $(_ $instance )? >];
storage;
}
)*
@@ -117,7 +115,7 @@ macro_rules! impl_outer_config {
$runtime:ident;
$module:ident;
$instance:ident;
$extra:ident;
$extra:expr;
$storage:ident;
) => {
$crate::sp_runtime::BuildModuleGenesisStorage::<$runtime, $module::$instance>::build_module_genesis_storage(
@@ -129,7 +127,7 @@ macro_rules! impl_outer_config {
$runtime:ident;
$module:ident;
;
$extra:ident;
$extra:expr;
$storage:ident;
) => {
$crate::sp_runtime::BuildModuleGenesisStorage::