Make Pallet ModuleId and LockIdentifier Configurable (#5695)

* transition treasury to configurable moduleids

* make election module id configurable

* convert runtime and pallet to accept module id config elections-phragmen

* add ModuleId to evm pallet

* change society pallet to configurable module id

* delete commented out module_id

* delete commented out code and merge in upstream  master

* try and convert 4 whitespace to tab

* fix remaining space to tab conversions

* trivial cleaning

* delete comment from elections-phragrems tests

* trivial

* Update frame/elections-phragmen/src/lib.rs

* add docs for elections and elections phragmen

* make has_lock test get moduleid dynamically

* Apply suggestions from code review

Co-Authored-By: Amar Singh <asinghchrony@protonmail.com>

* make sure get is imported to evm

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: Amar Singh <asinghchrony@protonmail.com>
Co-authored-by: Benjamin Kampmann <ben@gnunicorn.org>
This commit is contained in:
emostov
2020-04-24 02:47:32 -07:00
committed by GitHub
parent 2fb22de02e
commit 8ac2bac58d
9 changed files with 63 additions and 29 deletions
+7 -4
View File
@@ -110,10 +110,10 @@ type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trai
type PositiveImbalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::PositiveImbalance;
type NegativeImbalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::NegativeImbalance;
/// The treasury's module id, used for deriving its sovereign account ID.
const MODULE_ID: ModuleId = ModuleId(*b"py/trsry");
pub trait Trait: frame_system::Trait {
/// The treasury's module id, used for deriving its sovereign account ID.
type ModuleId: Get<ModuleId>;
/// The staking balance.
type Currency: Currency<Self::AccountId> + ReservableCurrency<Self::AccountId>;
@@ -313,6 +313,9 @@ decl_module! {
/// The amount held on deposit per byte within the tip report reason.
const TipReportDepositPerByte: BalanceOf<T> = T::TipReportDepositPerByte::get();
/// The treasury's module id, used for deriving its sovereign account ID.
const ModuleId: ModuleId = T::ModuleId::get();
type Error = Error<T>;
@@ -571,7 +574,7 @@ impl<T: Trait> Module<T> {
/// This actually does computation. If you need to keep using it, then make sure you cache the
/// value and only call this once.
pub fn account_id() -> T::AccountId {
MODULE_ID.into_account()
T::ModuleId::get().into_account()
}
/// The needed bond for a proposal whose spend is `value`.
+3 -1
View File
@@ -26,7 +26,7 @@ use frame_support::{
};
use sp_core::H256;
use sp_runtime::{
Perbill,
Perbill, ModuleId,
testing::Header,
traits::{BlakeTwo256, IdentityLookup, BadOrigin},
};
@@ -118,8 +118,10 @@ parameter_types! {
pub const TipFindersFee: Percent = Percent::from_percent(20);
pub const TipReportDepositBase: u64 = 1;
pub const TipReportDepositPerByte: u64 = 1;
pub const TreasuryModuleId: ModuleId = ModuleId(*b"py/trsry");
}
impl Trait for Test {
type ModuleId = TreasuryModuleId;
type Currency = pallet_balances::Module<Test>;
type ApproveOrigin = frame_system::EnsureRoot<u64>;
type RejectOrigin = frame_system::EnsureRoot<u64>;