Skip to content

Commit 2169c00

Browse files
gui1117darkfriend77
authored andcommitted
Rename pallet trait Trait to Config (paritytech#7599)
* rename Trait to Config * add test asserting using Trait is still valid. * fix ui tests
1 parent 0daed49 commit 2169c00

File tree

200 files changed

+1767
-1607
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

200 files changed

+1767
-1607
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/node-template/pallets/template/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ mod mock;
1414
mod tests;
1515

1616
/// Configure the pallet by specifying the parameters and types on which it depends.
17-
pub trait Trait: frame_system::Trait {
17+
pub trait Config: frame_system::Config {
1818
/// Because this pallet emits events, it depends on the runtime's definition of an event.
19-
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
19+
type Event: From<Event<Self>> + Into<<Self as frame_system::Config>::Event>;
2020
}
2121

2222
// The pallet's runtime storage items.
@@ -25,7 +25,7 @@ decl_storage! {
2525
// A unique name is used to ensure that the pallet's storage items are isolated.
2626
// This name may be updated, but each pallet in the runtime must use a unique name.
2727
// ---------------------------------vvvvvvvvvvvvvv
28-
trait Store for Module<T: Trait> as TemplateModule {
28+
trait Store for Module<T: Config> as TemplateModule {
2929
// Learn more about declaring storage items:
3030
// https://substrate.dev/docs/en/knowledgebase/runtime/storage#declaring-storage-items
3131
Something get(fn something): Option<u32>;
@@ -35,7 +35,7 @@ decl_storage! {
3535
// Pallets use events to inform users when important changes are made.
3636
// https://substrate.dev/docs/en/knowledgebase/runtime/events
3737
decl_event!(
38-
pub enum Event<T> where AccountId = <T as frame_system::Trait>::AccountId {
38+
pub enum Event<T> where AccountId = <T as frame_system::Config>::AccountId {
3939
/// Event documentation should end with an array that provides descriptive names for event
4040
/// parameters. [something, who]
4141
SomethingStored(u32, AccountId),
@@ -44,7 +44,7 @@ decl_event!(
4444

4545
// Errors inform users that something went wrong.
4646
decl_error! {
47-
pub enum Error for Module<T: Trait> {
47+
pub enum Error for Module<T: Config> {
4848
/// Error names should be descriptive.
4949
NoneValue,
5050
/// Errors should have helpful documentation associated with them.
@@ -56,7 +56,7 @@ decl_error! {
5656
// These functions materialize as "extrinsics", which are often compared to transactions.
5757
// Dispatchable functions must be annotated with a weight and must return a DispatchResult.
5858
decl_module! {
59-
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
59+
pub struct Module<T: Config> for enum Call where origin: T::Origin {
6060
// Errors must be initialized if they are used by the pallet.
6161
type Error = Error<T>;
6262

bin/node-template/pallets/template/src/mock.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{Module, Trait};
1+
use crate::{Module, Config};
22
use sp_core::H256;
33
use frame_support::{impl_outer_origin, parameter_types, weights::Weight};
44
use sp_runtime::{
@@ -21,7 +21,7 @@ parameter_types! {
2121
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
2222
}
2323

24-
impl system::Trait for Test {
24+
impl system::Config for Test {
2525
type BaseCallFilter = ();
2626
type Origin = Origin;
2727
type Call = ();
@@ -49,7 +49,7 @@ impl system::Trait for Test {
4949
type SystemWeightInfo = ();
5050
}
5151

52-
impl Trait for Test {
52+
impl Config for Test {
5353
type Event = ();
5454
}
5555

bin/node-template/runtime/src/lib.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ parameter_types! {
140140

141141
// Configure FRAME pallets to include in runtime.
142142

143-
impl frame_system::Trait for Runtime {
143+
impl frame_system::Config for Runtime {
144144
/// The basic call filter to use in dispatchable.
145145
type BaseCallFilter = ();
146146
/// The identifier used to distinguish between accounts.
@@ -199,11 +199,11 @@ impl frame_system::Trait for Runtime {
199199
type SystemWeightInfo = ();
200200
}
201201

202-
impl pallet_aura::Trait for Runtime {
202+
impl pallet_aura::Config for Runtime {
203203
type AuthorityId = AuraId;
204204
}
205205

206-
impl pallet_grandpa::Trait for Runtime {
206+
impl pallet_grandpa::Config for Runtime {
207207
type Event = Event;
208208
type Call = Call;
209209

@@ -226,7 +226,7 @@ parameter_types! {
226226
pub const MinimumPeriod: u64 = SLOT_DURATION / 2;
227227
}
228228

229-
impl pallet_timestamp::Trait for Runtime {
229+
impl pallet_timestamp::Config for Runtime {
230230
/// A timestamp: milliseconds since the unix epoch.
231231
type Moment = u64;
232232
type OnTimestampSet = Aura;
@@ -239,7 +239,7 @@ parameter_types! {
239239
pub const MaxLocks: u32 = 50;
240240
}
241241

242-
impl pallet_balances::Trait for Runtime {
242+
impl pallet_balances::Config for Runtime {
243243
type MaxLocks = MaxLocks;
244244
/// The type for recording an account's balance.
245245
type Balance = Balance;
@@ -255,20 +255,20 @@ parameter_types! {
255255
pub const TransactionByteFee: Balance = 1;
256256
}
257257

258-
impl pallet_transaction_payment::Trait for Runtime {
258+
impl pallet_transaction_payment::Config for Runtime {
259259
type OnChargeTransaction = CurrencyAdapter<Balances, ()>;
260260
type TransactionByteFee = TransactionByteFee;
261261
type WeightToFee = IdentityFee<Balance>;
262262
type FeeMultiplierUpdate = ();
263263
}
264264

265-
impl pallet_sudo::Trait for Runtime {
265+
impl pallet_sudo::Config for Runtime {
266266
type Event = Event;
267267
type Call = Call;
268268
}
269269

270270
/// Configure the pallet template in pallets/template.
271-
impl template::Trait for Runtime {
271+
impl template::Config for Runtime {
272272
type Event = Event;
273273
}
274274

@@ -457,7 +457,7 @@ impl_runtime_apis! {
457457
use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};
458458

459459
use frame_system_benchmarking::Module as SystemBench;
460-
impl frame_system_benchmarking::Trait for Runtime {}
460+
impl frame_system_benchmarking::Config for Runtime {}
461461

462462
let whitelist: Vec<TrackedStorageKey> = vec![
463463
// Block Number

bin/node/executor/tests/basic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,15 +580,15 @@ const CODE_TRANSFER: &str = r#"
580580
#[test]
581581
fn deploying_wasm_contract_should_work() {
582582
let transfer_code = wat::parse_str(CODE_TRANSFER).unwrap();
583-
let transfer_ch = <Runtime as frame_system::Trait>::Hashing::hash(&transfer_code);
583+
let transfer_ch = <Runtime as frame_system::Config>::Hashing::hash(&transfer_code);
584584

585585
let addr = pallet_contracts::Module::<Runtime>::contract_address(
586586
&charlie(),
587587
&transfer_ch,
588588
&[],
589589
);
590590

591-
let subsistence = pallet_contracts::Config::<Runtime>::subsistence_threshold_uncached();
591+
let subsistence = pallet_contracts::ConfigCache::<Runtime>::subsistence_threshold_uncached();
592592

593593
let b = construct_block(
594594
&mut new_test_ext(compact_code_unwrap(), false),

bin/node/runtime/src/impls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ mod multiplier_tests {
200200
fm = next;
201201
iterations += 1;
202202
let fee =
203-
<Runtime as pallet_transaction_payment::Trait>::WeightToFee::calc(&tx_weight);
203+
<Runtime as pallet_transaction_payment::Config>::WeightToFee::calc(&tx_weight);
204204
let adjusted_fee = fm.saturating_mul_acc_int(fee);
205205
println!(
206206
"iteration {}, new fm = {:?}. Fee at this point is: {} units / {} millicents, \

0 commit comments

Comments
 (0)