From 3c131b618138ced29c01ab8d15d8c6410c9e128b Mon Sep 17 00:00:00 2001 From: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> Date: Mon, 12 Jun 2023 11:33:01 +0200 Subject: [PATCH] RuntimeGenesisBuild added --- .../procedural/src/construct_runtime/expand/config.rs | 2 +- frame/support/src/traits.rs | 2 +- frame/support/src/traits/hooks.rs | 7 +++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/frame/support/procedural/src/construct_runtime/expand/config.rs b/frame/support/procedural/src/construct_runtime/expand/config.rs index 02cb6fd065ead..ce3af1bf142c4 100644 --- a/frame/support/procedural/src/construct_runtime/expand/config.rs +++ b/frame/support/procedural/src/construct_runtime/expand/config.rs @@ -100,7 +100,7 @@ pub fn expand_outer_config( } } - impl #scrate::traits::GenesisBuild for RuntimeGenesisConfig { + impl #scrate::traits::RuntimeGenesisBuild for RuntimeGenesisConfig { fn build(&self) { #genesis_build_calls } diff --git a/frame/support/src/traits.rs b/frame/support/src/traits.rs index 3db274c1720c6..845811d95d883 100644 --- a/frame/support/src/traits.rs +++ b/frame/support/src/traits.rs @@ -82,7 +82,7 @@ pub use metadata::{ mod hooks; pub use hooks::{ GenesisBuild, Hooks, IntegrityTest, OnFinalize, OnGenesis, OnIdle, OnInitialize, - OnRuntimeUpgrade, OnTimestampSet, + OnRuntimeUpgrade, OnTimestampSet, RuntimeGenesisBuild, }; pub mod schedule; diff --git a/frame/support/src/traits/hooks.rs b/frame/support/src/traits/hooks.rs index 7dda6624ffe65..d227bc2b331fb 100644 --- a/frame/support/src/traits/hooks.rs +++ b/frame/support/src/traits/hooks.rs @@ -359,6 +359,13 @@ pub trait Hooks { fn integrity_test() {} } +/// A trait to define the build function of a runtime genesis config. +pub trait RuntimeGenesisBuild: Default + sp_runtime::traits::MaybeSerializeDeserialize { + /// Build function allows to put all genesis config keys for each runtime pallet into the + /// storage. + fn build(&self); +} + /// A trait to define the build function of a genesis config, T and I are placeholder for pallet /// trait and pallet instance. pub trait GenesisBuild: Default + sp_runtime::traits::MaybeSerializeDeserialize {