Skip to content

Commit 7dba1e5

Browse files
committedJul 12, 2024
bring back genesis config
1 parent aed65c0 commit 7dba1e5

File tree

1 file changed

+19
-7
lines changed
  • pallets/dapp-staking-v3/src

1 file changed

+19
-7
lines changed
 

‎pallets/dapp-staking-v3/src/lib.rs

+19-7
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,6 @@ pub mod pallet {
503503
pub type Safeguard<T: Config> = StorageValue<_, bool, ValueQuery, DefaultSafeguard<T>>;
504504

505505
#[pallet::genesis_config]
506-
#[derive(frame_support::DefaultNoBound, PartialEq)]
507506
pub struct GenesisConfig<T> {
508507
pub reward_portion: Vec<Permill>,
509508
pub slot_distribution: Vec<Permill>,
@@ -513,15 +512,28 @@ pub mod pallet {
513512
pub _config: PhantomData<T>,
514513
}
515514

515+
impl<T: Config> Default for GenesisConfig<T> {
516+
fn default() -> Self {
517+
use sp_std::vec;
518+
let num_tiers = T::NumberOfTiers::get();
519+
Self {
520+
reward_portion: vec![Permill::from_percent(100 / num_tiers); num_tiers as usize],
521+
slot_distribution: vec![Permill::from_percent(100 / num_tiers); num_tiers as usize],
522+
tier_thresholds: (0..num_tiers)
523+
.map(|i| TierThreshold::FixedTvlAmount {
524+
amount: (10 * i).into(),
525+
})
526+
.collect(),
527+
slots_per_tier: vec![100; num_tiers as usize],
528+
safeguard: None,
529+
_config: Default::default(),
530+
}
531+
}
532+
}
533+
516534
#[pallet::genesis_build]
517535
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
518536
fn build(&self) {
519-
if self == &Default::default() {
520-
// Default config is an empty config, no build is needed
521-
// Remove this is default genesis changes
522-
return;
523-
}
524-
525537
// Prepare tier parameters & verify their correctness
526538
let tier_params = TierParameters::<T::NumberOfTiers> {
527539
reward_portion: BoundedVec::<Permill, T::NumberOfTiers>::try_from(

0 commit comments

Comments
 (0)