diff --git a/pallets/universal-dividend/src/lib.rs b/pallets/universal-dividend/src/lib.rs index b41e4b245bc7bc0e3e6ff8c4708ea776064a92de..25de8fb027cd88c57244465d9a0292b9c937f591 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 8bea5b1d3aac87e1dbbdc74439615c0af22ba4d5..a753ac163f487a6ac4cad51daac6ebf0432f96f3 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 cf6728e0b911d1c7f980cfaf772a968e9d113781..0e27e3b04375a40448a910f3fa011688e219a390 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 b9d23572036dd5ae23b1393adea35535e5cb0c4e..e950bf47b6b4b42ecc6dde310221066a7e665bd3 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>