mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 06:21:11 +00:00
pallets: implement Default for GenesisConfig in no_std (#2624)
* pallets: implement Default for GenesisConfig in no_std This change is follow-up of: https://github.com/paritytech/substrate/pull/14108 It is a step towards: https://github.com/paritytech/substrate/issues/13334 * ".git/.scripts/commands/fmt/fmt.sh" * update lockfile for {"substrate", "polkadot"} --------- Co-authored-by: command-bot <>
This commit is contained in:
committed by
GitHub
parent
972814a2be
commit
4909cbb5b1
@@ -88,7 +88,7 @@ pub mod pallet {
|
||||
Currency, EnsureOrigin, ExistenceRequirement::KeepAlive, ReservableCurrency,
|
||||
ValidatorRegistration,
|
||||
},
|
||||
BoundedVec, PalletId,
|
||||
BoundedVec, DefaultNoBound, PalletId,
|
||||
};
|
||||
use frame_system::{pallet_prelude::*, Config as SystemConfig};
|
||||
use pallet_session::SessionManager;
|
||||
@@ -203,28 +203,20 @@ pub mod pallet {
|
||||
pub type CandidacyBond<T> = StorageValue<_, BalanceOf<T>, ValueQuery>;
|
||||
|
||||
#[pallet::genesis_config]
|
||||
#[derive(DefaultNoBound)]
|
||||
pub struct GenesisConfig<T: Config> {
|
||||
pub invulnerables: Vec<T::AccountId>,
|
||||
pub candidacy_bond: BalanceOf<T>,
|
||||
pub desired_candidates: u32,
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl<T: Config> Default for GenesisConfig<T> {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
invulnerables: Default::default(),
|
||||
candidacy_bond: Default::default(),
|
||||
desired_candidates: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[pallet::genesis_build]
|
||||
impl<T: Config> GenesisBuild<T> for GenesisConfig<T> {
|
||||
fn build(&self) {
|
||||
let duplicate_invulnerables =
|
||||
self.invulnerables.iter().collect::<std::collections::BTreeSet<_>>();
|
||||
let duplicate_invulnerables = self
|
||||
.invulnerables
|
||||
.iter()
|
||||
.collect::<sp_std::collections::btree_set::BTreeSet<_>>();
|
||||
assert!(
|
||||
duplicate_invulnerables.len() == self.invulnerables.len(),
|
||||
"duplicate invulnerables in genesis."
|
||||
|
||||
Reference in New Issue
Block a user