diff --git a/runtime/common/src/lib.rs b/runtime/common/src/lib.rs index c48bc445826e3b16a8ee2476766eb07d268ca532..d1bde64f5cbbdaee5e9a9dfc2f3a0caa676b1081 100644 --- a/runtime/common/src/lib.rs +++ b/runtime/common/src/lib.rs @@ -23,6 +23,7 @@ pub mod entities; pub mod fees; pub mod handlers; mod pallets_config; +pub mod providers; pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic; diff --git a/runtime/common/src/pallets_config.rs b/runtime/common/src/pallets_config.rs index 3600fdbc7597c91f23d910fbf53bb0eb8b37103a..07010a1f7705445ac2101bd8183ef85d7e92ff4d 100644 --- a/runtime/common/src/pallets_config.rs +++ b/runtime/common/src/pallets_config.rs @@ -146,8 +146,8 @@ macro_rules! pallets_config { impl pallet_universal_dividend::Config for Runtime { type Currency = pallet_balances::Pallet<Runtime>; type Event = Event; - type MembersCount = UdAccountsProvider; - type MembersIds = UdAccountsProvider; + type MembersCount = common_runtime::providers::UdAccountsProvider<Runtime>; + type MembersIds = common_runtime::providers::UdAccountsProvider<Runtime>; type SquareMoneyGrowthRate = SquareMoneyGrowthRate; type UdCreationPeriod = UdCreationPeriod; type UdReevalPeriod = UdReevalPeriod; diff --git a/runtime/common/src/providers.rs b/runtime/common/src/providers.rs new file mode 100644 index 0000000000000000000000000000000000000000..1f49810e9455fefa28402692790c9259812d7f49 --- /dev/null +++ b/runtime/common/src/providers.rs @@ -0,0 +1,33 @@ +// Copyright 2021 Axiom-Team +// +// This file is part of Substrate-Libre-Currency. +// +// Substrate-Libre-Currency is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, version 3 of the License. +// +// Substrate-Libre-Currency is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with Substrate-Libre-Currency. If not, see <https://www.gnu.org/licenses/>. + +use crate::AccountId; +use frame_support::traits::Get; +use sp_std::vec::Vec; + +pub struct UdAccountsProvider<Runtime>(core::marker::PhantomData<Runtime>); +impl<Runtime: pallet_ud_accounts_storage::Config> Get<u64> for UdAccountsProvider<Runtime> { + fn get() -> u64 { + <pallet_ud_accounts_storage::Pallet<Runtime>>::ud_accounts_count() + } +} +impl<Runtime: frame_system::Config<AccountId = AccountId> + pallet_ud_accounts_storage::Config> + Get<Vec<AccountId>> for UdAccountsProvider<Runtime> +{ + fn get() -> Vec<AccountId> { + <pallet_ud_accounts_storage::Pallet<Runtime>>::account_list() + } +} diff --git a/runtime/g1/src/lib.rs b/runtime/g1/src/lib.rs index a4699e1a10fca22b50f4216af9bab6e215531cf5..2b756140a28125b002667951582426d54adc8103 100644 --- a/runtime/g1/src/lib.rs +++ b/runtime/g1/src/lib.rs @@ -46,7 +46,6 @@ use common_runtime::{ OnRightKeyChangeHandler, }, }; -use frame_support::traits::Get; use frame_system::EnsureRoot; use pallet_grandpa::fg_primitives; use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList}; @@ -146,18 +145,6 @@ common_runtime::pallets_config! { } } -pub struct UdAccountsProvider; -impl Get<u64> for UdAccountsProvider { - fn get() -> u64 { - UdAccountsStorage::ud_accounts_count() - } -} -impl Get<Vec<AccountId>> for UdAccountsProvider { - fn get() -> Vec<AccountId> { - UdAccountsStorage::account_list() - } -} - // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( pub enum Runtime where diff --git a/runtime/gdev/src/lib.rs b/runtime/gdev/src/lib.rs index 0e9c3c9d60d2de78193dc54b80a714c0ddfc5d64..cbe02cce4cb25a9619b44001131a5c20731e3d62 100644 --- a/runtime/gdev/src/lib.rs +++ b/runtime/gdev/src/lib.rs @@ -45,7 +45,6 @@ use common_runtime::{ OnRightKeyChangeHandler, }, }; -use frame_support::traits::Get; use frame_system::EnsureRoot; use pallet_grandpa::fg_primitives; use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList}; @@ -135,18 +134,6 @@ common_runtime::pallets_config! { } } -pub struct UdAccountsProvider; -impl Get<u64> for UdAccountsProvider { - fn get() -> u64 { - UdAccountsStorage::ud_accounts_count() - } -} -impl Get<Vec<AccountId>> for UdAccountsProvider { - fn get() -> Vec<AccountId> { - UdAccountsStorage::account_list() - } -} - // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( pub enum Runtime where diff --git a/runtime/gtest/src/lib.rs b/runtime/gtest/src/lib.rs index 2c32969409e376b7db7e400c2c46f3e05a0f4030..226c258f79d06b2a2d17473ff4cc9201ea102131 100644 --- a/runtime/gtest/src/lib.rs +++ b/runtime/gtest/src/lib.rs @@ -46,7 +46,6 @@ use common_runtime::{ OnRightKeyChangeHandler, }, }; -use frame_support::traits::Get; use frame_system::EnsureRoot; use pallet_grandpa::fg_primitives; use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList}; @@ -146,18 +145,6 @@ common_runtime::pallets_config! { } } -pub struct UdAccountsProvider; -impl Get<u64> for UdAccountsProvider { - fn get() -> u64 { - UdAccountsStorage::ud_accounts_count() - } -} -impl Get<Vec<AccountId>> for UdAccountsProvider { - fn get() -> Vec<AccountId> { - UdAccountsStorage::account_list() - } -} - // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( pub enum Runtime where