Skip to content

Commit

Permalink
add genesis config for ismp-parachain (#32)
Browse files Browse the repository at this point in the history
* add genesis config for ismp-parachain

* remove alloc import

* cargo fmt
  • Loading branch information
seunlanlege authored Apr 22, 2023
1 parent ebf001f commit e861921
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion parachain-consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub use pallet::*;

#[frame_support::pallet]
pub mod pallet {
use super::*;
use cumulus_primitives_core::relay_chain;
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
Expand All @@ -36,7 +37,9 @@ pub mod pallet {
pub struct Pallet<T>(_);

#[pallet::config]
pub trait Config: frame_system::Config + parachain_system::Config {
pub trait Config:
frame_system::Config + pallet_ismp::Config + parachain_system::Config
{
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
}

Expand Down Expand Up @@ -64,6 +67,27 @@ pub mod pallet {
}
}
}

#[pallet::genesis_config]
pub struct GenesisConfig;

#[cfg(feature = "std")]
impl Default for GenesisConfig {
fn default() -> Self {
GenesisConfig
}
}

#[pallet::genesis_build]
impl<T: Config> GenesisBuild<T> for GenesisConfig {
fn build(&self) {
// insert empty bytes
pallet_ismp::ConsensusStates::<T>::insert(
consensus::PARACHAIN_CONSENSUS_ID,
Vec::<u8>::new(),
);
}
}
}

/// Interface that exposes the relay chain state roots.
Expand Down

0 comments on commit e861921

Please sign in to comment.