From 0d8ad49cec6dac2c05c235ef39918d92f6a00f76 Mon Sep 17 00:00:00 2001 From: bgallois <benjamin@gallois.cc> Date: Tue, 19 Dec 2023 14:19:32 +0100 Subject: [PATCH] fix #124 --- pallets/universal-dividend/src/lib.rs | 4 --- pallets/universal-dividend/src/mock.rs | 18 ------------- runtime/common/src/pallets_config.rs | 1 - runtime/common/src/providers.rs | 37 -------------------------- 4 files changed, 60 deletions(-) diff --git a/pallets/universal-dividend/src/lib.rs b/pallets/universal-dividend/src/lib.rs index b41e4b245..25de8fb02 100644 --- a/pallets/universal-dividend/src/lib.rs +++ b/pallets/universal-dividend/src/lib.rs @@ -43,7 +43,6 @@ pub mod pallet { use frame_support::traits::{StorageVersion, StoredMap}; use frame_system::pallet_prelude::*; use sp_runtime::traits::Convert; - use sp_std::vec::Vec; pub type BalanceOf<T> = <<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance; @@ -69,9 +68,6 @@ pub mod pallet { type MembersCount: Get<BalanceOf<Self>>; /// Somethings that must provide the list of accounts ids allowed to create the universal dividend type MembersStorage: frame_support::traits::StoredMap<Self::AccountId, FirstEligibleUd>; - /// An iterator over all members - type MembersStorageIter: From<Option<Vec<u8>>> - + Iterator<Item = (Self::AccountId, FirstEligibleUd)>; /// Because this pallet emits events, it depends on the runtime's definition of an event. type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>; #[pallet::constant] diff --git a/pallets/universal-dividend/src/mock.rs b/pallets/universal-dividend/src/mock.rs index 8bea5b1d3..a753ac163 100644 --- a/pallets/universal-dividend/src/mock.rs +++ b/pallets/universal-dividend/src/mock.rs @@ -139,23 +139,6 @@ impl frame_support::traits::StoredMap<u32, FirstEligibleUd> for TestMembersStora Ok(result) } } -pub struct TestMembersStorageIter(frame_support::storage::PrefixIterator<(u32, FirstEligibleUd)>); -impl From<Option<Vec<u8>>> for TestMembersStorageIter { - fn from(maybe_key: Option<Vec<u8>>) -> Self { - let mut iter = crate::TestMembers::<Test>::iter(); - if let Some(key) = maybe_key { - iter.set_last_raw_key(key); - } - Self(iter) - } -} -impl Iterator for TestMembersStorageIter { - type Item = (u32, FirstEligibleUd); - - fn next(&mut self) -> Option<Self::Item> { - self.0.next() - } -} impl pallet_universal_dividend::Config for Test { type MomentIntoBalance = sp_runtime::traits::ConvertInto; @@ -163,7 +146,6 @@ impl pallet_universal_dividend::Config for Test { type MaxPastReeval = frame_support::traits::ConstU32<2>; type MembersCount = MembersCount; type MembersStorage = TestMembersStorage; - type MembersStorageIter = TestMembersStorageIter; type RuntimeEvent = RuntimeEvent; type SquareMoneyGrowthRate = SquareMoneyGrowthRate; type UdCreationPeriod = UdCreationPeriod; diff --git a/runtime/common/src/pallets_config.rs b/runtime/common/src/pallets_config.rs index cf6728e0b..0e27e3b04 100644 --- a/runtime/common/src/pallets_config.rs +++ b/runtime/common/src/pallets_config.rs @@ -439,7 +439,6 @@ macro_rules! pallets_config { type MaxPastReeval = frame_support::traits::ConstU32<160>; type MembersCount = MembersCount; type MembersStorage = common_runtime::providers::UdMembersStorage<Runtime>; - type MembersStorageIter = common_runtime::providers::UdMembersStorageIter<Runtime>; type SquareMoneyGrowthRate = SquareMoneyGrowthRate; type UdCreationPeriod = UdCreationPeriod; type UdReevalPeriod = UdReevalPeriod; diff --git a/runtime/common/src/providers.rs b/runtime/common/src/providers.rs index b9d235720..e950bf47b 100644 --- a/runtime/common/src/providers.rs +++ b/runtime/common/src/providers.rs @@ -18,8 +18,6 @@ use crate::{entities::IdtyData, AccountId, IdtyIndex}; use core::marker::PhantomData; use pallet_universal_dividend::FirstEligibleUd; use sp_runtime::DispatchError; -use sp_std::boxed::Box; -use sp_std::vec::Vec; pub struct IdentityAccountIdProvider<Runtime>(PhantomData<Runtime>); @@ -73,41 +71,6 @@ where } } -#[allow(clippy::type_complexity)] -pub struct UdMembersStorageIter<T: pallet_identity::Config>( - Box<dyn Iterator<Item = pallet_identity::IdtyValue<T::BlockNumber, T::AccountId, T::IdtyData>>>, - PhantomData<T>, -); - -impl<T: pallet_identity::Config> From<Option<Vec<u8>>> for UdMembersStorageIter<T> { - fn from(maybe_key: Option<Vec<u8>>) -> Self { - let mut iter = pallet_identity::Identities::<T>::iter_values(); - if let Some(key) = maybe_key { - iter.set_last_raw_key(key); - } - Self(Box::new(iter), PhantomData) - } -} - -impl<T> Iterator for UdMembersStorageIter<T> -where - T: pallet_identity::Config, - T::IdtyData: Into<FirstEligibleUd>, -{ - type Item = (T::AccountId, FirstEligibleUd); - - fn next(&mut self) -> Option<Self::Item> { - if let Some(pallet_identity::IdtyValue { - owner_key, data, .. - }) = self.0.next() - { - Some((owner_key, data.into())) - } else { - None - } - } -} - pub struct MainWotIsDistanceOk<T>(PhantomData<T>); impl<T> pallet_duniter_wot::traits::IsDistanceOk<<T as pallet_identity::Config>::IdtyIndex> -- GitLab