From 6d5e6b1d97adab908bf54724a23b88139b93ea03 Mon Sep 17 00:00:00 2001 From: Dmitry Lavrenov Date: Wed, 13 Mar 2024 15:51:16 +0300 Subject: [PATCH] [substrate-apply] pallet-*: frame: Enable GenesisConfig in no_std #14108 --- .../src/lib.rs | 9 +-------- crates/pallet-bioauth/src/lib.rs | 13 +------------ crates/pallet-bootnodes/src/lib.rs | 11 +---------- crates/pallet-evm-accounts-mapping/src/lib.rs | 13 ++----------- crates/pallet-pot/src/lib.rs | 5 ++--- crates/pallet-token-claims/src/lib.rs | 16 +++++----------- 6 files changed, 12 insertions(+), 55 deletions(-) diff --git a/crates/pallet-balanced-currency-swap-bridges-initializer/src/lib.rs b/crates/pallet-balanced-currency-swap-bridges-initializer/src/lib.rs index 3367ff3c0..9bfb210c6 100644 --- a/crates/pallet-balanced-currency-swap-bridges-initializer/src/lib.rs +++ b/crates/pallet-balanced-currency-swap-bridges-initializer/src/lib.rs @@ -113,16 +113,9 @@ pub mod pallet { pub type LastForceRebalanceAskCounter = StorageValue<_, u16, ValueQuery>; #[pallet::genesis_config] + #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig(PhantomData); - // The default value for the genesis config type. - #[cfg(feature = "std")] - impl Default for GenesisConfig { - fn default() -> Self { - Self(PhantomData) - } - } - // The build of genesis for the pallet. #[pallet::genesis_build] impl GenesisBuild for GenesisConfig { diff --git a/crates/pallet-bioauth/src/lib.rs b/crates/pallet-bioauth/src/lib.rs index eb3662dde..c2282188b 100644 --- a/crates/pallet-bioauth/src/lib.rs +++ b/crates/pallet-bioauth/src/lib.rs @@ -298,6 +298,7 @@ pub mod pallet { >; #[pallet::genesis_config] + #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig { pub robonode_public_key: T::RobonodePublicKey, pub consumed_auth_ticket_nonces: BoundedVec, @@ -305,18 +306,6 @@ pub mod pallet { BoundedVec, T::MaxAuthentications>, } - // The default value for the genesis config type. - #[cfg(feature = "std")] - impl Default for GenesisConfig { - 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 GenesisBuild for GenesisConfig { diff --git a/crates/pallet-bootnodes/src/lib.rs b/crates/pallet-bootnodes/src/lib.rs index 91609c14a..4c239ab6e 100644 --- a/crates/pallet-bootnodes/src/lib.rs +++ b/crates/pallet-bootnodes/src/lib.rs @@ -38,21 +38,12 @@ pub mod pallet { StorageValue<_, BoundedVec, ValueQuery>; #[pallet::genesis_config] + #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig { /// The list of bootnodes to use. pub bootnodes: BoundedVec, } - // The default value for the genesis config type. - #[cfg(feature = "std")] - impl Default for GenesisConfig { - fn default() -> Self { - Self { - bootnodes: Default::default(), - } - } - } - // The build of genesis for the pallet. #[pallet::genesis_build] impl GenesisBuild for GenesisConfig { diff --git a/crates/pallet-evm-accounts-mapping/src/lib.rs b/crates/pallet-evm-accounts-mapping/src/lib.rs index 022eb9222..ec989d167 100644 --- a/crates/pallet-evm-accounts-mapping/src/lib.rs +++ b/crates/pallet-evm-accounts-mapping/src/lib.rs @@ -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}; @@ -92,21 +92,12 @@ pub mod pallet { pub struct Pallet(_); #[pallet::genesis_config] + #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig { /// The mappings to set at genesis. pub mappings: Vec<(T::AccountId, EthereumAddress)>, } - // The default value for the genesis config type. - #[cfg(feature = "std")] - impl Default for GenesisConfig { - fn default() -> Self { - Self { - mappings: Default::default(), - } - } - } - #[pallet::genesis_build] impl GenesisBuild for GenesisConfig { fn build(&self) { diff --git a/crates/pallet-pot/src/lib.rs b/crates/pallet-pot/src/lib.rs index 486738446..92adbcb92 100644 --- a/crates/pallet-pot/src/lib.rs +++ b/crates/pallet-pot/src/lib.rs @@ -33,8 +33,8 @@ pub type NegativeImbalanceOf = pub type CreditOf = Credit<>::AccountId, >::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 { /// The state of the pot account is not checked at genesis. Unchecked, @@ -117,7 +117,6 @@ pub mod pallet { pub initial_state: InitialState>, } - #[cfg(feature = "std")] impl, I: 'static> Default for GenesisConfig { fn default() -> Self { Self { diff --git a/crates/pallet-token-claims/src/lib.rs b/crates/pallet-token-claims/src/lib.rs index db93c99af..5c4273dea 100644 --- a/crates/pallet-token-claims/src/lib.rs +++ b/crates/pallet-token-claims/src/lib.rs @@ -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::*; @@ -105,6 +108,7 @@ pub mod pallet { pub type TotalClaimable = StorageValue<_, BalanceOf, ValueQuery>; #[pallet::genesis_config] + #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig { /// The claims to initialize at genesis. pub claims: Vec<(EthereumAddress, ClaimInfoOf)>, @@ -115,16 +119,6 @@ pub mod pallet { pub total_claimable: Option>, } - #[cfg(feature = "std")] - impl Default for GenesisConfig { - fn default() -> Self { - GenesisConfig { - claims: Default::default(), - total_claimable: None, - } - } - } - #[pallet::genesis_build] impl GenesisBuild for GenesisConfig { fn build(&self) {