mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 18:37:59 +00:00
* `ModuleId` to `PalletId` - part of #8372 * fix doc * move `PalletId` to `frame-support` * fix compile * fix tests * `ModuleId` to `PalletId` * subcommand `moduleid` to `palletid`
This commit is contained in:
Generated
+1
@@ -9411,6 +9411,7 @@ dependencies = [
|
||||
name = "substrate-frame-cli"
|
||||
version = "3.0.0"
|
||||
dependencies = [
|
||||
"frame-support",
|
||||
"frame-system",
|
||||
"sc-cli",
|
||||
"sp-core",
|
||||
|
||||
@@ -40,7 +40,7 @@ use frame_system::{
|
||||
EnsureRoot, EnsureOneOf,
|
||||
limits::{BlockWeights, BlockLength}
|
||||
};
|
||||
use frame_support::traits::InstanceFilter;
|
||||
use frame_support::{traits::InstanceFilter, PalletId};
|
||||
use codec::{Encode, Decode};
|
||||
use sp_core::{
|
||||
crypto::KeyTypeId,
|
||||
@@ -52,7 +52,7 @@ use node_primitives::{AccountIndex, Balance, BlockNumber, Hash, Index, Moment};
|
||||
use sp_api::impl_runtime_apis;
|
||||
use sp_runtime::{
|
||||
Permill, Perbill, Perquintill, Percent, ApplyExtrinsicResult, impl_opaque_keys, generic,
|
||||
create_runtime_str, ModuleId, FixedPointNumber,
|
||||
create_runtime_str, FixedPointNumber,
|
||||
};
|
||||
use sp_runtime::curve::PiecewiseLinear;
|
||||
use sp_runtime::transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority};
|
||||
@@ -634,7 +634,7 @@ parameter_types! {
|
||||
pub const TermDuration: BlockNumber = 7 * DAYS;
|
||||
pub const DesiredMembers: u32 = 13;
|
||||
pub const DesiredRunnersUp: u32 = 7;
|
||||
pub const ElectionsPhragmenModuleId: LockIdentifier = *b"phrelect";
|
||||
pub const ElectionsPhragmenPalletId: LockIdentifier = *b"phrelect";
|
||||
}
|
||||
|
||||
// Make sure that there are no more than `MaxMembers` members elected via elections-phragmen.
|
||||
@@ -642,7 +642,7 @@ const_assert!(DesiredMembers::get() <= CouncilMaxMembers::get());
|
||||
|
||||
impl pallet_elections_phragmen::Config for Runtime {
|
||||
type Event = Event;
|
||||
type ModuleId = ElectionsPhragmenModuleId;
|
||||
type PalletId = ElectionsPhragmenPalletId;
|
||||
type Currency = Balances;
|
||||
type ChangeMembers = Council;
|
||||
// NOTE: this implies that council's genesis members cannot be set directly and must come from
|
||||
@@ -705,7 +705,7 @@ parameter_types! {
|
||||
pub const DataDepositPerByte: Balance = 1 * CENTS;
|
||||
pub const BountyDepositBase: Balance = 1 * DOLLARS;
|
||||
pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;
|
||||
pub const TreasuryModuleId: ModuleId = ModuleId(*b"py/trsry");
|
||||
pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry");
|
||||
pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;
|
||||
pub const MaximumReasonLength: u32 = 16384;
|
||||
pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);
|
||||
@@ -713,7 +713,7 @@ parameter_types! {
|
||||
}
|
||||
|
||||
impl pallet_treasury::Config for Runtime {
|
||||
type ModuleId = TreasuryModuleId;
|
||||
type PalletId = TreasuryPalletId;
|
||||
type Currency = Balances;
|
||||
type ApproveOrigin = EnsureOneOf<
|
||||
AccountId,
|
||||
@@ -970,12 +970,12 @@ parameter_types! {
|
||||
pub const MaxLockDuration: BlockNumber = 36 * 30 * DAYS;
|
||||
pub const ChallengePeriod: BlockNumber = 7 * DAYS;
|
||||
pub const MaxCandidateIntake: u32 = 10;
|
||||
pub const SocietyModuleId: ModuleId = ModuleId(*b"py/socie");
|
||||
pub const SocietyPalletId: PalletId = PalletId(*b"py/socie");
|
||||
}
|
||||
|
||||
impl pallet_society::Config for Runtime {
|
||||
type Event = Event;
|
||||
type ModuleId = SocietyModuleId;
|
||||
type PalletId = SocietyPalletId;
|
||||
type Currency = Balances;
|
||||
type Randomness = RandomnessCollectiveFlip;
|
||||
type CandidateDeposit = CandidateDeposit;
|
||||
@@ -1013,13 +1013,13 @@ impl pallet_mmr::Config for Runtime {
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const LotteryModuleId: ModuleId = ModuleId(*b"py/lotto");
|
||||
pub const LotteryPalletId: PalletId = PalletId(*b"py/lotto");
|
||||
pub const MaxCalls: usize = 10;
|
||||
pub const MaxGenerateRandom: u32 = 10;
|
||||
}
|
||||
|
||||
impl pallet_lottery::Config for Runtime {
|
||||
type ModuleId = LotteryModuleId;
|
||||
type PalletId = LotteryPalletId;
|
||||
type Call = Call;
|
||||
type Currency = Balances;
|
||||
type Randomness = RandomnessCollectiveFlip;
|
||||
|
||||
@@ -677,14 +677,14 @@ impl<T: Config> 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 {
|
||||
T::ModuleId::get().into_account()
|
||||
T::PalletId::get().into_account()
|
||||
}
|
||||
|
||||
/// The account ID of a bounty account
|
||||
pub fn bounty_account_id(id: BountyIndex) -> T::AccountId {
|
||||
// only use two byte prefix to support 16 byte account id (used by test)
|
||||
// "modl" ++ "py/trsry" ++ "bt" is 14 bytes, and two bytes remaining for bounty index
|
||||
T::ModuleId::get().into_sub_account(("bt", id))
|
||||
T::PalletId::get().into_sub_account(("bt", id))
|
||||
}
|
||||
|
||||
fn create_bounty(
|
||||
|
||||
@@ -24,12 +24,13 @@ use super::*;
|
||||
use std::cell::RefCell;
|
||||
|
||||
use frame_support::{
|
||||
assert_noop, assert_ok, parameter_types, weights::Weight, traits::OnInitialize
|
||||
assert_noop, assert_ok, parameter_types, weights::Weight, traits::OnInitialize,
|
||||
PalletId
|
||||
};
|
||||
|
||||
use sp_core::H256;
|
||||
use sp_runtime::{
|
||||
Perbill, ModuleId,
|
||||
Perbill,
|
||||
testing::Header,
|
||||
traits::{BlakeTwo256, IdentityLookup, BadOrigin},
|
||||
};
|
||||
@@ -103,11 +104,11 @@ parameter_types! {
|
||||
pub const SpendPeriod: u64 = 2;
|
||||
pub const Burn: Permill = Permill::from_percent(50);
|
||||
pub const DataDepositPerByte: u64 = 1;
|
||||
pub const TreasuryModuleId: ModuleId = ModuleId(*b"py/trsry");
|
||||
pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry");
|
||||
}
|
||||
// impl pallet_treasury::Config for Test {
|
||||
impl pallet_treasury::Config for Test {
|
||||
type ModuleId = TreasuryModuleId;
|
||||
type PalletId = TreasuryPalletId;
|
||||
type Currency = pallet_balances::Pallet<Test>;
|
||||
type ApproveOrigin = frame_system::EnsureRoot<u128>;
|
||||
type RejectOrigin = frame_system::EnsureRoot<u128>;
|
||||
|
||||
@@ -175,7 +175,7 @@ pub trait Config: frame_system::Config {
|
||||
type Event: From<Event<Self>> + Into<<Self as frame_system::Config>::Event>;
|
||||
|
||||
/// Identifier for the elections-phragmen pallet's lock
|
||||
type ModuleId: Get<LockIdentifier>;
|
||||
type PalletId: Get<LockIdentifier>;
|
||||
|
||||
/// The currency that people are electing with.
|
||||
type Currency:
|
||||
@@ -375,7 +375,7 @@ decl_module! {
|
||||
const DesiredMembers: u32 = T::DesiredMembers::get();
|
||||
const DesiredRunnersUp: u32 = T::DesiredRunnersUp::get();
|
||||
const TermDuration: T::BlockNumber = T::TermDuration::get();
|
||||
const ModuleId: LockIdentifier = T::ModuleId::get();
|
||||
const PalletId: LockIdentifier = T::PalletId::get();
|
||||
|
||||
/// Vote for a set of candidates for the upcoming round of election. This can be called to
|
||||
/// set the initial votes, or update already existing votes.
|
||||
@@ -452,7 +452,7 @@ decl_module! {
|
||||
// Amount to be locked up.
|
||||
let locked_stake = value.min(T::Currency::total_balance(&who));
|
||||
T::Currency::set_lock(
|
||||
T::ModuleId::get(),
|
||||
T::PalletId::get(),
|
||||
&who,
|
||||
locked_stake,
|
||||
WithdrawReasons::all(),
|
||||
@@ -807,7 +807,7 @@ impl<T: Config> Module<T> {
|
||||
let Voter { deposit, .. } = <Voting<T>>::take(who);
|
||||
|
||||
// remove storage, lock and unreserve.
|
||||
T::Currency::remove_lock(T::ModuleId::get(), who);
|
||||
T::Currency::remove_lock(T::PalletId::get(), who);
|
||||
|
||||
// NOTE: we could check the deposit amount before removing and skip if zero, but it will be
|
||||
// a noop anyhow.
|
||||
@@ -1158,11 +1158,11 @@ mod tests {
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const ElectionsPhragmenModuleId: LockIdentifier = *b"phrelect";
|
||||
pub const ElectionsPhragmenPalletId: LockIdentifier = *b"phrelect";
|
||||
}
|
||||
|
||||
impl Config for Test {
|
||||
type ModuleId = ElectionsPhragmenModuleId;
|
||||
type PalletId = ElectionsPhragmenPalletId;
|
||||
type Event = Event;
|
||||
type Currency = Balances;
|
||||
type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote;
|
||||
@@ -1313,7 +1313,7 @@ mod tests {
|
||||
.get(0)
|
||||
.cloned()
|
||||
.map(|lock| {
|
||||
assert_eq!(lock.id, ElectionsPhragmenModuleId::get());
|
||||
assert_eq!(lock.id, ElectionsPhragmenPalletId::get());
|
||||
lock.amount
|
||||
})
|
||||
.unwrap_or_default()
|
||||
|
||||
@@ -156,7 +156,7 @@ pub trait Config: frame_system::Config {
|
||||
type Event: From<Event<Self>> + Into<<Self as frame_system::Config>::Event>;
|
||||
|
||||
/// Identifier for the elections pallet's lock
|
||||
type ModuleId: Get<LockIdentifier>;
|
||||
type PalletId: Get<LockIdentifier>;
|
||||
|
||||
/// The currency that people are electing with.
|
||||
type Currency:
|
||||
@@ -391,7 +391,7 @@ decl_module! {
|
||||
/// The chunk size of the approval vector.
|
||||
const APPROVAL_SET_SIZE: u32 = APPROVAL_SET_SIZE as u32;
|
||||
|
||||
const ModuleId: LockIdentifier = T::ModuleId::get();
|
||||
const PalletId: LockIdentifier = T::PalletId::get();
|
||||
|
||||
fn deposit_event() = default;
|
||||
|
||||
@@ -491,7 +491,7 @@ decl_module! {
|
||||
);
|
||||
|
||||
T::Currency::remove_lock(
|
||||
T::ModuleId::get(),
|
||||
T::PalletId::get(),
|
||||
if valid { &who } else { &reporter }
|
||||
);
|
||||
|
||||
@@ -529,7 +529,7 @@ decl_module! {
|
||||
|
||||
Self::remove_voter(&who, index);
|
||||
T::Currency::unreserve(&who, T::VotingBond::get());
|
||||
T::Currency::remove_lock(T::ModuleId::get(), &who);
|
||||
T::Currency::remove_lock(T::PalletId::get(), &who);
|
||||
}
|
||||
|
||||
/// Submit oneself for candidacy.
|
||||
@@ -890,7 +890,7 @@ impl<T: Config> Module<T> {
|
||||
}
|
||||
|
||||
T::Currency::set_lock(
|
||||
T::ModuleId::get(),
|
||||
T::PalletId::get(),
|
||||
&who,
|
||||
locked_balance,
|
||||
WithdrawReasons::all(),
|
||||
|
||||
@@ -103,7 +103,7 @@ impl ChangeMembers<u64> for TestChangeMembers {
|
||||
}
|
||||
|
||||
parameter_types!{
|
||||
pub const ElectionModuleId: LockIdentifier = *b"py/elect";
|
||||
pub const ElectionPalletId: LockIdentifier = *b"py/elect";
|
||||
}
|
||||
|
||||
impl elections::Config for Test {
|
||||
@@ -123,7 +123,7 @@ impl elections::Config for Test {
|
||||
type InactiveGracePeriod = InactiveGracePeriod;
|
||||
type VotingPeriod = VotingPeriod;
|
||||
type DecayRatio = DecayRatio;
|
||||
type ModuleId = ElectionModuleId;
|
||||
type PalletId = ElectionPalletId;
|
||||
}
|
||||
|
||||
pub type Block = sp_runtime::generic::Block<Header, UncheckedExtrinsic>;
|
||||
|
||||
@@ -56,7 +56,7 @@ pub mod weights;
|
||||
|
||||
use sp_std::prelude::*;
|
||||
use sp_runtime::{
|
||||
DispatchError, ModuleId,
|
||||
DispatchError,
|
||||
traits::{AccountIdConversion, Saturating, Zero},
|
||||
};
|
||||
use frame_support::{
|
||||
@@ -66,7 +66,7 @@ use frame_support::{
|
||||
Currency, ReservableCurrency, Get, EnsureOrigin, ExistenceRequirement::KeepAlive, Randomness,
|
||||
},
|
||||
};
|
||||
use frame_support::weights::Weight;
|
||||
use frame_support::{weights::Weight, PalletId};
|
||||
use frame_system::ensure_signed;
|
||||
use codec::{Encode, Decode};
|
||||
pub use weights::WeightInfo;
|
||||
@@ -76,7 +76,7 @@ type BalanceOf<T> = <<T as Config>::Currency as Currency<<T as frame_system::Con
|
||||
/// The module's config trait.
|
||||
pub trait Config: frame_system::Config {
|
||||
/// The Lottery's module id
|
||||
type ModuleId: Get<ModuleId>;
|
||||
type PalletId: Get<PalletId>;
|
||||
|
||||
/// A dispatchable call.
|
||||
type Call: Parameter + Dispatchable<Origin=Self::Origin> + GetDispatchInfo + From<frame_system::Call<Self>>;
|
||||
@@ -211,7 +211,7 @@ decl_module! {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system = frame_system {
|
||||
type Error = Error<T>;
|
||||
|
||||
const ModuleId: ModuleId = T::ModuleId::get();
|
||||
const PalletId: PalletId = T::PalletId::get();
|
||||
const MaxCalls: u32 = T::MaxCalls::get() as u32;
|
||||
|
||||
fn deposit_event() = default;
|
||||
@@ -361,7 +361,7 @@ impl<T: Config> 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 {
|
||||
T::ModuleId::get().into_account()
|
||||
T::PalletId::get().into_account()
|
||||
}
|
||||
|
||||
/// Return the pot account and amount of money in the pot.
|
||||
@@ -449,7 +449,7 @@ impl<T: Config> Module<T> {
|
||||
// TODO: deal with randomness freshness
|
||||
// https://github.com/paritytech/substrate/issues/8311
|
||||
fn generate_random_number(seed: u32) -> u32 {
|
||||
let (random_seed, _) = T::Randomness::random(&(T::ModuleId::get(), seed).encode());
|
||||
let (random_seed, _) = T::Randomness::random(&(T::PalletId::get(), seed).encode());
|
||||
let random_number = <u32>::decode(&mut random_seed.as_ref())
|
||||
.expect("secure hashes should always be bigger than u32; qed");
|
||||
random_number
|
||||
|
||||
@@ -96,13 +96,13 @@ impl pallet_balances::Config for Test {
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const LotteryModuleId: ModuleId = ModuleId(*b"py/lotto");
|
||||
pub const LotteryPalletId: PalletId = PalletId(*b"py/lotto");
|
||||
pub const MaxCalls: usize = 2;
|
||||
pub const MaxGenerateRandom: u32 = 10;
|
||||
}
|
||||
|
||||
impl Config for Test {
|
||||
type ModuleId = LotteryModuleId;
|
||||
type PalletId = LotteryPalletId;
|
||||
type Call = Call;
|
||||
type Currency = Balances;
|
||||
type Randomness = TestRandomness<Self>;
|
||||
|
||||
@@ -254,13 +254,13 @@ mod tests;
|
||||
use rand_chacha::{rand_core::{RngCore, SeedableRng}, ChaChaRng};
|
||||
use sp_std::prelude::*;
|
||||
use codec::{Encode, Decode};
|
||||
use sp_runtime::{Percent, ModuleId, RuntimeDebug,
|
||||
use sp_runtime::{Percent, RuntimeDebug,
|
||||
traits::{
|
||||
StaticLookup, AccountIdConversion, Saturating, Zero, IntegerSquareRoot, Hash,
|
||||
TrailingZeroInput, CheckedSub
|
||||
}
|
||||
};
|
||||
use frame_support::{decl_error, decl_module, decl_storage, decl_event, ensure, dispatch::DispatchResult};
|
||||
use frame_support::{decl_error, decl_module, decl_storage, decl_event, ensure, dispatch::DispatchResult, PalletId};
|
||||
use frame_support::weights::Weight;
|
||||
use frame_support::traits::{
|
||||
Currency, ReservableCurrency, Randomness, Get, ChangeMembers, BalanceStatus,
|
||||
@@ -277,7 +277,7 @@ pub trait Config<I = DefaultInstance>: system::Config {
|
||||
type Event: From<Event<Self, I>> + Into<<Self as system::Config>::Event>;
|
||||
|
||||
/// The societies's module id
|
||||
type ModuleId: Get<ModuleId>;
|
||||
type PalletId: Get<PalletId>;
|
||||
|
||||
/// The currency type used for bidding.
|
||||
type Currency: ReservableCurrency<Self::AccountId>;
|
||||
@@ -498,7 +498,7 @@ decl_module! {
|
||||
const ChallengePeriod: T::BlockNumber = T::ChallengePeriod::get();
|
||||
|
||||
/// The societies's module id
|
||||
const ModuleId: ModuleId = T::ModuleId::get();
|
||||
const PalletId: PalletId = T::PalletId::get();
|
||||
|
||||
/// Maximum candidate intake per round.
|
||||
const MaxCandidateIntake: u32 = T::MaxCandidateIntake::get();
|
||||
@@ -1601,7 +1601,7 @@ impl<T: Config<I>, I: Instance> Module<T, I> {
|
||||
/// 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 {
|
||||
T::ModuleId::get().into_account()
|
||||
T::PalletId::get().into_account()
|
||||
}
|
||||
|
||||
/// The account ID of the payouts pot. This is where payouts are made from.
|
||||
@@ -1609,7 +1609,7 @@ impl<T: Config<I>, I: Instance> Module<T, I> {
|
||||
/// 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 payouts() -> T::AccountId {
|
||||
T::ModuleId::get().into_sub_account(b"payouts")
|
||||
T::PalletId::get().into_sub_account(b"payouts")
|
||||
}
|
||||
|
||||
/// Return the duration of the lock, in blocks, with the given number of members.
|
||||
|
||||
@@ -58,7 +58,7 @@ parameter_types! {
|
||||
pub const BlockHashCount: u64 = 250;
|
||||
pub const ExistentialDeposit: u64 = 1;
|
||||
pub const MaxCandidateIntake: u32 = 10;
|
||||
pub const SocietyModuleId: ModuleId = ModuleId(*b"py/socie");
|
||||
pub const SocietyPalletId: PalletId = PalletId(*b"py/socie");
|
||||
pub BlockWeights: frame_system::limits::BlockWeights =
|
||||
frame_system::limits::BlockWeights::simple_max(1024);
|
||||
}
|
||||
@@ -119,7 +119,7 @@ impl Config for Test {
|
||||
type SuspensionJudgementOrigin = EnsureSignedBy<SuspensionJudgementSetAccount, u128>;
|
||||
type ChallengePeriod = ChallengePeriod;
|
||||
type MaxCandidateIntake = MaxCandidateIntake;
|
||||
type ModuleId = SocietyModuleId;
|
||||
type PalletId = SocietyPalletId;
|
||||
}
|
||||
|
||||
pub struct EnvBuilder {
|
||||
|
||||
@@ -80,6 +80,9 @@ pub use self::storage::{
|
||||
pub use self::dispatch::{Parameter, Callable};
|
||||
pub use sp_runtime::{self, ConsensusEngineId, print, traits::Printable};
|
||||
|
||||
use codec::{Encode, Decode};
|
||||
use sp_runtime::TypeId;
|
||||
|
||||
/// A unified log target for support operations.
|
||||
pub const LOG_TARGET: &'static str = "runtime::frame-support";
|
||||
|
||||
@@ -87,6 +90,14 @@ pub const LOG_TARGET: &'static str = "runtime::frame-support";
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
pub enum Never {}
|
||||
|
||||
/// A pallet identifier. These are per pallet and should be stored in a registry somewhere.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Encode, Decode)]
|
||||
pub struct PalletId(pub [u8; 8]);
|
||||
|
||||
impl TypeId for PalletId {
|
||||
const TYPE_ID: [u8; 4] = *b"modl";
|
||||
}
|
||||
|
||||
/// Generate a new type alias for [`storage::types::value::StorageValue`],
|
||||
/// [`storage::types::value::StorageMap`] and [`storage::types::value::StorageDoubleMap`].
|
||||
///
|
||||
|
||||
@@ -444,7 +444,7 @@ impl<T: Config> 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 {
|
||||
T::ModuleId::get().into_account()
|
||||
T::PalletId::get().into_account()
|
||||
}
|
||||
|
||||
/// Given a mutable reference to an `OpenTip`, insert the tip into it and check whether it
|
||||
|
||||
@@ -22,11 +22,15 @@
|
||||
use crate as tips;
|
||||
use super::*;
|
||||
use std::cell::RefCell;
|
||||
use frame_support::{assert_noop, assert_ok, parameter_types, weights::Weight, traits::Contains};
|
||||
use frame_support::{
|
||||
assert_noop, assert_ok, parameter_types,
|
||||
weights::Weight, traits::Contains,
|
||||
PalletId
|
||||
};
|
||||
use sp_runtime::Permill;
|
||||
use sp_core::H256;
|
||||
use sp_runtime::{
|
||||
Perbill, ModuleId,
|
||||
Perbill,
|
||||
testing::Header,
|
||||
traits::{BlakeTwo256, IdentityLookup, BadOrigin},
|
||||
};
|
||||
@@ -121,11 +125,11 @@ parameter_types! {
|
||||
pub const SpendPeriod: u64 = 2;
|
||||
pub const Burn: Permill = Permill::from_percent(50);
|
||||
pub const DataDepositPerByte: u64 = 1;
|
||||
pub const TreasuryModuleId: ModuleId = ModuleId(*b"py/trsry");
|
||||
pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry");
|
||||
pub const MaximumReasonLength: u32 = 16384;
|
||||
}
|
||||
impl pallet_treasury::Config for Test {
|
||||
type ModuleId = TreasuryModuleId;
|
||||
type PalletId = TreasuryPalletId;
|
||||
type Currency = pallet_balances::Pallet<Test>;
|
||||
type ApproveOrigin = frame_system::EnsureRoot<u128>;
|
||||
type RejectOrigin = frame_system::EnsureRoot<u128>;
|
||||
|
||||
@@ -66,14 +66,17 @@ pub mod weights;
|
||||
#[cfg(feature = "std")]
|
||||
use serde::{Serialize, Deserialize};
|
||||
use sp_std::prelude::*;
|
||||
use frame_support::{decl_module, decl_storage, decl_event, ensure, print, decl_error};
|
||||
use frame_support::{decl_module, decl_storage, decl_event, ensure, print, decl_error, PalletId};
|
||||
use frame_support::traits::{
|
||||
Currency, Get, Imbalance, OnUnbalanced, ExistenceRequirement::KeepAlive,
|
||||
ReservableCurrency, WithdrawReasons
|
||||
};
|
||||
use sp_runtime::{Permill, ModuleId, RuntimeDebug, traits::{
|
||||
Zero, StaticLookup, AccountIdConversion, Saturating
|
||||
}};
|
||||
use sp_runtime::{
|
||||
Permill, RuntimeDebug,
|
||||
traits::{
|
||||
Zero, StaticLookup, AccountIdConversion, Saturating
|
||||
}
|
||||
};
|
||||
use frame_support::weights::{Weight, DispatchClass};
|
||||
use frame_support::traits::EnsureOrigin;
|
||||
use codec::{Encode, Decode};
|
||||
@@ -89,7 +92,7 @@ pub type NegativeImbalanceOf<T, I=DefaultInstance> =
|
||||
|
||||
pub trait Config<I=DefaultInstance>: frame_system::Config {
|
||||
/// The treasury's module id, used for deriving its sovereign account ID.
|
||||
type ModuleId: Get<ModuleId>;
|
||||
type PalletId: Get<PalletId>;
|
||||
|
||||
/// The staking balance.
|
||||
type Currency: Currency<Self::AccountId> + ReservableCurrency<Self::AccountId>;
|
||||
@@ -246,7 +249,7 @@ decl_module! {
|
||||
const Burn: Permill = T::Burn::get();
|
||||
|
||||
/// The treasury's module id, used for deriving its sovereign account ID.
|
||||
const ModuleId: ModuleId = T::ModuleId::get();
|
||||
const PalletId: PalletId = T::PalletId::get();
|
||||
|
||||
type Error = Error<T, I>;
|
||||
|
||||
@@ -346,7 +349,7 @@ impl<T: Config<I>, I: Instance> Module<T, I> {
|
||||
/// 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 {
|
||||
T::ModuleId::get().into_account()
|
||||
T::PalletId::get().into_account()
|
||||
}
|
||||
|
||||
/// The needed bond for a proposal whose spend is `value`.
|
||||
|
||||
@@ -24,12 +24,11 @@ use super::*;
|
||||
use std::cell::RefCell;
|
||||
use frame_support::{
|
||||
assert_noop, assert_ok, parameter_types,
|
||||
traits::OnInitialize,
|
||||
traits::OnInitialize, PalletId
|
||||
};
|
||||
|
||||
use sp_core::H256;
|
||||
use sp_runtime::{
|
||||
ModuleId,
|
||||
testing::Header,
|
||||
traits::{BlakeTwo256, IdentityLookup},
|
||||
};
|
||||
@@ -99,13 +98,13 @@ parameter_types! {
|
||||
pub const ProposalBondMinimum: u64 = 1;
|
||||
pub const SpendPeriod: u64 = 2;
|
||||
pub const Burn: Permill = Permill::from_percent(50);
|
||||
pub const TreasuryModuleId: ModuleId = ModuleId(*b"py/trsry");
|
||||
pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry");
|
||||
pub const BountyUpdatePeriod: u32 = 20;
|
||||
pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);
|
||||
pub const BountyValueMinimum: u64 = 1;
|
||||
}
|
||||
impl Config for Test {
|
||||
type ModuleId = TreasuryModuleId;
|
||||
type PalletId = TreasuryPalletId;
|
||||
type Currency = pallet_balances::Pallet<Test>;
|
||||
type ApproveOrigin = frame_system::EnsureRoot<u128>;
|
||||
type RejectOrigin = frame_system::EnsureRoot<u128>;
|
||||
|
||||
@@ -158,14 +158,6 @@ impl From<Justification> for Justifications {
|
||||
|
||||
use traits::{Verify, Lazy};
|
||||
|
||||
/// A module identifier. These are per module and should be stored in a registry somewhere.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Encode, Decode)]
|
||||
pub struct ModuleId(pub [u8; 8]);
|
||||
|
||||
impl TypeId for ModuleId {
|
||||
const TYPE_ID: [u8; 4] = *b"modl";
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub use serde::{Serialize, Deserialize, de::DeserializeOwned};
|
||||
use crate::traits::IdentifyAccount;
|
||||
|
||||
@@ -16,6 +16,7 @@ sc-cli = { version = "0.9.0", path = "../../../client/cli" }
|
||||
sp-runtime = { version = "3.0.0", path = "../../../primitives/runtime" }
|
||||
structopt = "0.3.8"
|
||||
frame-system = { version = "3.0.0", path = "../../../frame/system" }
|
||||
frame-support = { version = "3.0.0", path = "../../../frame/support" }
|
||||
|
||||
[dev-dependencies]
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
//! frame-system CLI utilities
|
||||
|
||||
mod module_id;
|
||||
mod pallet_id;
|
||||
|
||||
pub use module_id::ModuleIdCmd;
|
||||
pub use pallet_id::PalletIdCmd;
|
||||
|
||||
|
||||
+8
-8
@@ -15,25 +15,25 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Implementation of the `moduleid` subcommand
|
||||
//! Implementation of the `palletid` subcommand
|
||||
|
||||
use sc_cli::{
|
||||
Error, utils::print_from_uri, CryptoSchemeFlag,
|
||||
OutputTypeFlag, KeystoreParams, with_crypto_scheme,
|
||||
};
|
||||
use sp_runtime::ModuleId;
|
||||
use sp_runtime::traits::AccountIdConversion;
|
||||
use sp_core::crypto::{Ss58Codec, Ss58AddressFormat};
|
||||
use std::convert::{TryInto, TryFrom};
|
||||
use structopt::StructOpt;
|
||||
use frame_support::PalletId;
|
||||
|
||||
/// The `moduleid` command
|
||||
/// The `palletid` command
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(
|
||||
name = "moduleid",
|
||||
name = "palletid",
|
||||
about = "Inspect a module ID address"
|
||||
)]
|
||||
pub struct ModuleIdCmd {
|
||||
pub struct PalletIdCmd {
|
||||
/// The module ID used to derive the account
|
||||
id: String,
|
||||
|
||||
@@ -60,7 +60,7 @@ pub struct ModuleIdCmd {
|
||||
pub keystore_params: KeystoreParams,
|
||||
}
|
||||
|
||||
impl ModuleIdCmd {
|
||||
impl PalletIdCmd {
|
||||
/// runs the command
|
||||
pub fn run<R>(&self) -> Result<(), Error>
|
||||
where
|
||||
@@ -74,9 +74,9 @@ impl ModuleIdCmd {
|
||||
|
||||
let id_fixed_array: [u8; 8] = self.id.as_bytes()
|
||||
.try_into()
|
||||
.map_err(|_| "Cannot convert argument to moduleid: argument should be 8-character string")?;
|
||||
.map_err(|_| "Cannot convert argument to palletid: argument should be 8-character string")?;
|
||||
|
||||
let account_id: R::AccountId = ModuleId(id_fixed_array).into_account();
|
||||
let account_id: R::AccountId = PalletId(id_fixed_array).into_account();
|
||||
|
||||
with_crypto_scheme!(
|
||||
self.crypto_scheme.scheme,
|
||||
Reference in New Issue
Block a user