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:
Guillaume Thiolliere
2020-11-30 15:34:54 +01:00
committed by GitHub
parent dd3c84c362
commit 1cbfc9257f
200 changed files with 1767 additions and 1607 deletions
@@ -24,7 +24,7 @@
//! Run `cargo doc --package pallet-example-offchain-worker --open` to view this module's
//! documentation.
//!
//! - [`pallet_example_offchain_worker::Trait`](./trait.Trait.html)
//! - [`pallet_example_offchain_worker::Config`](./trait.Config.html)
//! - [`Call`](./enum.Call.html)
//! - [`Module`](./struct.Module.html)
//!
@@ -103,12 +103,12 @@ pub mod crypto {
}
/// This pallet's configuration trait
pub trait Trait: CreateSignedTransaction<Call<Self>> {
pub trait Config: CreateSignedTransaction<Call<Self>> {
/// The identifier type for an offchain worker.
type AuthorityId: AppCrypto<Self::Public, Self::Signature>;
/// The overarching event type.
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 overarching dispatch call type.
type Call: From<Call<Self>>;
@@ -149,7 +149,7 @@ impl<T: SigningTypes> SignedPayload<T> for PricePayload<T::Public, T::BlockNumbe
}
decl_storage! {
trait Store for Module<T: Trait> as ExampleOffchainWorker {
trait Store for Module<T: Config> as ExampleOffchainWorker {
/// A vector of recently submitted prices.
///
/// This is used to calculate average price, should have bounded size.
@@ -165,7 +165,7 @@ decl_storage! {
decl_event!(
/// Events generated by the module.
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 generated when new price is accepted to contribute to the average.
/// \[price, who\]
NewPrice(u32, AccountId),
@@ -174,7 +174,7 @@ decl_event!(
decl_module! {
/// A public part of the pallet.
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
pub struct Module<T: Config> for enum Call where origin: T::Origin {
fn deposit_event() = default;
/// Submit new price to the list.
@@ -310,7 +310,7 @@ enum TransactionType {
///
/// This greatly helps with error messages, as the ones inside the macro
/// can sometimes be hard to debug.
impl<T: Trait> Module<T> {
impl<T: Config> Module<T> {
/// Chooses which transaction type to send.
///
/// This function serves mostly to showcase `StorageValue` helper
@@ -679,7 +679,7 @@ impl<T: Trait> Module<T> {
}
#[allow(deprecated)] // ValidateUnsigned
impl<T: Trait> frame_support::unsigned::ValidateUnsigned for Module<T> {
impl<T: Config> frame_support::unsigned::ValidateUnsigned for Module<T> {
type Call = Call<T>;
/// Validate unsigned call to this module.
@@ -56,7 +56,7 @@ parameter_types! {
pub const MaximumBlockLength: u32 = 2 * 1024;
pub const AvailableBlockRatio: Perbill = Perbill::one();
}
impl frame_system::Trait for Test {
impl frame_system::Config for Test {
type BaseCallFilter = ();
type Origin = Origin;
type Call = ();
@@ -118,7 +118,7 @@ parameter_types! {
pub const UnsignedPriority: u64 = 1 << 20;
}
impl Trait for Test {
impl Config for Test {
type Event = ();
type AuthorityId = crypto::TestAuthId;
type Call = Call<Test>;
@@ -282,7 +282,7 @@ fn should_submit_unsigned_transaction_on_chain_for_any_account() {
let signature_valid = <PricePayload<
<Test as SigningTypes>::Public,
<Test as frame_system::Trait>::BlockNumber
<Test as frame_system::Config>::BlockNumber
> as SignedPayload<Test>>::verify::<crypto::TestAuthId>(&price_payload, signature);
assert!(signature_valid);
@@ -335,7 +335,7 @@ fn should_submit_unsigned_transaction_on_chain_for_all_accounts() {
let signature_valid = <PricePayload<
<Test as SigningTypes>::Public,
<Test as frame_system::Trait>::BlockNumber
<Test as frame_system::Config>::BlockNumber
> as SignedPayload<Test>>::verify::<crypto::TestAuthId>(&price_payload, signature);
assert!(signature_valid);