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
+15 -15
View File
@@ -28,7 +28,7 @@
//! * Asset Transfer
//! * Asset Destruction
//!
//! To use it in your runtime, you need to implement the assets [`Trait`](./trait.Trait.html).
//! To use it in your runtime, you need to implement the assets [`Config`](./trait.Config.html).
//!
//! The supported dispatchable functions are documented in the [`Call`](./enum.Call.html) enum.
//!
@@ -89,10 +89,10 @@
//! use frame_support::{decl_module, dispatch, ensure};
//! use frame_system::ensure_signed;
//!
//! pub trait Trait: assets::Trait { }
//! pub trait Config: assets::Config { }
//!
//! 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 {
//! pub fn issue_token_airdrop(origin) -> dispatch::DispatchResult {
//! let sender = ensure_signed(origin).map_err(|e| e.as_str())?;
//!
@@ -123,7 +123,7 @@
//! them are violated, the behavior of this module is undefined.
//!
//! * The total count of assets should be less than
//! `Trait::AssetId::max_value()`.
//! `Config::AssetId::max_value()`.
//!
//! ## Related Modules
//!
@@ -139,9 +139,9 @@ use frame_system::ensure_signed;
use sp_runtime::traits::One;
/// The module configuration trait.
pub trait Trait: frame_system::Trait {
pub trait Config: frame_system::Config {
/// 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 units in which we record balances.
type Balance: Member + Parameter + AtLeast32BitUnsigned + Default + Copy;
@@ -151,7 +151,7 @@ pub trait Trait: frame_system::Trait {
}
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 {
type Error = Error<T>;
fn deposit_event() = default;
@@ -226,9 +226,9 @@ decl_module! {
decl_event! {
pub enum Event<T> where
<T as frame_system::Trait>::AccountId,
<T as Trait>::Balance,
<T as Trait>::AssetId,
<T as frame_system::Config>::AccountId,
<T as Config>::Balance,
<T as Config>::AssetId,
{
/// Some assets were issued. \[asset_id, owner, total_supply\]
Issued(AssetId, AccountId, Balance),
@@ -240,7 +240,7 @@ decl_event! {
}
decl_error! {
pub enum Error for Module<T: Trait> {
pub enum Error for Module<T: Config> {
/// Transfer amount should be non-zero
AmountZero,
/// Account balance must be greater than or equal to the transfer amount
@@ -251,7 +251,7 @@ decl_error! {
}
decl_storage! {
trait Store for Module<T: Trait> as Assets {
trait Store for Module<T: Config> as Assets {
/// The number of units of assets held by any given account.
Balances: map hasher(blake2_128_concat) (T::AssetId, T::AccountId) => T::Balance;
/// The next asset identifier up for grabs.
@@ -264,7 +264,7 @@ decl_storage! {
}
// The main implementation block for the module.
impl<T: Trait> Module<T> {
impl<T: Config> Module<T> {
// Public immutables
/// Get the asset `id` balance of `who`.
@@ -298,7 +298,7 @@ mod tests {
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 Index = u64;
@@ -325,7 +325,7 @@ mod tests {
type OnKilledAccount = ();
type SystemWeightInfo = ();
}
impl Trait for Test {
impl Config for Test {
type Event = ();
type Balance = u64;
type AssetId = u32;