mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-20 07:01:02 +00:00
Rename pallet trait Trait to Config (#7599)
* rename Trait to Config * add test asserting using Trait is still valid. * fix ui tests
This commit is contained in:
committed by
GitHub
parent
dd3c84c362
commit
1cbfc9257f
@@ -14,9 +14,9 @@ mod mock;
|
||||
mod tests;
|
||||
|
||||
/// Configure the pallet by specifying the parameters and types on which it depends.
|
||||
pub trait Trait: frame_system::Trait {
|
||||
pub trait Config: frame_system::Config {
|
||||
/// Because this pallet emits events, it depends on the runtime's definition of an event.
|
||||
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
|
||||
type Event: From<Event<Self>> + Into<<Self as frame_system::Config>::Event>;
|
||||
}
|
||||
|
||||
// The pallet's runtime storage items.
|
||||
@@ -25,7 +25,7 @@ decl_storage! {
|
||||
// A unique name is used to ensure that the pallet's storage items are isolated.
|
||||
// This name may be updated, but each pallet in the runtime must use a unique name.
|
||||
// ---------------------------------vvvvvvvvvvvvvv
|
||||
trait Store for Module<T: Trait> as TemplateModule {
|
||||
trait Store for Module<T: Config> as TemplateModule {
|
||||
// Learn more about declaring storage items:
|
||||
// https://substrate.dev/docs/en/knowledgebase/runtime/storage#declaring-storage-items
|
||||
Something get(fn something): Option<u32>;
|
||||
@@ -35,7 +35,7 @@ decl_storage! {
|
||||
// Pallets use events to inform users when important changes are made.
|
||||
// https://substrate.dev/docs/en/knowledgebase/runtime/events
|
||||
decl_event!(
|
||||
pub enum Event<T> where AccountId = <T as frame_system::Trait>::AccountId {
|
||||
pub enum Event<T> where AccountId = <T as frame_system::Config>::AccountId {
|
||||
/// Event documentation should end with an array that provides descriptive names for event
|
||||
/// parameters. [something, who]
|
||||
SomethingStored(u32, AccountId),
|
||||
@@ -44,7 +44,7 @@ decl_event!(
|
||||
|
||||
// Errors inform users that something went wrong.
|
||||
decl_error! {
|
||||
pub enum Error for Module<T: Trait> {
|
||||
pub enum Error for Module<T: Config> {
|
||||
/// Error names should be descriptive.
|
||||
NoneValue,
|
||||
/// Errors should have helpful documentation associated with them.
|
||||
@@ -56,7 +56,7 @@ decl_error! {
|
||||
// These functions materialize as "extrinsics", which are often compared to transactions.
|
||||
// Dispatchable functions must be annotated with a weight and must return a DispatchResult.
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin {
|
||||
// Errors must be initialized if they are used by the pallet.
|
||||
type Error = Error<T>;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::{Module, Trait};
|
||||
use crate::{Module, Config};
|
||||
use sp_core::H256;
|
||||
use frame_support::{impl_outer_origin, parameter_types, weights::Weight};
|
||||
use sp_runtime::{
|
||||
@@ -21,7 +21,7 @@ parameter_types! {
|
||||
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
|
||||
}
|
||||
|
||||
impl system::Trait for Test {
|
||||
impl system::Config for Test {
|
||||
type BaseCallFilter = ();
|
||||
type Origin = Origin;
|
||||
type Call = ();
|
||||
@@ -49,7 +49,7 @@ impl system::Trait for Test {
|
||||
type SystemWeightInfo = ();
|
||||
}
|
||||
|
||||
impl Trait for Test {
|
||||
impl Config for Test {
|
||||
type Event = ();
|
||||
}
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ parameter_types! {
|
||||
|
||||
// Configure FRAME pallets to include in runtime.
|
||||
|
||||
impl frame_system::Trait for Runtime {
|
||||
impl frame_system::Config for Runtime {
|
||||
/// The basic call filter to use in dispatchable.
|
||||
type BaseCallFilter = ();
|
||||
/// The identifier used to distinguish between accounts.
|
||||
@@ -199,11 +199,11 @@ impl frame_system::Trait for Runtime {
|
||||
type SystemWeightInfo = ();
|
||||
}
|
||||
|
||||
impl pallet_aura::Trait for Runtime {
|
||||
impl pallet_aura::Config for Runtime {
|
||||
type AuthorityId = AuraId;
|
||||
}
|
||||
|
||||
impl pallet_grandpa::Trait for Runtime {
|
||||
impl pallet_grandpa::Config for Runtime {
|
||||
type Event = Event;
|
||||
type Call = Call;
|
||||
|
||||
@@ -226,7 +226,7 @@ parameter_types! {
|
||||
pub const MinimumPeriod: u64 = SLOT_DURATION / 2;
|
||||
}
|
||||
|
||||
impl pallet_timestamp::Trait for Runtime {
|
||||
impl pallet_timestamp::Config for Runtime {
|
||||
/// A timestamp: milliseconds since the unix epoch.
|
||||
type Moment = u64;
|
||||
type OnTimestampSet = Aura;
|
||||
@@ -239,7 +239,7 @@ parameter_types! {
|
||||
pub const MaxLocks: u32 = 50;
|
||||
}
|
||||
|
||||
impl pallet_balances::Trait for Runtime {
|
||||
impl pallet_balances::Config for Runtime {
|
||||
type MaxLocks = MaxLocks;
|
||||
/// The type for recording an account's balance.
|
||||
type Balance = Balance;
|
||||
@@ -255,20 +255,20 @@ parameter_types! {
|
||||
pub const TransactionByteFee: Balance = 1;
|
||||
}
|
||||
|
||||
impl pallet_transaction_payment::Trait for Runtime {
|
||||
impl pallet_transaction_payment::Config for Runtime {
|
||||
type OnChargeTransaction = CurrencyAdapter<Balances, ()>;
|
||||
type TransactionByteFee = TransactionByteFee;
|
||||
type WeightToFee = IdentityFee<Balance>;
|
||||
type FeeMultiplierUpdate = ();
|
||||
}
|
||||
|
||||
impl pallet_sudo::Trait for Runtime {
|
||||
impl pallet_sudo::Config for Runtime {
|
||||
type Event = Event;
|
||||
type Call = Call;
|
||||
}
|
||||
|
||||
/// Configure the pallet template in pallets/template.
|
||||
impl template::Trait for Runtime {
|
||||
impl template::Config for Runtime {
|
||||
type Event = Event;
|
||||
}
|
||||
|
||||
@@ -457,7 +457,7 @@ impl_runtime_apis! {
|
||||
use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};
|
||||
|
||||
use frame_system_benchmarking::Module as SystemBench;
|
||||
impl frame_system_benchmarking::Trait for Runtime {}
|
||||
impl frame_system_benchmarking::Config for Runtime {}
|
||||
|
||||
let whitelist: Vec<TrackedStorageKey> = vec![
|
||||
// Block Number
|
||||
|
||||
@@ -580,7 +580,7 @@ const CODE_TRANSFER: &str = r#"
|
||||
#[test]
|
||||
fn deploying_wasm_contract_should_work() {
|
||||
let transfer_code = wat::parse_str(CODE_TRANSFER).unwrap();
|
||||
let transfer_ch = <Runtime as frame_system::Trait>::Hashing::hash(&transfer_code);
|
||||
let transfer_ch = <Runtime as frame_system::Config>::Hashing::hash(&transfer_code);
|
||||
|
||||
let addr = pallet_contracts::Module::<Runtime>::contract_address(
|
||||
&charlie(),
|
||||
@@ -588,7 +588,7 @@ fn deploying_wasm_contract_should_work() {
|
||||
&[],
|
||||
);
|
||||
|
||||
let subsistence = pallet_contracts::Config::<Runtime>::subsistence_threshold_uncached();
|
||||
let subsistence = pallet_contracts::ConfigCache::<Runtime>::subsistence_threshold_uncached();
|
||||
|
||||
let b = construct_block(
|
||||
&mut new_test_ext(compact_code_unwrap(), false),
|
||||
|
||||
@@ -200,7 +200,7 @@ mod multiplier_tests {
|
||||
fm = next;
|
||||
iterations += 1;
|
||||
let fee =
|
||||
<Runtime as pallet_transaction_payment::Trait>::WeightToFee::calc(&tx_weight);
|
||||
<Runtime as pallet_transaction_payment::Config>::WeightToFee::calc(&tx_weight);
|
||||
let adjusted_fee = fm.saturating_mul_acc_int(fee);
|
||||
println!(
|
||||
"iteration {}, new fm = {:?}. Fee at this point is: {} units / {} millicents, \
|
||||
|
||||
@@ -156,7 +156,7 @@ parameter_types! {
|
||||
|
||||
const_assert!(AvailableBlockRatio::get().deconstruct() >= AVERAGE_ON_INITIALIZE_WEIGHT.deconstruct());
|
||||
|
||||
impl frame_system::Trait for Runtime {
|
||||
impl frame_system::Config for Runtime {
|
||||
type BaseCallFilter = ();
|
||||
type Origin = Origin;
|
||||
type Call = Call;
|
||||
@@ -184,7 +184,7 @@ impl frame_system::Trait for Runtime {
|
||||
type SystemWeightInfo = frame_system::weights::SubstrateWeight<Runtime>;
|
||||
}
|
||||
|
||||
impl pallet_utility::Trait for Runtime {
|
||||
impl pallet_utility::Config for Runtime {
|
||||
type Event = Event;
|
||||
type Call = Call;
|
||||
type WeightInfo = pallet_utility::weights::SubstrateWeight<Runtime>;
|
||||
@@ -198,7 +198,7 @@ parameter_types! {
|
||||
pub const MaxSignatories: u16 = 100;
|
||||
}
|
||||
|
||||
impl pallet_multisig::Trait for Runtime {
|
||||
impl pallet_multisig::Config for Runtime {
|
||||
type Event = Event;
|
||||
type Call = Call;
|
||||
type Currency = Balances;
|
||||
@@ -261,7 +261,7 @@ impl InstanceFilter<Call> for ProxyType {
|
||||
}
|
||||
}
|
||||
|
||||
impl pallet_proxy::Trait for Runtime {
|
||||
impl pallet_proxy::Config for Runtime {
|
||||
type Event = Event;
|
||||
type Call = Call;
|
||||
type Currency = Balances;
|
||||
@@ -281,7 +281,7 @@ parameter_types! {
|
||||
pub const MaxScheduledPerBlock: u32 = 50;
|
||||
}
|
||||
|
||||
impl pallet_scheduler::Trait for Runtime {
|
||||
impl pallet_scheduler::Config for Runtime {
|
||||
type Event = Event;
|
||||
type Origin = Origin;
|
||||
type PalletsOrigin = OriginCaller;
|
||||
@@ -297,7 +297,7 @@ parameter_types! {
|
||||
pub const ExpectedBlockTime: Moment = MILLISECS_PER_BLOCK;
|
||||
}
|
||||
|
||||
impl pallet_babe::Trait for Runtime {
|
||||
impl pallet_babe::Config for Runtime {
|
||||
type EpochDuration = EpochDuration;
|
||||
type ExpectedBlockTime = ExpectedBlockTime;
|
||||
type EpochChangeTrigger = pallet_babe::ExternalTrigger;
|
||||
@@ -324,7 +324,7 @@ parameter_types! {
|
||||
pub const IndexDeposit: Balance = 1 * DOLLARS;
|
||||
}
|
||||
|
||||
impl pallet_indices::Trait for Runtime {
|
||||
impl pallet_indices::Config for Runtime {
|
||||
type AccountIndex = AccountIndex;
|
||||
type Currency = Balances;
|
||||
type Deposit = IndexDeposit;
|
||||
@@ -339,7 +339,7 @@ parameter_types! {
|
||||
pub const MaxLocks: u32 = 50;
|
||||
}
|
||||
|
||||
impl pallet_balances::Trait for Runtime {
|
||||
impl pallet_balances::Config for Runtime {
|
||||
type MaxLocks = MaxLocks;
|
||||
type Balance = Balance;
|
||||
type DustRemoval = ();
|
||||
@@ -356,7 +356,7 @@ parameter_types! {
|
||||
pub MinimumMultiplier: Multiplier = Multiplier::saturating_from_rational(1, 1_000_000_000u128);
|
||||
}
|
||||
|
||||
impl pallet_transaction_payment::Trait for Runtime {
|
||||
impl pallet_transaction_payment::Config for Runtime {
|
||||
type OnChargeTransaction = CurrencyAdapter<Balances, DealWithFees>;
|
||||
type TransactionByteFee = TransactionByteFee;
|
||||
type WeightToFee = IdentityFee<Balance>;
|
||||
@@ -368,7 +368,7 @@ parameter_types! {
|
||||
pub const MinimumPeriod: Moment = SLOT_DURATION / 2;
|
||||
}
|
||||
|
||||
impl pallet_timestamp::Trait for Runtime {
|
||||
impl pallet_timestamp::Config for Runtime {
|
||||
type Moment = Moment;
|
||||
type OnTimestampSet = Babe;
|
||||
type MinimumPeriod = MinimumPeriod;
|
||||
@@ -379,7 +379,7 @@ parameter_types! {
|
||||
pub const UncleGenerations: BlockNumber = 5;
|
||||
}
|
||||
|
||||
impl pallet_authorship::Trait for Runtime {
|
||||
impl pallet_authorship::Config for Runtime {
|
||||
type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Babe>;
|
||||
type UncleGenerations = UncleGenerations;
|
||||
type FilterUncle = ();
|
||||
@@ -399,9 +399,9 @@ parameter_types! {
|
||||
pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(17);
|
||||
}
|
||||
|
||||
impl pallet_session::Trait for Runtime {
|
||||
impl pallet_session::Config for Runtime {
|
||||
type Event = Event;
|
||||
type ValidatorId = <Self as frame_system::Trait>::AccountId;
|
||||
type ValidatorId = <Self as frame_system::Config>::AccountId;
|
||||
type ValidatorIdOf = pallet_staking::StashOf<Self>;
|
||||
type ShouldEndSession = Babe;
|
||||
type NextSessionRotation = Babe;
|
||||
@@ -412,7 +412,7 @@ impl pallet_session::Trait for Runtime {
|
||||
type WeightInfo = pallet_session::weights::SubstrateWeight<Runtime>;
|
||||
}
|
||||
|
||||
impl pallet_session::historical::Trait for Runtime {
|
||||
impl pallet_session::historical::Config for Runtime {
|
||||
type FullIdentification = pallet_staking::Exposure<AccountId, Balance>;
|
||||
type FullIdentificationOf = pallet_staking::ExposureOf<Runtime>;
|
||||
}
|
||||
@@ -443,7 +443,7 @@ parameter_types! {
|
||||
.saturating_sub(ExtrinsicBaseWeight::get());
|
||||
}
|
||||
|
||||
impl pallet_staking::Trait for Runtime {
|
||||
impl pallet_staking::Config for Runtime {
|
||||
type Currency = Balances;
|
||||
type UnixTime = Timestamp;
|
||||
type CurrencyToVote = U128CurrencyToVote;
|
||||
@@ -489,7 +489,7 @@ parameter_types! {
|
||||
pub const MaxProposals: u32 = 100;
|
||||
}
|
||||
|
||||
impl pallet_democracy::Trait for Runtime {
|
||||
impl pallet_democracy::Config for Runtime {
|
||||
type Proposal = Call;
|
||||
type Event = Event;
|
||||
type Currency = Balances;
|
||||
@@ -541,7 +541,7 @@ parameter_types! {
|
||||
}
|
||||
|
||||
type CouncilCollective = pallet_collective::Instance1;
|
||||
impl pallet_collective::Trait<CouncilCollective> for Runtime {
|
||||
impl pallet_collective::Config<CouncilCollective> for Runtime {
|
||||
type Origin = Origin;
|
||||
type Proposal = Call;
|
||||
type Event = Event;
|
||||
@@ -564,7 +564,7 @@ parameter_types! {
|
||||
// Make sure that there are no more than `MaxMembers` members elected via elections-phragmen.
|
||||
const_assert!(DesiredMembers::get() <= CouncilMaxMembers::get());
|
||||
|
||||
impl pallet_elections_phragmen::Trait for Runtime {
|
||||
impl pallet_elections_phragmen::Config for Runtime {
|
||||
type Event = Event;
|
||||
type ModuleId = ElectionsPhragmenModuleId;
|
||||
type Currency = Balances;
|
||||
@@ -591,7 +591,7 @@ parameter_types! {
|
||||
}
|
||||
|
||||
type TechnicalCollective = pallet_collective::Instance2;
|
||||
impl pallet_collective::Trait<TechnicalCollective> for Runtime {
|
||||
impl pallet_collective::Config<TechnicalCollective> for Runtime {
|
||||
type Origin = Origin;
|
||||
type Proposal = Call;
|
||||
type Event = Event;
|
||||
@@ -607,7 +607,7 @@ type EnsureRootOrHalfCouncil = EnsureOneOf<
|
||||
EnsureRoot<AccountId>,
|
||||
pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>
|
||||
>;
|
||||
impl pallet_membership::Trait<pallet_membership::Instance1> for Runtime {
|
||||
impl pallet_membership::Config<pallet_membership::Instance1> for Runtime {
|
||||
type Event = Event;
|
||||
type AddOrigin = EnsureRootOrHalfCouncil;
|
||||
type RemoveOrigin = EnsureRootOrHalfCouncil;
|
||||
@@ -636,7 +636,7 @@ parameter_types! {
|
||||
pub const BountyValueMinimum: Balance = 5 * DOLLARS;
|
||||
}
|
||||
|
||||
impl pallet_treasury::Trait for Runtime {
|
||||
impl pallet_treasury::Config for Runtime {
|
||||
type ModuleId = TreasuryModuleId;
|
||||
type Currency = Balances;
|
||||
type ApproveOrigin = EnsureOneOf<
|
||||
@@ -681,7 +681,7 @@ parameter_types! {
|
||||
pub const MaxValueSize: u32 = 16 * 1024;
|
||||
}
|
||||
|
||||
impl pallet_contracts::Trait for Runtime {
|
||||
impl pallet_contracts::Config for Runtime {
|
||||
type Time = Timestamp;
|
||||
type Randomness = RandomnessCollectiveFlip;
|
||||
type Currency = Balances;
|
||||
@@ -699,7 +699,7 @@ impl pallet_contracts::Trait for Runtime {
|
||||
type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;
|
||||
}
|
||||
|
||||
impl pallet_sudo::Trait for Runtime {
|
||||
impl pallet_sudo::Config for Runtime {
|
||||
type Event = Event;
|
||||
type Call = Call;
|
||||
}
|
||||
@@ -769,7 +769,7 @@ impl<C> frame_system::offchain::SendTransactionTypes<C> for Runtime where
|
||||
type OverarchingCall = Call;
|
||||
}
|
||||
|
||||
impl pallet_im_online::Trait for Runtime {
|
||||
impl pallet_im_online::Config for Runtime {
|
||||
type AuthorityId = ImOnlineId;
|
||||
type Event = Event;
|
||||
type SessionDuration = SessionDuration;
|
||||
@@ -782,16 +782,16 @@ parameter_types! {
|
||||
pub OffencesWeightSoftLimit: Weight = Perbill::from_percent(60) * MaximumBlockWeight::get();
|
||||
}
|
||||
|
||||
impl pallet_offences::Trait for Runtime {
|
||||
impl pallet_offences::Config for Runtime {
|
||||
type Event = Event;
|
||||
type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
|
||||
type OnOffenceHandler = Staking;
|
||||
type WeightSoftLimit = OffencesWeightSoftLimit;
|
||||
}
|
||||
|
||||
impl pallet_authority_discovery::Trait for Runtime {}
|
||||
impl pallet_authority_discovery::Config for Runtime {}
|
||||
|
||||
impl pallet_grandpa::Trait for Runtime {
|
||||
impl pallet_grandpa::Config for Runtime {
|
||||
type Event = Event;
|
||||
type Call = Call;
|
||||
|
||||
@@ -820,7 +820,7 @@ parameter_types! {
|
||||
pub const MaxRegistrars: u32 = 20;
|
||||
}
|
||||
|
||||
impl pallet_identity::Trait for Runtime {
|
||||
impl pallet_identity::Config for Runtime {
|
||||
type Event = Event;
|
||||
type Currency = Balances;
|
||||
type BasicDeposit = BasicDeposit;
|
||||
@@ -842,7 +842,7 @@ parameter_types! {
|
||||
pub const RecoveryDeposit: Balance = 5 * DOLLARS;
|
||||
}
|
||||
|
||||
impl pallet_recovery::Trait for Runtime {
|
||||
impl pallet_recovery::Config for Runtime {
|
||||
type Event = Event;
|
||||
type Call = Call;
|
||||
type Currency = Balances;
|
||||
@@ -863,7 +863,7 @@ parameter_types! {
|
||||
pub const SocietyModuleId: ModuleId = ModuleId(*b"py/socie");
|
||||
}
|
||||
|
||||
impl pallet_society::Trait for Runtime {
|
||||
impl pallet_society::Config for Runtime {
|
||||
type Event = Event;
|
||||
type ModuleId = SocietyModuleId;
|
||||
type Currency = Balances;
|
||||
@@ -884,7 +884,7 @@ parameter_types! {
|
||||
pub const MinVestedTransfer: Balance = 100 * DOLLARS;
|
||||
}
|
||||
|
||||
impl pallet_vesting::Trait for Runtime {
|
||||
impl pallet_vesting::Config for Runtime {
|
||||
type Event = Event;
|
||||
type Currency = Balances;
|
||||
type BlockNumberToBalance = ConvertInto;
|
||||
@@ -1173,9 +1173,9 @@ impl_runtime_apis! {
|
||||
use pallet_offences_benchmarking::Module as OffencesBench;
|
||||
use frame_system_benchmarking::Module as SystemBench;
|
||||
|
||||
impl pallet_session_benchmarking::Trait for Runtime {}
|
||||
impl pallet_offences_benchmarking::Trait for Runtime {}
|
||||
impl frame_system_benchmarking::Trait for Runtime {}
|
||||
impl pallet_session_benchmarking::Config for Runtime {}
|
||||
impl pallet_offences_benchmarking::Config for Runtime {}
|
||||
impl frame_system_benchmarking::Config for Runtime {}
|
||||
|
||||
let whitelist: Vec<TrackedStorageKey> = vec![
|
||||
// Block Number
|
||||
|
||||
@@ -63,7 +63,7 @@ pub enum Subkey {
|
||||
/// Run the subkey command, given the apropriate runtime.
|
||||
pub fn run<R>() -> Result<(), Error>
|
||||
where
|
||||
R: frame_system::Trait,
|
||||
R: frame_system::Config,
|
||||
R::AccountId: Ss58Codec
|
||||
{
|
||||
match Subkey::from_args() {
|
||||
|
||||
Reference in New Issue
Block a user