Attribute Macro frame_support::pallet_macros::genesis_build
source · #[genesis_build]
Expand description
Allows you to define how the state of your pallet at genesis is built. This
takes as input the GenesisConfig
type (as self
) and constructs the pallet’s initial
state.
The fields of the GenesisConfig
can in turn be populated by the chain-spec.
§Example
#[frame_support::pallet]
pub mod pallet {
#[pallet::genesis_config]
#[derive(frame_support::DefaultNoBound)]
pub struct GenesisConfig<T: Config> {
foo: Vec<T::AccountId>
}
#[pallet::genesis_build]
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
fn build(&self) {
// use &self to access fields.
let foo = &self.foo;
todo!()
}
}
}
§Former Usage
Prior to https://github.com/paritytech/substrate/pull/14306, the following syntax was used. This is deprecated and will soon be removed.
#[frame_support::pallet]
pub mod pallet {
#[pallet::genesis_config]
#[derive(frame_support::DefaultNoBound)]
pub struct GenesisConfig<T: Config> {
foo: Vec<T::AccountId>
}
#[pallet::genesis_build]
impl<T: Config> GenesisBuild<T> for GenesisConfig<T> {
fn build(&self) {
todo!()
}
}
}
Documentation for this macro can be found at frame_support::pallet_macros::genesis_build
.