diff --git a/Cargo.lock b/Cargo.lock index 2bdafcac47f4c98d334970549ac0f53612045b57..fe2675c9178aa6568777a766051268de027127b7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -840,6 +840,7 @@ dependencies = [ "pallet-membership", "pallet-provide-randomness", "pallet-session", + "pallet-treasury", "pallet-ud-accounts-storage", "parity-scale-codec", "scale-info", @@ -1976,6 +1977,7 @@ dependencies = [ "pallet-timestamp", "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", + "pallet-treasury", "pallet-ud-accounts-storage", "pallet-universal-dividend", "pallet-utility", @@ -2037,6 +2039,7 @@ dependencies = [ "pallet-timestamp", "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", + "pallet-treasury", "pallet-ud-accounts-storage", "pallet-universal-dividend", "pallet-upgrade-origin", @@ -2240,6 +2243,7 @@ dependencies = [ "pallet-timestamp", "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", + "pallet-treasury", "pallet-ud-accounts-storage", "pallet-universal-dividend", "pallet-utility", @@ -4440,9 +4444,11 @@ dependencies = [ "frame-benchmarking", "frame-support", "frame-system", + "log", "maplit", "pallet-balances", "pallet-provide-randomness", + "pallet-treasury", "parity-scale-codec", "scale-info", "serde", @@ -4747,6 +4753,23 @@ dependencies = [ "sp-runtime", ] +[[package]] +name = "pallet-treasury" +version = "4.0.0-dev" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-02#8fbc011c06ee051577022c8fd84f2a018123efd3" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "pallet-balances", + "parity-scale-codec", + "scale-info", + "serde", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-ud-accounts-storage" version = "3.0.0" diff --git a/node/src/chain_spec/gdev.rs b/node/src/chain_spec/gdev.rs index 70ff7bc0af7d1694466cac781ac01f77235c1a59..fefa4d44c31e5c82e941b4a1c2c27f56d13ee5c6 100644 --- a/node/src/chain_spec/gdev.rs +++ b/node/src/chain_spec/gdev.rs @@ -378,6 +378,7 @@ fn gen_genesis_conf( first_ud: 1_000, initial_monetary_mass: 0, }, + treasury: Default::default(), } } @@ -482,5 +483,6 @@ fn genesis_data_to_gdev_genesis_conf( first_ud, initial_monetary_mass, }, + treasury: Default::default(), } } diff --git a/pallets/duniter-account/Cargo.toml b/pallets/duniter-account/Cargo.toml index c4f48360f0b1c5ac9e5c3fd6e26e24c3b13f966b..0bb55aa80e178dda61acba7cd7af19b92ac75f13 100644 --- a/pallets/duniter-account/Cargo.toml +++ b/pallets/duniter-account/Cargo.toml @@ -19,6 +19,7 @@ std = [ 'frame-benchmarking/std', 'pallet-balances/std', 'pallet-provide-randomness/std', + 'pallet-treasury/std', 'serde', 'sp-core/std', 'sp-io/std', @@ -33,6 +34,7 @@ pallet-provide-randomness = { path = "../provide-randomness", default-features = # crates.io codec = { package = 'parity-scale-codec', version = "2.3.1", default-features = false, features = ["derive"] } +log = { version = "0.4.14", default-features = false } scale-info = { version = "1.0", default-features = false, features = ["derive"] } # substrate @@ -57,6 +59,11 @@ default-features = false git = 'https://github.com/librelois/substrate.git' branch = 'duniter-monthly-2022-02' +[dependencies.pallet-treasury] +default-features = false +git = 'https://github.com/librelois/substrate.git' +branch = 'duniter-monthly-2022-02' + [dependencies.serde] version = "1.0.101" optional = true diff --git a/pallets/duniter-account/src/lib.rs b/pallets/duniter-account/src/lib.rs index e43e2a91e78c15bb5a1ef97990ef1584c80815b3..0e8e91a840d7733cc08c1889fead446f34ac0f77 100644 --- a/pallets/duniter-account/src/lib.rs +++ b/pallets/duniter-account/src/lib.rs @@ -49,6 +49,7 @@ pub mod pallet { frame_system::Config<AccountData = AccountData<Self::Balance>> + pallet_balances::Config + pallet_provide_randomness::Config<Currency = pallet_balances::Pallet<Self>> + + pallet_treasury::Config<Currency = pallet_balances::Pallet<Self>> { type AccountIdToSalt: Convert<Self::AccountId, [u8; 32]>; /// The overarching event type. @@ -89,6 +90,16 @@ pub mod pallet { #[pallet::genesis_build] impl<T: Config> GenesisBuild<T> for GenesisConfig<T> { fn build(&self) { + // Treasury + frame_system::Account::<T>::mutate( + pallet_treasury::Pallet::<T>::account_id(), + |account| { + account.data.random_id = None; + account.data.free = T::ExistentialDeposit::get(); + account.providers = 1; + }, + ); + // Classic accounts for ( account_id, GenesisAccountData { @@ -146,7 +157,7 @@ pub mod pallet { } else { // If the account is not self-sufficient, it must pay the account creation fees frame_system::Pallet::<T>::inc_providers(&account_id); - let res = T::Currency::withdraw( + let res = <pallet_balances::Pallet<T> as Currency<T::AccountId>>::withdraw( &account_id, T::NewAccountPrice::get(), frame_support::traits::WithdrawReasons::FEE, @@ -180,12 +191,20 @@ pub mod pallet { "Cannot fail because providers are incremented just before" ); let account_data = frame_system::Pallet::<T>::get(&account_id); - let (imbalance, rest) = pallet_balances::Pallet::<T>::slash( + let res = <pallet_balances::Pallet<T> as Currency<T::AccountId>>::withdraw( &account_id, account_data.free.saturating_add(account_data.reserved), + frame_support::traits::WithdrawReasons::FEE, + ExistenceRequirement::AllowDeath, ); - debug_assert!(rest.is_zero()); - T::OnUnbalanced::on_unbalanced(imbalance); + if let Ok(imbalance) = res { + T::OnUnbalanced::on_unbalanced(imbalance); + } else { + log::warn!( + "Unexpected withdraw fail to destroy account {:?}", + &account_id + ); + } total_weight += 300_000; } } diff --git a/runtime/common/Cargo.toml b/runtime/common/Cargo.toml index 9d4a1b324c6e917ee7e5508f23ffdc3977904af2..0cceb7f4a360e40078bf18766ae808b481dddfe4 100644 --- a/runtime/common/Cargo.toml +++ b/runtime/common/Cargo.toml @@ -14,6 +14,7 @@ runtime-benchmarks = [ 'pallet-duniter-wot/runtime-benchmarks', 'pallet-identity/runtime-benchmarks', 'pallet-membership/runtime-benchmarks', + 'pallet-treasury/std', 'pallet-ud-accounts-storage/runtime-benchmarks', 'sp-runtime/runtime-benchmarks', ] @@ -31,6 +32,7 @@ std = [ 'pallet-identity/std', 'pallet-membership/std', 'pallet-provide-randomness/std', + 'pallet-treasury/std', 'pallet-ud-accounts-storage/std', 'serde', 'sp-arithmetic/std', @@ -90,6 +92,11 @@ features = ["historical"] git = 'https://github.com/librelois/substrate.git' branch = 'duniter-monthly-2022-02' +[dependencies.pallet-treasury] +default-features = false +git = 'https://github.com/librelois/substrate.git' +branch = 'duniter-monthly-2022-02' + [dependencies.serde] version = "1.0.101" optional = true diff --git a/runtime/common/src/handlers.rs b/runtime/common/src/handlers.rs index b9731cd6b40651da8f21282c19ed32c029803a2b..7e5587f55f7dd212c2f061c962f5723872abcdbf 100644 --- a/runtime/common/src/handlers.rs +++ b/runtime/common/src/handlers.rs @@ -188,3 +188,18 @@ where 0 } } + +pub struct TreasurySpendFunds<Runtime>(core::marker::PhantomData<Runtime>); +impl<Runtime> pallet_treasury::SpendFunds<Runtime> for TreasurySpendFunds<Runtime> +where + Runtime: pallet_treasury::Config, +{ + fn spend_funds( + _budget_remaining: &mut pallet_treasury::BalanceOf<Runtime>, + _imbalance: &mut pallet_treasury::PositiveImbalanceOf<Runtime>, + _total_weight: &mut Weight, + missed_any: &mut bool, + ) { + *missed_any = true; + } +} diff --git a/runtime/common/src/pallets_config.rs b/runtime/common/src/pallets_config.rs index 9ae9bbbd2ff604460df330dfdba0af2f917bc238..0ab744c6f36a11409c76289dad9b80b8011fc33c 100644 --- a/runtime/common/src/pallets_config.rs +++ b/runtime/common/src/pallets_config.rs @@ -155,7 +155,7 @@ macro_rules! pallets_config { type Balance = Balance; /// The ubiquitous event type. type Event = Event; - type DustRemoval = (); + type DustRemoval = Treasury; type ExistentialDeposit = ExistentialDeposit; type AccountStore = Account; type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>; @@ -272,7 +272,7 @@ macro_rules! pallets_config { type MaxRequests = frame_support::traits::ConstU32<1_000>; type RequestPrice = frame_support::traits::ConstU64<200>; type OnFilledRandomness = Account; - type OnUnbalanced = (); + type OnUnbalanced = Treasury; type CurrentBlockRandomness = pallet_babe::CurrentBlockRandomness<Self>; type RandomnessFromOneEpochAgo = pallet_babe::RandomnessFromOneEpochAgo<Self>; } @@ -321,6 +321,33 @@ macro_rules! pallets_config { type WeightInfo = pallet_utility::weights::SubstrateWeight<Self>; } + parameter_types! { + pub const Burn: Permill = Permill::zero(); + pub const ProposalBond: Permill = Permill::from_percent(1); + pub const ProposalBondMaximum: Option<Balance> = None; + pub const SpendPeriod: BlockNumber = DAYS; + // Treasury account address: + // gdev/gtest: 5EYCAe5ijiYfyeZ2JJCGq56LmPyNRAKzpG4QkoQkkQNB5e6Z + pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry"); + } + impl pallet_treasury::Config for Runtime { + type ApproveOrigin = TreasuryApproveOrigin; + type Burn = Burn; + type BurnDestination = (); + type Currency = Balances; + type Event = Event; + type OnSlash = Treasury; + type ProposalBond = ProposalBond; + type ProposalBondMinimum = frame_support::traits::ConstU64<10_000>; + type ProposalBondMaximum = ProposalBondMaximum; + type MaxApprovals = frame_support::traits::ConstU32<10>; + type PalletId = TreasuryPalletId; + type RejectOrigin = TreasuryRejectOrigin; + type SpendFunds = TreasurySpendFunds<Self>; + type SpendPeriod = SpendPeriod; + type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>; + } + // UNIVERSALĂ‚ DIVIDEND // impl pallet_universal_dividend::Config for Runtime { diff --git a/runtime/g1/Cargo.toml b/runtime/g1/Cargo.toml index 1f08a0648284599b0bdbc5db71f2967ff9fad30f..a5c3e256762f6f6f57ea49a943b1dc3c5588c457 100644 --- a/runtime/g1/Cargo.toml +++ b/runtime/g1/Cargo.toml @@ -22,8 +22,9 @@ runtime-benchmarks = [ 'frame-system/runtime-benchmarks', 'hex-literal', 'pallet-balances/runtime-benchmarks', - 'pallet-universal-dividend/runtime-benchmarks', 'pallet-timestamp/runtime-benchmarks', + 'pallet-treasury/runtime-benchmarks', + 'pallet-universal-dividend/runtime-benchmarks', 'sp-runtime/runtime-benchmarks', ] std = [ @@ -50,10 +51,11 @@ std = [ 'pallet-proxy/std', 'pallet-session/std', 'pallet-sudo/std', - 'pallet-universal-dividend/std', 'pallet-timestamp/std', 'pallet-transaction-payment-rpc-runtime-api/std', 'pallet-transaction-payment/std', + 'pallet-treasury/std', + 'pallet-universal-dividend/std', 'common-runtime/std', 'serde', 'sp-api/std', @@ -217,6 +219,11 @@ default-features = false git = 'https://github.com/librelois/substrate.git' branch = 'duniter-monthly-2022-02' +[dependencies.pallet-treasury] +default-features = false +git = 'https://github.com/librelois/substrate.git' +branch = 'duniter-monthly-2022-02' + [dependencies.pallet-utility] default-features = false git = 'https://github.com/librelois/substrate.git' diff --git a/runtime/g1/src/lib.rs b/runtime/g1/src/lib.rs index 2546c4f3c94466953e96609b3c9d578e297db9aa..cc89d93e3d088ca9b9cae9f73d6497880f876a1c 100644 --- a/runtime/g1/src/lib.rs +++ b/runtime/g1/src/lib.rs @@ -42,6 +42,7 @@ pub use sp_runtime::{KeyTypeId, Perbill, Permill}; use common_runtime::IdtyNameValidatorImpl; use frame_support::traits::Contains; +use frame_support::PalletId; use frame_system::EnsureRoot; use pallet_grandpa::fg_primitives; use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList}; @@ -121,6 +122,8 @@ pub type Executive = frame_executive::Executive< AllPalletsWithSystem, >; +pub type SmithsInstance = Instance2; + pub struct BaseCallFilter; impl Contains<Call> for BaseCallFilter { fn contains(call: &Call) -> bool { @@ -241,6 +244,7 @@ construct_runtime!( ProvideRandomness: pallet_provide_randomness::{Pallet, Call, Storage, Event} = 62, Proxy: pallet_proxy::{Pallet, Call, Storage, Event<T>} = 63, Utility: pallet_utility::{Pallet, Call, Event} = 64, + Treasury: pallet_treasury::{Pallet, Call, Config, Storage, Event<T>} = 65, } ); diff --git a/runtime/g1/src/parameters.rs b/runtime/g1/src/parameters.rs index fa7e5e98d3f8c3e5aaa6cf054c0104fa9bc4d73c..a9a6684baf6ca9b464296d589d9e6af6bf92ba6d 100644 --- a/runtime/g1/src/parameters.rs +++ b/runtime/g1/src/parameters.rs @@ -14,11 +14,13 @@ // 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::*; use common_runtime::constants::*; use common_runtime::{Balance, BlockNumber}; use frame_support::parameter_types; use frame_support::weights::constants::WEIGHT_PER_SECOND; use sp_arithmetic::Perbill; +use sp_core::u32_trait::*; use sp_runtime::transaction_validity::TransactionPriority; parameter_types! { @@ -146,7 +148,17 @@ parameter_types! { pub const SmithValidityPeriod: BlockNumber = 146 * DAYS; } +/*************/ +/* UTILITIES */ +/*************/ + // Multisig parameter_types! { pub const MaxSignatories: u16 = 5; } + +// Treasury +pub type TreasuryApproveOrigin = + pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, SmithsInstance>; +pub type TreasuryRejectOrigin = + pallet_collective::EnsureProportionMoreThan<_1, _3, AccountId, SmithsInstance>; diff --git a/runtime/gdev/Cargo.toml b/runtime/gdev/Cargo.toml index c584dd980ca2194ee4fb85070dc5feea4eea1dd1..ef02d5472116e80e953be8c7840372d06faa2979 100644 --- a/runtime/gdev/Cargo.toml +++ b/runtime/gdev/Cargo.toml @@ -23,6 +23,7 @@ runtime-benchmarks = [ 'hex-literal', 'pallet-balances/runtime-benchmarks', 'pallet-identity/runtime-benchmarks', + 'pallet-treasury/runtime-benchmarks', 'pallet-universal-dividend/runtime-benchmarks', 'common-runtime/runtime-benchmarks', 'sp-runtime/runtime-benchmarks', @@ -57,6 +58,7 @@ std = [ 'pallet-timestamp/std', 'pallet-transaction-payment-rpc-runtime-api/std', 'pallet-transaction-payment/std', + 'pallet-treasury/std', 'common-runtime/std', 'serde', 'sp-api/std', @@ -227,6 +229,12 @@ default-features = false git = 'https://github.com/librelois/substrate.git' branch = 'duniter-monthly-2022-02' +[dependencies.pallet-treasury] +default-features = false +git = 'https://github.com/librelois/substrate.git' +branch = 'duniter-monthly-2022-02' + + [dependencies.pallet-utility] default-features = false git = 'https://github.com/librelois/substrate.git' diff --git a/runtime/gdev/src/lib.rs b/runtime/gdev/src/lib.rs index 7bc127edf7622df35cbc6961d352eabe7fe1fd98..d8c7ef4a5118dd2142ea7845f3560613df513e9b 100644 --- a/runtime/gdev/src/lib.rs +++ b/runtime/gdev/src/lib.rs @@ -42,6 +42,7 @@ pub use sp_runtime::{KeyTypeId, Perbill, Permill}; use common_runtime::IdtyNameValidatorImpl; use frame_support::traits::Contains; +use frame_support::PalletId; use frame_system::EnsureRoot; use pallet_grandpa::fg_primitives; use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList}; @@ -123,6 +124,8 @@ pub type Executive = frame_executive::Executive< AllPalletsWithSystem, >; +pub type SmithsInstance = Instance2; + pub struct BaseCallFilter; impl Contains<Call> for BaseCallFilter { fn contains(call: &Call) -> bool { @@ -131,7 +134,8 @@ impl Contains<Call> for BaseCallFilter { Call::System( frame_system::Call::remark { .. } | frame_system::Call::remark_with_event { .. } ) | Call::Membership( - pallet_membership::Call::claim_membership { .. } + pallet_membership::Call::request_membership { .. } + | pallet_membership::Call::claim_membership { .. } | pallet_membership::Call::revoke_membership { .. } ) | Call::Session(_) | Call::SmithsMembership(pallet_membership::Call::claim_membership { .. }) @@ -232,7 +236,7 @@ common_runtime::pallets_config! { impl pallet_upgrade_origin::Config for Runtime { type Event = Event; type Call = Call; - type UpgradableOrigin = pallet_collective::EnsureProportionAtLeast<_2, _3, AccountId, Instance2>; + type UpgradableOrigin = pallet_collective::EnsureProportionAtLeast<_2, _3, AccountId, SmithsInstance>; } } @@ -295,6 +299,7 @@ construct_runtime!( ProvideRandomness: pallet_provide_randomness::{Pallet, Call, Storage, Event} = 62, Proxy: pallet_proxy::{Pallet, Call, Storage, Event<T>} = 63, Utility: pallet_utility::{Pallet, Call, Event} = 64, + Treasury: pallet_treasury::{Pallet, Call, Config, Storage, Event<T>} = 65, } ); diff --git a/runtime/gdev/src/parameters.rs b/runtime/gdev/src/parameters.rs index 229c8eb2542c547f258ad471661a138b90e9eb24..7c11c6b7b315062d0fdab9cbc26aa313797d372f 100644 --- a/runtime/gdev/src/parameters.rs +++ b/runtime/gdev/src/parameters.rs @@ -14,11 +14,13 @@ // 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::*; use common_runtime::constants::*; use common_runtime::{Balance, BlockNumber}; use frame_support::parameter_types; use frame_support::weights::constants::WEIGHT_PER_SECOND; use sp_arithmetic::Perbill; +use sp_core::u32_trait::*; use sp_runtime::transaction_validity::TransactionPriority; parameter_types! { @@ -84,7 +86,17 @@ parameter_types! { pub const SquareMoneyGrowthRate: Perbill = Perbill::from_parts(2_381_440); } +/*************/ +/* UTILITIES */ +/*************/ + // Multisig parameter_types! { pub const MaxSignatories: u16 = 5; } + +// Treasury +pub type TreasuryApproveOrigin = + pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, SmithsInstance>; +pub type TreasuryRejectOrigin = + pallet_collective::EnsureProportionMoreThan<_1, _3, AccountId, SmithsInstance>; diff --git a/runtime/gdev/tests/integration_tests.rs b/runtime/gdev/tests/integration_tests.rs index 5d95a9f04b1d2f958dcf5ced2a0a76cfc8bd9d70..8b412a2045da9962e3c8c486b449d2ff34f784d2 100644 --- a/runtime/gdev/tests/integration_tests.rs +++ b/runtime/gdev/tests/integration_tests.rs @@ -24,6 +24,11 @@ use gdev_runtime::*; use sp_keyring::AccountKeyring; use sp_runtime::MultiAddress; +#[test] +fn verify_treasury_account() { + println!("{}", Treasury::account_id()); +} + #[test] fn verify_pallet_prefixes() { let prefix = |pallet_name, storage_name| { @@ -179,8 +184,8 @@ fn test_create_new_account() { // and new account tax should be collected run_to_block(3); let events = System::events(); - //println!("{:#?}", events); - assert_eq!(events.len(), 2); + println!("{:#?}", events); + assert_eq!(events.len(), 4); assert_eq!( System::events()[0].event, Event::System(frame_system::Event::NewAccount { @@ -194,10 +199,22 @@ fn test_create_new_account() { amount: 300, }) ); + assert_eq!( + System::events()[2].event, + Event::Balances(pallet_balances::Event::Deposit { + who: Treasury::account_id(), + amount: 300, + }) + ); + assert_eq!( + System::events()[3].event, + Event::Treasury(pallet_treasury::Event::Deposit { value: 300 }) + ); assert_eq!( Balances::free_balance(AccountKeyring::Eve.to_account_id()), 200 ); + assert_eq!(Balances::free_balance(Treasury::account_id()), 500); // A random id request should be registered assert_eq!( diff --git a/runtime/gtest/Cargo.toml b/runtime/gtest/Cargo.toml index af482793005974d16eda5bd51aa63ccc723cab14..c66f4f351e06de60e2f5da8c20a402b4cde0bc24 100644 --- a/runtime/gtest/Cargo.toml +++ b/runtime/gtest/Cargo.toml @@ -22,8 +22,9 @@ runtime-benchmarks = [ 'frame-system/runtime-benchmarks', 'hex-literal', 'pallet-balances/runtime-benchmarks', - 'pallet-universal-dividend/runtime-benchmarks', 'pallet-timestamp/runtime-benchmarks', + 'pallet-treasury/runtime-benchmarks', + 'pallet-universal-dividend/runtime-benchmarks', 'sp-runtime/runtime-benchmarks', ] std = [ @@ -50,10 +51,11 @@ std = [ 'pallet-multisig/std', 'pallet-session/std', 'pallet-sudo/std', - 'pallet-universal-dividend/std', 'pallet-timestamp/std', 'pallet-transaction-payment-rpc-runtime-api/std', 'pallet-transaction-payment/std', + 'pallet-treasury/std', + 'pallet-universal-dividend/std', 'common-runtime/std', 'serde', 'sp-api/std', @@ -217,6 +219,11 @@ default-features = false git = 'https://github.com/librelois/substrate.git' branch = 'duniter-monthly-2022-02' +[dependencies.pallet-treasury] +default-features = false +git = 'https://github.com/librelois/substrate.git' +branch = 'duniter-monthly-2022-02' + [dependencies.pallet-utility] default-features = false git = 'https://github.com/librelois/substrate.git' diff --git a/runtime/gtest/src/lib.rs b/runtime/gtest/src/lib.rs index be6b0723a3f5c6cc02dd470c761def90904cbc55..f980b2c1082d55e4c7eae2cbef300006a9c45483 100644 --- a/runtime/gtest/src/lib.rs +++ b/runtime/gtest/src/lib.rs @@ -42,6 +42,7 @@ pub use sp_runtime::{KeyTypeId, Perbill, Permill}; use common_runtime::IdtyNameValidatorImpl; use frame_support::traits::Contains; +use frame_support::PalletId; use frame_system::EnsureRoot; use pallet_grandpa::fg_primitives; use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList}; @@ -122,6 +123,8 @@ pub type Executive = frame_executive::Executive< AllPalletsWithSystem, >; +pub type SmithsInstance = Instance2; + pub struct BaseCallFilter; impl Contains<Call> for BaseCallFilter { fn contains(call: &Call) -> bool { @@ -242,6 +245,7 @@ construct_runtime!( ProvideRandomness: pallet_provide_randomness::{Pallet, Call, Storage, Event} = 62, Proxy: pallet_proxy::{Pallet, Call, Storage, Event<T>} = 63, Utility: pallet_utility::{Pallet, Call, Event} = 64, + Treasury: pallet_treasury::{Pallet, Call, Config, Storage, Event<T>} = 65, } ); diff --git a/runtime/gtest/src/parameters.rs b/runtime/gtest/src/parameters.rs index 5b1a0f76fee35e6749fd1d4a9ccc0f638b7496fd..e4262ab824c9a1d2389dafc77bc361149aa3cd44 100644 --- a/runtime/gtest/src/parameters.rs +++ b/runtime/gtest/src/parameters.rs @@ -14,11 +14,13 @@ // 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::*; use common_runtime::constants::*; use common_runtime::{Balance, BlockNumber}; use frame_support::parameter_types; use frame_support::weights::constants::WEIGHT_PER_SECOND; use sp_arithmetic::Perbill; +use sp_core::u32_trait::*; use sp_runtime::transaction_validity::TransactionPriority; parameter_types! { @@ -146,7 +148,17 @@ parameter_types! { pub const SmithValidityPeriod: BlockNumber = 146 * DAYS; } +/*************/ +/* UTILITIES */ +/*************/ + // Multisig parameter_types! { pub const MaxSignatories: u16 = 5; } + +// Treasury +pub type TreasuryApproveOrigin = + pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, SmithsInstance>; +pub type TreasuryRejectOrigin = + pallet_collective::EnsureProportionMoreThan<_1, _3, AccountId, SmithsInstance>;