Skip to content

Commit

Permalink
[substrate-apply] pallet-*: frame: Enable GenesisConfig in no_std #14108
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrylavrenov committed Oct 28, 2024
1 parent d1b39c2 commit 6d5e6b1
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,9 @@ pub mod pallet {
pub type LastForceRebalanceAskCounter<T: Config> = StorageValue<_, u16, ValueQuery>;

#[pallet::genesis_config]
#[derive(frame_support::DefaultNoBound)]
pub struct GenesisConfig<T: Config>(PhantomData<T>);

// The default value for the genesis config type.
#[cfg(feature = "std")]
impl<T: Config> Default for GenesisConfig<T> {
fn default() -> Self {
Self(PhantomData)
}
}

// The build of genesis for the pallet.
#[pallet::genesis_build]
impl<T: Config> GenesisBuild<T> for GenesisConfig<T> {
Expand Down
13 changes: 1 addition & 12 deletions crates/pallet-bioauth/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,25 +298,14 @@ pub mod pallet {
>;

#[pallet::genesis_config]
#[derive(frame_support::DefaultNoBound)]
pub struct GenesisConfig<T: Config> {
pub robonode_public_key: T::RobonodePublicKey,
pub consumed_auth_ticket_nonces: BoundedVec<BoundedAuthTicketNonce, T::MaxNonces>,
pub active_authentications:
BoundedVec<Authentication<T::ValidatorPublicKey, T::Moment>, T::MaxAuthentications>,
}

// The default value for the genesis config type.
#[cfg(feature = "std")]
impl<T: Config> Default for GenesisConfig<T> {
fn default() -> Self {
Self {
robonode_public_key: Default::default(),
consumed_auth_ticket_nonces: Default::default(),
active_authentications: Default::default(),
}
}
}

// The build of genesis for the pallet.
#[pallet::genesis_build]
impl<T: Config> GenesisBuild<T> for GenesisConfig<T> {
Expand Down
11 changes: 1 addition & 10 deletions crates/pallet-bootnodes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,12 @@ pub mod pallet {
StorageValue<_, BoundedVec<T::BootnodeId, T::MaxBootnodes>, ValueQuery>;

#[pallet::genesis_config]
#[derive(frame_support::DefaultNoBound)]
pub struct GenesisConfig<T: Config> {
/// The list of bootnodes to use.
pub bootnodes: BoundedVec<T::BootnodeId, T::MaxBootnodes>,
}

// The default value for the genesis config type.
#[cfg(feature = "std")]
impl<T: Config> Default for GenesisConfig<T> {
fn default() -> Self {
Self {
bootnodes: Default::default(),
}
}
}

// The build of genesis for the pallet.
#[pallet::genesis_build]
impl<T: Config> GenesisBuild<T> for GenesisConfig<T> {
Expand Down
13 changes: 2 additions & 11 deletions crates/pallet-evm-accounts-mapping/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#![cfg_attr(not(feature = "std"), no_std)]

use frame_support::pallet_prelude::*;
use frame_support::{inherent::Vec, pallet_prelude::*};
use frame_system::pallet_prelude::*;
pub use pallet::*;
use primitives_ethereum::{EcdsaSignature, EthereumAddress};
Expand Down Expand Up @@ -92,21 +92,12 @@ pub mod pallet {
pub struct Pallet<T>(_);

#[pallet::genesis_config]
#[derive(frame_support::DefaultNoBound)]
pub struct GenesisConfig<T: Config> {
/// The mappings to set at genesis.
pub mappings: Vec<(T::AccountId, EthereumAddress)>,
}

// The default value for the genesis config type.
#[cfg(feature = "std")]
impl<T: Config> Default for GenesisConfig<T> {
fn default() -> Self {
Self {
mappings: Default::default(),
}
}
}

#[pallet::genesis_build]
impl<T: Config> GenesisBuild<T> for GenesisConfig<T> {
fn build(&self) {
Expand Down
5 changes: 2 additions & 3 deletions crates/pallet-pot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ pub type NegativeImbalanceOf<T, I = ()> =
pub type CreditOf<T, I = ()> = Credit<<T as Config<I>>::AccountId, <T as Config<I>>::Currency>;

/// The initial state of the pot, for use in genesis.
#[cfg(feature = "std")]
#[derive(Debug, serde::Serialize, serde::Deserialize)]
#[derive(Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum InitialState<Balance> {
/// The state of the pot account is not checked at genesis.
Unchecked,
Expand Down Expand Up @@ -117,7 +117,6 @@ pub mod pallet {
pub initial_state: InitialState<BalanceOf<T, I>>,
}

#[cfg(feature = "std")]
impl<T: Config<I>, I: 'static> Default for GenesisConfig<T, I> {
fn default() -> Self {
Self {
Expand Down
16 changes: 5 additions & 11 deletions crates/pallet-token-claims/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@

#![cfg_attr(not(feature = "std"), no_std)]

use frame_support::traits::{Currency, StorageVersion};
use frame_support::{
inherent::Vec,
traits::{Currency, StorageVersion},
};
pub use weights::*;

pub use self::pallet::*;
Expand Down Expand Up @@ -105,6 +108,7 @@ pub mod pallet {
pub type TotalClaimable<T> = StorageValue<_, BalanceOf<T>, ValueQuery>;

#[pallet::genesis_config]
#[derive(frame_support::DefaultNoBound)]
pub struct GenesisConfig<T: Config> {
/// The claims to initialize at genesis.
pub claims: Vec<(EthereumAddress, ClaimInfoOf<T>)>,
Expand All @@ -115,16 +119,6 @@ pub mod pallet {
pub total_claimable: Option<BalanceOf<T>>,
}

#[cfg(feature = "std")]
impl<T: Config> Default for GenesisConfig<T> {
fn default() -> Self {
GenesisConfig {
claims: Default::default(),
total_claimable: None,
}
}
}

#[pallet::genesis_build]
impl<T: Config> GenesisBuild<T> for GenesisConfig<T> {
fn build(&self) {
Expand Down

0 comments on commit 6d5e6b1

Please sign in to comment.