From e88b9a4be25fb856d936c64c3e6876c90daecdc9 Mon Sep 17 00:00:00 2001 From: bgallois <benjamin@gallois.cc> Date: Wed, 13 Nov 2024 08:22:30 +0100 Subject: [PATCH] move MembersCount --- runtime/common/src/pallets_config.rs | 11 +---------- runtime/common/src/providers.rs | 12 +++++++++++- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/runtime/common/src/pallets_config.rs b/runtime/common/src/pallets_config.rs index b69440907..f9bf0f1ce 100644 --- a/runtime/common/src/pallets_config.rs +++ b/runtime/common/src/pallets_config.rs @@ -176,8 +176,6 @@ macro_rules! pallets_config { type WeightInfo = weights::pallet_balances::WeightInfo<Runtime>; } - pub struct OnChargeTransaction; - parameter_types! { pub Target: Perquintill = Perquintill::from_percent(25); pub MaxMultiplier: sp_runtime::FixedU128 = 10.into(); @@ -411,19 +409,12 @@ macro_rules! pallets_config { // UNIVERSAL DIVIDEND // - pub struct MembersCount; - impl frame_support::pallet_prelude::Get<Balance> for MembersCount { - fn get() -> Balance { - <Membership as sp_membership::traits::MembersCount>::members_count() as Balance - } - } - impl pallet_universal_dividend::Config for Runtime { type Currency = Balances; #[cfg(feature = "runtime-benchmarks")] type IdtyAttr = Identity; type MaxPastReeval = frame_support::traits::ConstU32<160>; - type MembersCount = MembersCount; + type MembersCount = common_runtime::providers::MembersCount<Membership>; type MembersStorage = common_runtime::providers::UdMembersStorage<Runtime>; type MomentIntoBalance = sp_runtime::traits::ConvertInto; type RuntimeEvent = RuntimeEvent; diff --git a/runtime/common/src/providers.rs b/runtime/common/src/providers.rs index 829be1a07..848ebec9a 100644 --- a/runtime/common/src/providers.rs +++ b/runtime/common/src/providers.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>. -use crate::{entities::IdtyData, AccountId, IdtyIndex}; +use crate::{entities::IdtyData, AccountId, Balance, IdtyIndex}; use core::marker::PhantomData; use pallet_universal_dividend::FirstEligibleUd; @@ -116,3 +116,13 @@ macro_rules! impl_benchmark_setup_handler { #[cfg(feature = "runtime-benchmarks")] impl_benchmark_setup_handler!(pallet_membership::SetupBenchmark<<T as pallet_identity::Config>::IdtyIndex, T::AccountId>); + +pub struct MembersCount<T>(PhantomData<T>); +impl<T> frame_support::pallet_prelude::Get<Balance> for MembersCount<T> +where + T: sp_membership::traits::MembersCount, +{ + fn get() -> Balance { + T::members_count() as Balance + } +} -- GitLab