diff --git a/.vscode/launch.json b/.vscode/launch.json index 23b696a3d50a152fb38f1405c89a5f1183a0f3cb..3fb767daceef457fbfeab501aea8b9c4e0bbabd1 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -88,25 +88,6 @@ "args": [], "cwd": "${workspaceFolder}" }, - { - "type": "lldb", - "request": "launch", - "name": "Debug unit tests in library 'pallet-ud-accounts-storage'", - "cargo": { - "args": [ - "test", - "--no-run", - "--lib", - "--package=pallet-ud-accounts-storage" - ], - "filter": { - "name": "pallet-ud-accounts-storage", - "kind": "lib" - } - }, - "args": [], - "cwd": "${workspaceFolder}" - }, { "type": "lldb", "request": "launch", diff --git a/Cargo.lock b/Cargo.lock index fb1b1b03ef6780a8a447945f607c539396d65766..2bb67beb80720c6f4f902c553540dbc19506c90f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -895,7 +895,6 @@ dependencies = [ "pallet-session", "pallet-timestamp", "pallet-treasury", - "pallet-ud-accounts-storage", "pallet-universal-dividend", "pallet-upgrade-origin", "parity-scale-codec", @@ -2325,7 +2324,6 @@ dependencies = [ "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", "pallet-treasury", - "pallet-ud-accounts-storage", "pallet-universal-dividend", "pallet-upgrade-origin", "pallet-utility", @@ -2394,7 +2392,6 @@ dependencies = [ "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", "pallet-treasury", - "pallet-ud-accounts-storage", "pallet-universal-dividend", "pallet-upgrade-origin", "pallet-utility", @@ -2666,7 +2663,6 @@ dependencies = [ "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", "pallet-treasury", - "pallet-ud-accounts-storage", "pallet-universal-dividend", "pallet-upgrade-origin", "pallet-utility", @@ -5501,23 +5497,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "pallet-ud-accounts-storage" -version = "3.0.0" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "pallet-balances", - "parity-scale-codec", - "scale-info", - "serde", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - [[package]] name = "pallet-universal-dividend" version = "3.0.0" diff --git a/Cargo.toml b/Cargo.toml index b054d2a4e0f999b1a4ecfa4b3ce8d4993e63001b..ae17782bb5ae07e5992e8bfdadae227bf9dd0209 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -131,7 +131,6 @@ members = [ 'pallets/identity', 'pallets/membership', 'pallets/authority-members', - 'pallets/ud-accounts-storage', 'pallets/universal-dividend', 'pallets/upgrade-origin', 'primitives/membership', diff --git a/node/src/chain_spec/gdev.rs b/node/src/chain_spec/gdev.rs index 29474919483db60f5df72e37620a8cc599c0964d..52bea218a5c48721aba9e036bd8989ea0413b950 100644 --- a/node/src/chain_spec/gdev.rs +++ b/node/src/chain_spec/gdev.rs @@ -21,7 +21,7 @@ use gdev_runtime::{ opaque::SessionKeys, AccountConfig, AccountId, AuthorityMembersConfig, BabeConfig, BalancesConfig, CertConfig, GenesisConfig, IdentityConfig, ImOnlineId, MembershipConfig, ParametersConfig, SessionConfig, SmithsCertConfig, SmithsMembershipConfig, SudoConfig, - SystemConfig, UdAccountsStorageConfig, UniversalDividendConfig, WASM_BINARY, + SystemConfig, UniversalDividendConfig, WASM_BINARY, }; use sc_service::ChainType; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; @@ -417,9 +417,6 @@ fn gen_genesis_for_local_chain( certs_by_issuer: clique_wot(initial_smiths_len, smith_cert_validity_period), }, smiths_collective: Default::default(), - ud_accounts_storage: UdAccountsStorageConfig { - ud_accounts: initial_identities.values().cloned().collect(), - }, universal_dividend: UniversalDividendConfig { first_reeval: 100, first_ud, @@ -467,7 +464,6 @@ fn genesis_data_to_gdev_genesis_conf( smiths_certs_by_issuer, smiths_memberships, sudo_key, - ud_accounts, } = genesis_data; gdev_runtime::GenesisConfig { @@ -525,7 +521,6 @@ fn genesis_data_to_gdev_genesis_conf( memberships: smiths_memberships, }, smiths_collective: Default::default(), - ud_accounts_storage: UdAccountsStorageConfig { ud_accounts }, universal_dividend: UniversalDividendConfig { first_reeval: first_ud_reeval, first_ud, diff --git a/node/src/chain_spec/gen_genesis_data.rs b/node/src/chain_spec/gen_genesis_data.rs index 437f691fe87f5e8441c8b741227e3b0f6f44911c..d9c66c76adda7dd09671cf6febf843d32621f768 100644 --- a/node/src/chain_spec/gen_genesis_data.rs +++ b/node/src/chain_spec/gen_genesis_data.rs @@ -17,7 +17,7 @@ use common_runtime::*; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use sp_core::{blake2_256, Decode, Encode, H256}; -use std::collections::{BTreeMap, BTreeSet}; +use std::collections::BTreeMap; type MembershipData = sp_membership::MembershipData<u32>; @@ -38,7 +38,6 @@ pub struct GenesisData<Parameters: DeserializeOwned, SessionKeys: Decode> { pub smiths_certs_by_issuer: BTreeMap<u32, BTreeMap<u32, u32>>, pub smiths_memberships: BTreeMap<u32, MembershipData>, pub sudo_key: Option<AccountId>, - pub ud_accounts: BTreeSet<AccountId>, } #[derive(Default)] @@ -151,7 +150,6 @@ where let mut initial_monetary_mass = 0; let mut memberships = BTreeMap::new(); //let mut total_dust = 0; - let mut ud_accounts = BTreeSet::new(); // SIMPLE WALLETS // @@ -194,7 +192,6 @@ where // We must count the money under the existential deposit because what we count is // the monetary mass created (for the revaluation of the DU) initial_monetary_mass += identity.balance; - ud_accounts.insert(identity.pubkey.clone()); // Wot identities_.push((idty_name.clone(), identity.pubkey.clone())); @@ -329,7 +326,6 @@ where smiths_certs_by_issuer, smiths_memberships, sudo_key, - ud_accounts, }; Ok(f(genesis_data)) diff --git a/pallets/ud-accounts-storage/Cargo.toml b/pallets/ud-accounts-storage/Cargo.toml deleted file mode 100644 index 3a7dc7135c46ba5cefb21c64428b607e7bce6512..0000000000000000000000000000000000000000 --- a/pallets/ud-accounts-storage/Cargo.toml +++ /dev/null @@ -1,83 +0,0 @@ -[package] -authors = ['librelois <c@elo.tf>'] -description = 'FRAME pallet universal dividend accounts storage.' -edition = '2018' -homepage = 'https://substrate.dev' -license = 'AGPL-3.0' -name = 'pallet-ud-accounts-storage' -readme = 'README.md' -repository = 'https://git.duniter.org/nodes/rust/duniter-v2s' -version = '3.0.0' - -[features] -default = ['std'] -runtime-benchmarks = ['frame-benchmarking'] -std = [ - 'codec/std', - 'frame-support/std', - 'frame-system/std', - 'frame-benchmarking/std', - "sp-std/std", -] -try-runtime = ['frame-support/try-runtime'] - -[dependencies] - -# substrate -scale-info = { version = "1.0", default-features = false, features = ["derive"] } - -[dependencies.codec] -default-features = false -features = ['derive'] -package = 'parity-scale-codec' -version = '2.3.1' - -[dependencies.frame-benchmarking] -default-features = false -git = 'https://github.com/librelois/substrate.git' -optional = true -branch = 'duniter-monthly-2022-02' - -[dependencies.frame-support] -default-features = false -git = 'https://github.com/librelois/substrate.git' -branch = 'duniter-monthly-2022-02' - -[dependencies.frame-system] -default-features = false -git = 'https://github.com/librelois/substrate.git' -branch = 'duniter-monthly-2022-02' - -[dependencies.sp-std] -default-features = false -git = 'https://github.com/librelois/substrate.git' -branch = 'duniter-monthly-2022-02' - -### DOC ### - -[package.metadata.docs.rs] -targets = ['x86_64-unknown-linux-gnu'] -[dev-dependencies.serde] -version = '1.0.119' - -### DEV ### - -[dev-dependencies.pallet-balances] -default-features = false -git = 'https://github.com/librelois/substrate.git' -branch = 'duniter-monthly-2022-02' - -[dev-dependencies.sp-core] -default-features = false -git = 'https://github.com/librelois/substrate.git' -branch = 'duniter-monthly-2022-02' - -[dev-dependencies.sp-io] -default-features = false -git = 'https://github.com/librelois/substrate.git' -branch = 'duniter-monthly-2022-02' - -[dev-dependencies.sp-runtime] -default-features = false -git = 'https://github.com/librelois/substrate.git' -branch = 'duniter-monthly-2022-02' diff --git a/pallets/ud-accounts-storage/src/lib.rs b/pallets/ud-accounts-storage/src/lib.rs deleted file mode 100644 index d73c89fed2e50db5a6d8d60d5085e132fe3ade01..0000000000000000000000000000000000000000 --- a/pallets/ud-accounts-storage/src/lib.rs +++ /dev/null @@ -1,155 +0,0 @@ -// 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/>. - -#![cfg_attr(not(feature = "std"), no_std)] -#![allow(clippy::unused_unit)] - -pub use pallet::*; - -/*#[cfg(test)] -mod mock; - -#[cfg(test)] -mod tests; - -#[cfg(feature = "runtime-benchmarks")] -mod benchmarking;*/ - -use sp_std::prelude::*; - -#[frame_support::pallet] -pub mod pallet { - use super::*; - use frame_support::pallet_prelude::*; - use frame_support::traits::StorageVersion; - - /// The current storage version. - const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); - - #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] - #[pallet::storage_version(STORAGE_VERSION)] - #[pallet::without_storage_info] - pub struct Pallet<T>(_); - - // CONFIG // - - #[pallet::config] - pub trait Config: frame_system::Config {} - - // STORAGE // - - #[pallet::storage] - #[pallet::getter(fn ud_accounts)] - pub type UdAccounts<T: Config> = - CountedStorageMap<_, Blake2_128Concat, T::AccountId, (), ValueQuery>; - - // GENESIS // - - #[pallet::genesis_config] - pub struct GenesisConfig<T: Config> { - pub ud_accounts: sp_std::collections::btree_set::BTreeSet<T::AccountId>, - } - - #[cfg(feature = "std")] - impl<T: Config> Default for GenesisConfig<T> { - fn default() -> Self { - Self { - ud_accounts: Default::default(), - } - } - } - - #[pallet::genesis_build] - impl<T: Config> GenesisBuild<T> for GenesisConfig<T> { - fn build(&self) { - for account in &self.ud_accounts { - <UdAccounts<T>>::insert(account, ()); - } - } - } - - // PUBLIC FUNCTIONS // - - impl<T: Config> Pallet<T> { - pub fn accounts_len() -> u32 { - <UdAccounts<T>>::count() - } - pub fn accounts_list() -> Vec<T::AccountId> { - <UdAccounts<T>>::iter_keys().collect() - } - pub fn replace_account( - old_account_opt: Option<T::AccountId>, - new_account_opt: Option<T::AccountId>, - ) -> Weight { - if let Some(old_account) = old_account_opt { - if let Some(new_account) = new_account_opt { - Self::replace_account_inner(old_account, new_account) - } else { - Self::del_account(old_account) - } - } else if let Some(new_account) = new_account_opt { - Self::add_account(new_account) - } else { - 0 - } - } - pub fn remove_account(account_id: T::AccountId) -> Weight { - Self::del_account(account_id) - } - fn replace_account_inner(old_account: T::AccountId, new_account: T::AccountId) -> Weight { - if <UdAccounts<T>>::contains_key(&old_account) { - if !<UdAccounts<T>>::contains_key(&new_account) { - <UdAccounts<T>>::remove(&old_account); - <UdAccounts<T>>::insert(&new_account, ()); - } else { - frame_support::runtime_print!( - "ERROR: replace_account(): new_account {:?} already added", - new_account - ); - } - } else { - frame_support::runtime_print!( - "ERROR: replace_account(): old_account {:?} already deleted", - old_account - ); - } - 0 - } - fn add_account(account: T::AccountId) -> Weight { - if !<UdAccounts<T>>::contains_key(&account) { - <UdAccounts<T>>::insert(&account, ()); - } else { - frame_support::runtime_print!( - "ERROR: add_account(): account {:?} already added", - account - ); - } - 0 - } - fn del_account(account: T::AccountId) -> Weight { - if <UdAccounts<T>>::contains_key(&account) { - <UdAccounts<T>>::remove(&account); - } else { - frame_support::runtime_print!( - "ERROR: del_account(): account {:?} already deleted", - account - ); - } - 0 - } - } -} diff --git a/pallets/universal-dividend/src/lib.rs b/pallets/universal-dividend/src/lib.rs index 4271a9acdfe870b9158c358bf65f04804772437c..08d2adb8df6c997eca77639c8d796eaed515352f 100644 --- a/pallets/universal-dividend/src/lib.rs +++ b/pallets/universal-dividend/src/lib.rs @@ -25,7 +25,7 @@ mod types; mod weights; pub use pallet::*; -pub use types::FirstEligibleUd; +pub use types::*; pub use weights::WeightInfo; use frame_support::traits::{tokens::ExistenceRequirement, Currency}; @@ -92,6 +92,17 @@ pub mod pallet { #[pallet::getter(fn current_ud)] pub type CurrentUd<T: Config> = StorageValue<_, BalanceOf<T>, ValueQuery>; + #[pallet::type_value] + pub fn DefaultForCurrentUdIndex() -> UdIndex { + 1 + } + + /// Current UD index + #[pallet::storage] + #[pallet::getter(fn ud_index)] + pub type CurrentUdIndex<T: Config> = + StorageValue<_, UdIndex, ValueQuery, DefaultForCurrentUdIndex>; + /// Total quantity of money created by universal dividend (does not take into account the possible destruction of money) #[pallet::storage] #[pallet::getter(fn total_money_created)] @@ -168,6 +179,7 @@ pub mod pallet { /// [amout, members_count] NewUdCreated { amount: BalanceOf<T>, + index: UdIndex, monetary_mass: BalanceOf<T>, members_count: BalanceOf<T>, }, @@ -189,12 +201,16 @@ pub mod pallet { let monetary_mass = <MonetaryMass<T>>::try_get().expect("corrupted storage"); // TODO inc ud index + let ud_index = CurrentUdIndex::<T>::mutate(|next_ud_index| { + core::mem::replace(next_ud_index, next_ud_index.saturating_add(1)) + }); let new_monetary_mass = monetary_mass.saturating_add(ud_amount.saturating_mul(members_count)); MonetaryMass::<T>::put(new_monetary_mass); Self::deposit_event(Event::NewUdCreated { amount: ud_amount, + index: ud_index, members_count, monetary_mass: new_monetary_mass, }); @@ -287,4 +303,12 @@ pub mod pallet { Self::do_transfer_ud(origin, dest, value, ExistenceRequirement::KeepAlive) } } + + // PUBLIC FUNCTIONS + + impl<T: Config> Pallet<T> { + pub fn init_first_eligible_ud() -> FirstEligibleUd { + CurrentUdIndex::<T>::get().into() + } + } } diff --git a/pallets/universal-dividend/src/tests.rs b/pallets/universal-dividend/src/tests.rs index 2b48bef4cb364dbbfd0a8f97cd7ff1c11db0d918..317f2a87c52e80246409aa67ece582ec30c40764 100644 --- a/pallets/universal-dividend/src/tests.rs +++ b/pallets/universal-dividend/src/tests.rs @@ -50,6 +50,7 @@ fn test_ud_creation() { phase: Phase::Initialization, event: Event::UniversalDividend(crate::Event::NewUdCreated { amount: 1_000, + index: 1, monetary_mass: 3_000, members_count: 3, }), diff --git a/pallets/universal-dividend/src/types.rs b/pallets/universal-dividend/src/types.rs index 2ce0b9a5a735491b967f19ce9061cbc828d0e93f..16464350ce77c3f1de28b04834497ea8da9d390a 100644 --- a/pallets/universal-dividend/src/types.rs +++ b/pallets/universal-dividend/src/types.rs @@ -20,7 +20,7 @@ use core::num::NonZeroU16; use serde::{Deserialize, Serialize}; use sp_std::vec::Vec; -type UdIndex = u16; +pub type UdIndex = u16; #[cfg_attr(feature = "std", derive(Deserialize, Serialize))] #[derive(Clone, Copy, Default, Eq, PartialEq)] @@ -33,6 +33,12 @@ impl FirstEligibleUd { } } +impl From<UdIndex> for FirstEligibleUd { + fn from(ud_index: UdIndex) -> Self { + FirstEligibleUd(NonZeroU16::new(ud_index)) + } +} + impl From<FirstEligibleUd> for Option<UdIndex> { fn from(first_eligible_ud: FirstEligibleUd) -> Self { first_eligible_ud.0.map(|ud_index| ud_index.get()) diff --git a/runtime/common/Cargo.toml b/runtime/common/Cargo.toml index 9c2f22584d145f364b7ac8053a4878905d96e786..18152fd8ca730c359137f84c17ea80659cf2bffd 100644 --- a/runtime/common/Cargo.toml +++ b/runtime/common/Cargo.toml @@ -21,7 +21,6 @@ runtime-benchmarks = [ 'pallet-multisig/runtime-benchmarks', 'pallet-proxy/runtime-benchmarks', 'pallet-treasury/runtime-benchmarks', - 'pallet-ud-accounts-storage/runtime-benchmarks', 'sp-runtime/runtime-benchmarks', ] std = [ @@ -46,7 +45,6 @@ std = [ 'pallet-timestamp/std', 'pallet-treasury/std', 'pallet-universal-dividend/std', - 'pallet-ud-accounts-storage/std', "serde/std", "serde_derive", 'sp-arithmetic/std', @@ -71,7 +69,6 @@ pallet-duniter-wot = { path = '../../pallets/duniter-wot', default-features = fa pallet-identity = { path = '../../pallets/identity', default-features = false } pallet-membership = { path = '../../pallets/membership', default-features = false } pallet-provide-randomness = { path = '../../pallets/provide-randomness', default-features = false } -pallet-ud-accounts-storage = { path = '../../pallets/ud-accounts-storage', default-features = false } pallet-upgrade-origin = { path = '../../pallets/upgrade-origin', default-features = false } pallet-universal-dividend = { path = '../../pallets/universal-dividend', default-features = false } sp-membership = { path = '../../primitives/membership', default-features = false } diff --git a/runtime/common/src/handlers.rs b/runtime/common/src/handlers.rs index 7e5587f55f7dd212c2f061c962f5723872abcdbf..3b81d4cee01bae09ed7be02f5551decae259959c 100644 --- a/runtime/common/src/handlers.rs +++ b/runtime/common/src/handlers.rs @@ -15,12 +15,13 @@ // along with Substrate-Libre-Currency. If not, see <https://www.gnu.org/licenses/>. use super::entities::*; -use super::{AccountId, IdtyIndex}; +use super::{AccountId, IdtyData, IdtyIndex}; use frame_support::dispatch::UnfilteredDispatchable; use frame_support::instances::{Instance1, Instance2}; use frame_support::pallet_prelude::Weight; +use frame_support::traits::Get; use frame_support::Parameter; -use sp_runtime::traits::{Convert, IsMember}; +use sp_runtime::traits::IsMember; pub struct OnNewSessionHandler<Runtime>(core::marker::PhantomData<Runtime>); impl<Runtime> pallet_authority_members::traits::OnNewSession for OnNewSessionHandler<Runtime> @@ -40,28 +41,22 @@ type MembershipMetaData = pallet_duniter_wot::MembershipMetaData<AccountId>; impl< Inner: sp_membership::traits::OnEvent<IdtyIndex, MembershipMetaData>, Runtime: frame_system::Config<AccountId = AccountId> - + pallet_identity::Config<IdtyIndex = IdtyIndex> + + pallet_identity::Config<IdtyData = IdtyData, IdtyIndex = IdtyIndex> + pallet_membership::Config<Instance1, MetaData = MembershipMetaData> - + pallet_ud_accounts_storage::Config, + + pallet_universal_dividend::Config, > sp_membership::traits::OnEvent<IdtyIndex, MembershipMetaData> for OnMembershipEventHandler<Inner, Runtime> { fn on_event(membership_event: &sp_membership::Event<IdtyIndex, MembershipMetaData>) -> Weight { (match membership_event { - sp_membership::Event::MembershipAcquired(_idty_index, owner_key) => { - pallet_ud_accounts_storage::Pallet::<Runtime>::replace_account( - None, - Some(owner_key.0.clone()), - ) - } - sp_membership::Event::MembershipRevoked(idty_index) => { - if let Some(account_id) = - crate::providers::IdentityAccountIdProvider::<Runtime>::convert(*idty_index) - { - pallet_ud_accounts_storage::Pallet::<Runtime>::remove_account(account_id) - } else { - 0 - } + sp_membership::Event::MembershipAcquired(idty_index, _owner_key) => { + pallet_identity::Identities::<Runtime>::mutate_exists(idty_index, |idty_val_opt| { + if let Some(ref mut idty_val) = idty_val_opt { + idty_val.data = + pallet_universal_dividend::Pallet::<Runtime>::init_first_eligible_ud(); + } + }); + Runtime::DbWeight::get().reads_writes(1, 1) } _ => 0, }) + Inner::on_event(membership_event) diff --git a/runtime/common/src/pallets_config.rs b/runtime/common/src/pallets_config.rs index 15467dbcba7ee0244bff277bd685a757921b4635..3dc7b962e95ba1b9846ba1a22adac771ffd57e36 100644 --- a/runtime/common/src/pallets_config.rs +++ b/runtime/common/src/pallets_config.rs @@ -406,8 +406,6 @@ macro_rules! pallets_config { type WeightInfo = common_runtime::weights::pallet_universal_dividend::WeightInfo<Runtime>; } - impl pallet_ud_accounts_storage::Config for Runtime {} - // WEBÂ OFÂ TRUST // use frame_support::instances::Instance1; diff --git a/runtime/common/src/providers.rs b/runtime/common/src/providers.rs index 5c87d977327cb23e13645c6335694fe646c23dfd..cddf467a9a8eeac8596b22e2cd5974c7177ed783 100644 --- a/runtime/common/src/providers.rs +++ b/runtime/common/src/providers.rs @@ -15,8 +15,6 @@ // along with Substrate-Libre-Currency. If not, see <https://www.gnu.org/licenses/>. use crate::{AccountId, IdtyIndex}; -use frame_support::traits::Get; -use sp_std::vec::Vec; pub struct IdentityAccountIdProvider<Runtime>(core::marker::PhantomData<Runtime>); @@ -30,17 +28,3 @@ impl< pallet_identity::Pallet::<Runtime>::identity(idty_index).map(|idty| idty.owner_key) } } - -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>>::accounts_len() as u64 - } -} -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>>::accounts_list() - } -} diff --git a/runtime/g1/Cargo.toml b/runtime/g1/Cargo.toml index 7fd344106d679fb1a63c7cc3110e412bf1b9aae8..a4479f4561b5212aa20c486d0dbcd2c7c6d22789 100644 --- a/runtime/g1/Cargo.toml +++ b/runtime/g1/Cargo.toml @@ -118,7 +118,6 @@ pallet-duniter-wot = { path = '../../pallets/duniter-wot', default-features = fa pallet-identity = { path = '../../pallets/identity', default-features = false } pallet-membership = { path = '../../pallets/membership', default-features = false } pallet-provide-randomness = { path = '../../pallets/provide-randomness', default-features = false } -pallet-ud-accounts-storage = { path = '../../pallets/ud-accounts-storage', default-features = false } pallet-universal-dividend = { path = '../../pallets/universal-dividend', default-features = false } pallet-upgrade-origin = { path = '../../pallets/upgrade-origin', default-features = false } sp-membership = { path = '../../primitives/membership', default-features = false } diff --git a/runtime/g1/src/lib.rs b/runtime/g1/src/lib.rs index 66c3239ba86c86fb5d03478c12b324009b816c5c..75f12540d2fbbe3a0b93c34c18d7129b4dfc64ff 100644 --- a/runtime/g1/src/lib.rs +++ b/runtime/g1/src/lib.rs @@ -228,8 +228,7 @@ construct_runtime!( Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>} = 22, // Universal dividend - UdAccountsStorage: pallet_ud_accounts_storage::{Pallet, Config<T>, Storage} = 30, - UniversalDividend: pallet_universal_dividend::{Pallet, Call, Config<T>, Storage, Event<T>} = 31, + UniversalDividend: pallet_universal_dividend::{Pallet, Call, Config<T>, Storage, Event<T>} = 30, // Web Of Trust Wot: pallet_duniter_wot::<Instance1>::{Pallet} = 40, diff --git a/runtime/gdev/Cargo.toml b/runtime/gdev/Cargo.toml index d400bdf3d09c791947d3f2525c251a878d6b029d..236aadec20abd3c0cc13dd1b40c6f1de80f65570 100644 --- a/runtime/gdev/Cargo.toml +++ b/runtime/gdev/Cargo.toml @@ -140,7 +140,6 @@ pallet-duniter-wot = { path = '../../pallets/duniter-wot', default-features = fa pallet-identity = { path = '../../pallets/identity', default-features = false } pallet-membership = { path = '../../pallets/membership', default-features = false } pallet-provide-randomness = { path = '../../pallets/provide-randomness', default-features = false } -pallet-ud-accounts-storage = { path = '../../pallets/ud-accounts-storage', default-features = false } pallet-universal-dividend = { path = '../../pallets/universal-dividend', default-features = false } pallet-upgrade-origin = { path = '../../pallets/upgrade-origin', default-features = false } sp-membership = { path = '../../primitives/membership', default-features = false } diff --git a/runtime/gdev/src/lib.rs b/runtime/gdev/src/lib.rs index 2b4c002484eb9bf9703fa2f925e13884bec2ee98..2a6e21a44cfc4473a2741477d6b7cffb417693ef 100644 --- a/runtime/gdev/src/lib.rs +++ b/runtime/gdev/src/lib.rs @@ -302,8 +302,7 @@ construct_runtime!( Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>} = 22, // Universal dividend - UdAccountsStorage: pallet_ud_accounts_storage::{Pallet, Config<T>, Storage} = 30, - UniversalDividend: pallet_universal_dividend::{Pallet, Call, Config<T>, Storage, Event<T>} = 31, + UniversalDividend: pallet_universal_dividend::{Pallet, Call, Config<T>, Storage, Event<T>} = 30, // Web Of Trust Wot: pallet_duniter_wot::<Instance1>::{Pallet} = 40, diff --git a/runtime/gdev/tests/common/mod.rs b/runtime/gdev/tests/common/mod.rs index 03b9fefac447ea27462e7652c0e3ddce77d7b76e..762e921fbbb85ad718d50f0e9c951d25d537a0c1 100644 --- a/runtime/gdev/tests/common/mod.rs +++ b/runtime/gdev/tests/common/mod.rs @@ -267,12 +267,6 @@ impl ExtBuilder { .assimilate_storage(&mut t) .unwrap(); - pallet_ud_accounts_storage::GenesisConfig::<Runtime> { - ud_accounts: initial_identities.values().cloned().collect(), - } - .assimilate_storage(&mut t) - .unwrap(); - pallet_universal_dividend::GenesisConfig::<Runtime> { first_reeval: 100, first_ud: 1_000, diff --git a/runtime/gdev/tests/integration_tests.rs b/runtime/gdev/tests/integration_tests.rs index 5505560b420a9a3cd3a396e0a9debe5d26059b9a..37f00dcb0d493d8a74b961e471f7fce2bcc9542b 100644 --- a/runtime/gdev/tests/integration_tests.rs +++ b/runtime/gdev/tests/integration_tests.rs @@ -107,17 +107,6 @@ fn test_remove_identity() { System::events()[2].event, Event::Identity(pallet_identity::Event::IdtyRemoved { idty_index: 4 }) ); - - // The identity should be removed from UdAccountsStorage - assert_eq!(UdAccountsStorage::accounts_len(), 3); - assert_eq!( - UdAccountsStorage::accounts_list(), - vec![ - AccountKeyring::Bob.to_account_id(), - AccountKeyring::Charlie.to_account_id(), - AccountKeyring::Alice.to_account_id(), - ] - ); }); } diff --git a/runtime/gtest/Cargo.toml b/runtime/gtest/Cargo.toml index 68915d05baba63430746b3af90917cbfa424d334..cefd2396d6218b1a766de4753f7bc93648b18c5d 100644 --- a/runtime/gtest/Cargo.toml +++ b/runtime/gtest/Cargo.toml @@ -118,7 +118,6 @@ pallet-duniter-wot = { path = '../../pallets/duniter-wot', default-features = fa pallet-identity = { path = '../../pallets/identity', default-features = false } pallet-membership = { path = '../../pallets/membership', default-features = false } pallet-provide-randomness = { path = '../../pallets/provide-randomness', default-features = false } -pallet-ud-accounts-storage = { path = '../../pallets/ud-accounts-storage', default-features = false } pallet-universal-dividend = { path = '../../pallets/universal-dividend', default-features = false } pallet-upgrade-origin = { path = '../../pallets/upgrade-origin', default-features = false } sp-membership = { path = '../../primitives/membership', default-features = false } diff --git a/runtime/gtest/src/lib.rs b/runtime/gtest/src/lib.rs index 862a545658a07265f7b4ffe05399a68185fe32ec..43c84ab9e56583fb8ab570ce0ba5a68e4c8b8dbf 100644 --- a/runtime/gtest/src/lib.rs +++ b/runtime/gtest/src/lib.rs @@ -229,8 +229,7 @@ construct_runtime!( Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>} = 22, // Universal dividend - UdAccountsStorage: pallet_ud_accounts_storage::{Pallet, Config<T>, Storage} = 30, - UniversalDividend: pallet_universal_dividend::{Pallet, Call, Config<T>, Storage, Event<T>} = 31, + UniversalDividend: pallet_universal_dividend::{Pallet, Call, Config<T>, Storage, Event<T>} = 30, // Web Of Trust Wot: pallet_duniter_wot::<Instance1>::{Pallet} = 40,