Skip to content

Commit

Permalink
Relax genesis config to not require Default impl (paritytech#1221)
Browse files Browse the repository at this point in the history
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
  • Loading branch information
nazar-pc and ggwpez authored Aug 29, 2023
1 parent 5de8bca commit 068ddd8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion substrate/frame/support/src/genesis_builder_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ use sp_runtime::format_runtime_string;

/// Get the default `GenesisConfig` as a JSON blob. For more info refer to
/// [`sp_genesis_builder::GenesisBuilder::create_default_config`]
pub fn create_default_config<GC: BuildGenesisConfig>() -> sp_std::vec::Vec<u8> {
pub fn create_default_config<GC>() -> sp_std::vec::Vec<u8>
where
GC: BuildGenesisConfig + Default,
{
serde_json::to_string(&GC::default())
.expect("serialization to json is expected to work. qed.")
.into_bytes()
Expand Down
4 changes: 2 additions & 2 deletions substrate/frame/support/src/traits/hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ pub trait Hooks<BlockNumber> {
/// A trait to define the build function of a genesis config for both runtime and pallets.
///
/// Replaces deprecated [`GenesisBuild<T,I>`].
pub trait BuildGenesisConfig: Default + sp_runtime::traits::MaybeSerializeDeserialize {
pub trait BuildGenesisConfig: sp_runtime::traits::MaybeSerializeDeserialize {
/// The build function puts initial `GenesisConfig` keys/values pairs into the storage.
fn build(&self);
}
Expand All @@ -452,7 +452,7 @@ pub trait BuildGenesisConfig: Default + sp_runtime::traits::MaybeSerializeDeseri
#[deprecated(
note = "GenesisBuild is planned to be removed in December 2023. Use BuildGenesisConfig instead of it."
)]
pub trait GenesisBuild<T, I = ()>: Default + sp_runtime::traits::MaybeSerializeDeserialize {
pub trait GenesisBuild<T, I = ()>: sp_runtime::traits::MaybeSerializeDeserialize {
/// The build function is called within an externalities allowing storage APIs.
/// Thus one can write to storage using regular pallet storages.
fn build(&self);
Expand Down

0 comments on commit 068ddd8

Please sign in to comment.