Skip to content
Snippets Groups Projects
Commit 214cc867 authored by Éloïs's avatar Éloïs
Browse files

ref(runtime): move UdAccountsProvider in common part

parent 26c5ce89
Branches
Tags
No related merge requests found
...@@ -23,6 +23,7 @@ pub mod entities; ...@@ -23,6 +23,7 @@ pub mod entities;
pub mod fees; pub mod fees;
pub mod handlers; pub mod handlers;
mod pallets_config; mod pallets_config;
pub mod providers;
pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic; pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;
......
...@@ -146,8 +146,8 @@ macro_rules! pallets_config { ...@@ -146,8 +146,8 @@ macro_rules! pallets_config {
impl pallet_universal_dividend::Config for Runtime { impl pallet_universal_dividend::Config for Runtime {
type Currency = pallet_balances::Pallet<Runtime>; type Currency = pallet_balances::Pallet<Runtime>;
type Event = Event; type Event = Event;
type MembersCount = UdAccountsProvider; type MembersCount = common_runtime::providers::UdAccountsProvider<Runtime>;
type MembersIds = UdAccountsProvider; type MembersIds = common_runtime::providers::UdAccountsProvider<Runtime>;
type SquareMoneyGrowthRate = SquareMoneyGrowthRate; type SquareMoneyGrowthRate = SquareMoneyGrowthRate;
type UdCreationPeriod = UdCreationPeriod; type UdCreationPeriod = UdCreationPeriod;
type UdReevalPeriod = UdReevalPeriod; type UdReevalPeriod = UdReevalPeriod;
......
// 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()
}
}
...@@ -46,7 +46,6 @@ use common_runtime::{ ...@@ -46,7 +46,6 @@ use common_runtime::{
OnRightKeyChangeHandler, OnRightKeyChangeHandler,
}, },
}; };
use frame_support::traits::Get;
use frame_system::EnsureRoot; use frame_system::EnsureRoot;
use pallet_grandpa::fg_primitives; use pallet_grandpa::fg_primitives;
use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList}; use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};
...@@ -146,18 +145,6 @@ common_runtime::pallets_config! { ...@@ -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. // Create the runtime by composing the FRAME pallets that were previously configured.
construct_runtime!( construct_runtime!(
pub enum Runtime where pub enum Runtime where
......
...@@ -45,7 +45,6 @@ use common_runtime::{ ...@@ -45,7 +45,6 @@ use common_runtime::{
OnRightKeyChangeHandler, OnRightKeyChangeHandler,
}, },
}; };
use frame_support::traits::Get;
use frame_system::EnsureRoot; use frame_system::EnsureRoot;
use pallet_grandpa::fg_primitives; use pallet_grandpa::fg_primitives;
use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList}; use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};
...@@ -135,18 +134,6 @@ common_runtime::pallets_config! { ...@@ -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. // Create the runtime by composing the FRAME pallets that were previously configured.
construct_runtime!( construct_runtime!(
pub enum Runtime where pub enum Runtime where
......
...@@ -46,7 +46,6 @@ use common_runtime::{ ...@@ -46,7 +46,6 @@ use common_runtime::{
OnRightKeyChangeHandler, OnRightKeyChangeHandler,
}, },
}; };
use frame_support::traits::Get;
use frame_system::EnsureRoot; use frame_system::EnsureRoot;
use pallet_grandpa::fg_primitives; use pallet_grandpa::fg_primitives;
use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList}; use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};
...@@ -146,18 +145,6 @@ common_runtime::pallets_config! { ...@@ -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. // Create the runtime by composing the FRAME pallets that were previously configured.
construct_runtime!( construct_runtime!(
pub enum Runtime where pub enum Runtime where
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment