Skip to content

Commit 734e1ad

Browse files
authored
Rename pallet trait Trait to Config (#7599)
* rename Trait to Config * add test asserting using Trait is still valid. * fix ui tests
1 parent 129b323 commit 734e1ad

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

src/lib.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ pub type OriginOf<E, C> = <CallOf<E, C> as Dispatchable>::Origin;
145145
/// Main entry point for certain runtime actions as e.g. `execute_block`.
146146
///
147147
/// Generic parameters:
148-
/// - `System`: Something that implements `frame_system::Trait`
148+
/// - `System`: Something that implements `frame_system::Config`
149149
/// - `Block`: The block type of the runtime
150150
/// - `Context`: The context that is used when checking an extrinsic.
151151
/// - `UnsignedValidator`: The unsigned transaction validator of the runtime.
@@ -158,7 +158,7 @@ pub struct Executive<System, Block, Context, UnsignedValidator, AllModules, OnRu
158158
);
159159

160160
impl<
161-
System: frame_system::Trait,
161+
System: frame_system::Config,
162162
Block: traits::Block<Header=System::Header, Hash=System::Hash>,
163163
Context: Default,
164164
UnsignedValidator,
@@ -185,7 +185,7 @@ where
185185
}
186186

187187
impl<
188-
System: frame_system::Trait,
188+
System: frame_system::Config,
189189
Block: traits::Block<Header=System::Header, Hash=System::Hash>,
190190
Context: Default,
191191
UnsignedValidator,
@@ -505,10 +505,10 @@ mod tests {
505505
UnknownTransaction, TransactionSource, TransactionValidity
506506
};
507507

508-
pub trait Trait: frame_system::Trait {}
508+
pub trait Config: frame_system::Config {}
509509

510510
frame_support::decl_module! {
511-
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
511+
pub struct Module<T: Config> for enum Call where origin: T::Origin {
512512
#[weight = 100]
513513
fn some_function(origin) {
514514
// NOTE: does not make any different.
@@ -555,7 +555,7 @@ mod tests {
555555
}
556556
}
557557

558-
impl<T: Trait> sp_runtime::traits::ValidateUnsigned for Module<T> {
558+
impl<T: Config> sp_runtime::traits::ValidateUnsigned for Module<T> {
559559
type Call = Call<T>;
560560

561561
fn validate_unsigned(
@@ -594,7 +594,7 @@ mod tests {
594594
write: 100,
595595
};
596596
}
597-
impl frame_system::Trait for Runtime {
597+
impl frame_system::Config for Runtime {
598598
type BaseCallFilter = ();
599599
type Origin = Origin;
600600
type Index = u64;
@@ -626,7 +626,7 @@ mod tests {
626626
parameter_types! {
627627
pub const ExistentialDeposit: Balance = 1;
628628
}
629-
impl pallet_balances::Trait for Runtime {
629+
impl pallet_balances::Config for Runtime {
630630
type Balance = Balance;
631631
type Event = Event;
632632
type DustRemoval = ();
@@ -639,13 +639,13 @@ mod tests {
639639
parameter_types! {
640640
pub const TransactionByteFee: Balance = 0;
641641
}
642-
impl pallet_transaction_payment::Trait for Runtime {
642+
impl pallet_transaction_payment::Config for Runtime {
643643
type OnChargeTransaction = CurrencyAdapter<Balances, ()>;
644644
type TransactionByteFee = TransactionByteFee;
645645
type WeightToFee = IdentityFee<Balance>;
646646
type FeeMultiplierUpdate = ();
647647
}
648-
impl custom::Trait for Runtime {}
648+
impl custom::Config for Runtime {}
649649

650650
pub struct RuntimeVersion;
651651
impl frame_support::traits::Get<sp_version::RuntimeVersion> for RuntimeVersion {
@@ -668,8 +668,8 @@ mod tests {
668668
type TestXt = sp_runtime::testing::TestXt<Call, SignedExtra>;
669669
type TestBlock = Block<TestXt>;
670670
type TestUncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic<
671-
<Runtime as frame_system::Trait>::AccountId,
672-
<Runtime as frame_system::Trait>::Call,
671+
<Runtime as frame_system::Config>::AccountId,
672+
<Runtime as frame_system::Config>::Call,
673673
(),
674674
SignedExtra,
675675
>;
@@ -715,9 +715,9 @@ mod tests {
715715
balances: vec![(1, 211)],
716716
}.assimilate_storage(&mut t).unwrap();
717717
let xt = TestXt::new(Call::Balances(BalancesCall::transfer(2, 69)), sign_extra(1, 0, 0));
718-
let weight = xt.get_dispatch_info().weight + <Runtime as frame_system::Trait>::ExtrinsicBaseWeight::get();
718+
let weight = xt.get_dispatch_info().weight + <Runtime as frame_system::Config>::ExtrinsicBaseWeight::get();
719719
let fee: Balance
720-
= <Runtime as pallet_transaction_payment::Trait>::WeightToFee::calc(&weight);
720+
= <Runtime as pallet_transaction_payment::Config>::WeightToFee::calc(&weight);
721721
let mut t = sp_io::TestExternalities::new(t);
722722
t.execute_with(|| {
723723
Executive::initialize_block(&Header::new(
@@ -818,7 +818,7 @@ mod tests {
818818
let encoded = xt.encode();
819819
let encoded_len = encoded.len() as Weight;
820820
// on_initialize weight + block execution weight
821-
let base_block_weight = 175 + <Runtime as frame_system::Trait>::BlockExecutionWeight::get();
821+
let base_block_weight = 175 + <Runtime as frame_system::Config>::BlockExecutionWeight::get();
822822
let limit = AvailableBlockRatio::get() * MaximumBlockWeight::get() - base_block_weight;
823823
let num_to_exhaust_block = limit / (encoded_len + 5);
824824
t.execute_with(|| {
@@ -861,7 +861,7 @@ mod tests {
861861
let mut t = new_test_ext(1);
862862
t.execute_with(|| {
863863
// Block execution weight + on_initialize weight from custom module
864-
let base_block_weight = 175 + <Runtime as frame_system::Trait>::BlockExecutionWeight::get();
864+
let base_block_weight = 175 + <Runtime as frame_system::Config>::BlockExecutionWeight::get();
865865

866866
Executive::initialize_block(&Header::new(
867867
1,
@@ -879,7 +879,7 @@ mod tests {
879879
assert!(Executive::apply_extrinsic(x2.clone()).unwrap().is_ok());
880880

881881
// default weight for `TestXt` == encoded length.
882-
let extrinsic_weight = len as Weight + <Runtime as frame_system::Trait>::ExtrinsicBaseWeight::get();
882+
let extrinsic_weight = len as Weight + <Runtime as frame_system::Config>::ExtrinsicBaseWeight::get();
883883
assert_eq!(
884884
<frame_system::Module<Runtime>>::block_weight().total(),
885885
base_block_weight + 3 * extrinsic_weight,
@@ -946,9 +946,9 @@ mod tests {
946946
sign_extra(1, 0, 0),
947947
);
948948
let weight = xt.get_dispatch_info().weight
949-
+ <Runtime as frame_system::Trait>::ExtrinsicBaseWeight::get();
949+
+ <Runtime as frame_system::Config>::ExtrinsicBaseWeight::get();
950950
let fee: Balance =
951-
<Runtime as pallet_transaction_payment::Trait>::WeightToFee::calc(&weight);
951+
<Runtime as pallet_transaction_payment::Config>::WeightToFee::calc(&weight);
952952
Executive::initialize_block(&Header::new(
953953
1,
954954
H256::default(),
@@ -1106,7 +1106,7 @@ mod tests {
11061106
let runtime_upgrade_weight = <AllModules as OnRuntimeUpgrade>::on_runtime_upgrade();
11071107
let frame_system_on_initialize_weight = frame_system::Module::<Runtime>::on_initialize(block_number);
11081108
let on_initialize_weight = <AllModules as OnInitialize<u64>>::on_initialize(block_number);
1109-
let base_block_weight = <Runtime as frame_system::Trait>::BlockExecutionWeight::get();
1109+
let base_block_weight = <Runtime as frame_system::Config>::BlockExecutionWeight::get();
11101110

11111111
// Weights are recorded correctly
11121112
assert_eq!(

0 commit comments

Comments
 (0)