diff --git a/Cargo.dev.toml b/Cargo.dev.toml index dca469f6b..357d6e536 100644 --- a/Cargo.dev.toml +++ b/Cargo.dev.toml @@ -15,21 +15,21 @@ members = [ ] [patch.crates-io] -frame-benchmarking = { git = "https://github.com/paritytech/substrate.git", rev = "b7712fed2c58a898f7706e16861d7109c8f585a5" } -frame-support = { git = "https://github.com/paritytech/substrate.git", rev = "b7712fed2c58a898f7706e16861d7109c8f585a5" } -frame-system = { git = "https://github.com/paritytech/substrate.git", rev = "b7712fed2c58a898f7706e16861d7109c8f585a5" } -pallet-balances = { git = "https://github.com/paritytech/substrate.git", rev = "b7712fed2c58a898f7706e16861d7109c8f585a5" } -pallet-elections-phragmen = { git = "https://github.com/paritytech/substrate.git", rev = "b7712fed2c58a898f7706e16861d7109c8f585a5" } -pallet-scheduler = { git = "https://github.com/paritytech/substrate.git", rev = "b7712fed2c58a898f7706e16861d7109c8f585a5" } -pallet-treasury = { git = "https://github.com/paritytech/substrate.git", rev = "b7712fed2c58a898f7706e16861d7109c8f585a5" } -sp-api = { git = "https://github.com/paritytech/substrate.git", rev = "b7712fed2c58a898f7706e16861d7109c8f585a5" } -sp-application-crypto = { git = "https://github.com/paritytech/substrate.git", rev = "b7712fed2c58a898f7706e16861d7109c8f585a5" } -sp-arithmetic = { git = "https://github.com/paritytech/substrate.git", rev = "b7712fed2c58a898f7706e16861d7109c8f585a5" } -sp-core = { git = "https://github.com/paritytech/substrate.git", rev = "b7712fed2c58a898f7706e16861d7109c8f585a5" } -sp-inherents = { git = "https://github.com/paritytech/substrate.git", rev = "b7712fed2c58a898f7706e16861d7109c8f585a5" } -sp-io = { git = "https://github.com/paritytech/substrate.git", rev = "b7712fed2c58a898f7706e16861d7109c8f585a5" } -sp-runtime = { git = "https://github.com/paritytech/substrate.git", rev = "b7712fed2c58a898f7706e16861d7109c8f585a5" } -sp-runtime-interface = { git = "https://github.com/paritytech/substrate.git", rev = "b7712fed2c58a898f7706e16861d7109c8f585a5" } -sp-std = { git = "https://github.com/paritytech/substrate.git", rev = "b7712fed2c58a898f7706e16861d7109c8f585a5" } -sp-trie = { git = "https://github.com/paritytech/substrate.git", rev = "b7712fed2c58a898f7706e16861d7109c8f585a5" } -sp-version = { git = "https://github.com/paritytech/substrate.git", rev = "b7712fed2c58a898f7706e16861d7109c8f585a5" } +frame-benchmarking = { git = "https://github.com/paritytech/substrate.git", rev = "f884296f7436916909025f8b43c4bbf3e60e4c60" } +frame-support = { git = "https://github.com/paritytech/substrate.git", rev = "f884296f7436916909025f8b43c4bbf3e60e4c60" } +frame-system = { git = "https://github.com/paritytech/substrate.git", rev = "f884296f7436916909025f8b43c4bbf3e60e4c60" } +pallet-balances = { git = "https://github.com/paritytech/substrate.git", rev = "f884296f7436916909025f8b43c4bbf3e60e4c60" } +pallet-elections-phragmen = { git = "https://github.com/paritytech/substrate.git", rev = "f884296f7436916909025f8b43c4bbf3e60e4c60" } +pallet-scheduler = { git = "https://github.com/paritytech/substrate.git", rev = "f884296f7436916909025f8b43c4bbf3e60e4c60" } +pallet-treasury = { git = "https://github.com/paritytech/substrate.git", rev = "f884296f7436916909025f8b43c4bbf3e60e4c60" } +sp-api = { git = "https://github.com/paritytech/substrate.git", rev = "f884296f7436916909025f8b43c4bbf3e60e4c60" } +sp-application-crypto = { git = "https://github.com/paritytech/substrate.git", rev = "f884296f7436916909025f8b43c4bbf3e60e4c60" } +sp-arithmetic = { git = "https://github.com/paritytech/substrate.git", rev = "f884296f7436916909025f8b43c4bbf3e60e4c60" } +sp-core = { git = "https://github.com/paritytech/substrate.git", rev = "f884296f7436916909025f8b43c4bbf3e60e4c60" } +sp-inherents = { git = "https://github.com/paritytech/substrate.git", rev = "f884296f7436916909025f8b43c4bbf3e60e4c60" } +sp-io = { git = "https://github.com/paritytech/substrate.git", rev = "f884296f7436916909025f8b43c4bbf3e60e4c60" } +sp-runtime = { git = "https://github.com/paritytech/substrate.git", rev = "f884296f7436916909025f8b43c4bbf3e60e4c60" } +sp-runtime-interface = { git = "https://github.com/paritytech/substrate.git", rev = "f884296f7436916909025f8b43c4bbf3e60e4c60" } +sp-std = { git = "https://github.com/paritytech/substrate.git", rev = "f884296f7436916909025f8b43c4bbf3e60e4c60" } +sp-trie = { git = "https://github.com/paritytech/substrate.git", rev = "f884296f7436916909025f8b43c4bbf3e60e4c60" } +sp-version = { git = "https://github.com/paritytech/substrate.git", rev = "f884296f7436916909025f8b43c4bbf3e60e4c60" } diff --git a/auction/src/lib.rs b/auction/src/lib.rs index bf14156d4..307b310dd 100644 --- a/auction/src/lib.rs +++ b/auction/src/lib.rs @@ -34,8 +34,8 @@ pub trait WeightInfo { fn on_finalize(c: u32) -> Weight; } -pub trait Trait: frame_system::Trait { - type Event: From> + Into<::Event>; +pub trait Config: frame_system::Config { + type Event: From> + Into<::Event>; /// The balance type for bidding type Balance: Parameter + Member + AtLeast32BitUnsigned + Default + Copy + MaybeSerializeDeserialize; @@ -53,9 +53,9 @@ pub trait Trait: frame_system::Trait { decl_event!( pub enum Event where - ::AccountId, - ::Balance, - ::AuctionId, + ::AccountId, + ::Balance, + ::AuctionId, { /// A bid is placed. [auction_id, bidder, bidding_amount] Bid(AuctionId, AccountId, Balance), @@ -63,7 +63,7 @@ decl_event!( ); decl_storage! { - trait Store for Module as Auction { + trait Store for Module as Auction { /// Stores on-going and future auctions. Closed auction are removed. pub Auctions get(fn auctions): map hasher(twox_64_concat) T::AuctionId => Option>; @@ -76,7 +76,7 @@ decl_storage! { } decl_module! { - pub struct Module for enum Call where origin: T::Origin { + pub struct Module for enum Call where origin: T::Origin { type Error = Error; fn deposit_event() = default; @@ -180,7 +180,7 @@ decl_module! { decl_error! { /// Error for auction module. - pub enum Error for Module { + pub enum Error for Module { AuctionNotExist, AuctionNotStarted, BidNotAccepted, @@ -189,7 +189,7 @@ decl_error! { } } -impl Module { +impl Module { fn _on_finalize(now: T::BlockNumber) { for (auction_id, _) in >::drain_prefix(&now) { if let Some(auction) = >::take(&auction_id) { @@ -199,7 +199,7 @@ impl Module { } } -impl Auction for Module { +impl Auction for Module { type AuctionId = T::AuctionId; type Balance = T::Balance; diff --git a/auction/src/mock.rs b/auction/src/mock.rs index 9e5ba5943..c82ac976f 100644 --- a/auction/src/mock.rs +++ b/auction/src/mock.rs @@ -38,7 +38,7 @@ pub type Balance = u64; pub type BlockNumber = u64; pub type AuctionId = u64; -impl frame_system::Trait for Runtime { +impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = BlockNumber; @@ -92,7 +92,7 @@ impl AuctionHandler for Handler { fn on_auction_ended(_id: AuctionId, _winner: Option<(AccountId, Balance)>) {} } -impl Trait for Runtime { +impl Config for Runtime { type Event = TestEvent; type Balance = Balance; type AuctionId = AuctionId; diff --git a/authority/src/lib.rs b/authority/src/lib.rs index b924d344a..346df6074 100644 --- a/authority/src/lib.rs +++ b/authority/src/lib.rs @@ -2,7 +2,7 @@ //! A module to provide features for governance including dispatch method on //! behalf of other accounts and schedule dispatchables. //! -//! - [`Trait`](./trait.Trait.html) +//! - [`Config`](./trait.Config.html) //! - [`Call`](./enum.Call.html) //! - [`Module`](./struct.Module.html) //! @@ -90,7 +90,7 @@ impl< } /// Origin for the authority module. -pub type Origin = DelayedOrigin<::BlockNumber, ::PalletsOrigin>; +pub type Origin = DelayedOrigin<::BlockNumber, ::PalletsOrigin>; /// Config for orml-authority pub trait AuthorityConfig { @@ -123,44 +123,48 @@ pub trait AsOriginId { fn check_dispatch_from(&self, origin: Origin) -> DispatchResult; } -type CallOf = ::Call; +type CallOf = ::Call; /// The schedule task index type. pub type ScheduleTaskIndex = u32; /// orml-authority configuration trait. -pub trait Trait: frame_system::Trait { +pub trait Config: frame_system::Config { /// The overarching event type. - type Event: From> + Into<::Event>; + type Event: From> + Into<::Event>; /// The outer origin type. - type Origin: From::PalletsOrigin>> - + IsType<::Origin> + type Origin: From::PalletsOrigin>> + + IsType<::Origin> + OriginTrait; /// The caller origin, overarching type of all pallets origins. - type PalletsOrigin: Parameter + Into<::Origin>; + type PalletsOrigin: Parameter + Into<::Origin>; /// The aggregated call type. type Call: Parameter - + Dispatchable::Origin, PostInfo = PostDispatchInfo> + + Dispatchable::Origin, PostInfo = PostDispatchInfo> + GetDispatchInfo; /// The Scheduler. - type Scheduler: ScheduleNamed::Call, Self::PalletsOrigin>; + type Scheduler: ScheduleNamed::Call, Self::PalletsOrigin>; /// The type represent origin that can be dispatched by other origins. - type AsOriginId: Parameter + AsOriginId<::Origin, Self::PalletsOrigin>; + type AsOriginId: Parameter + AsOriginId<::Origin, Self::PalletsOrigin>; /// Additional permission config. - type AuthorityConfig: AuthorityConfig<::Origin, Self::PalletsOrigin, Self::BlockNumber>; + type AuthorityConfig: AuthorityConfig< + ::Origin, + Self::PalletsOrigin, + Self::BlockNumber, + >; /// Weight information for extrinsics in this module. type WeightInfo: WeightInfo; } decl_error! { - pub enum Error for Module { + pub enum Error for Module { /// Calculation overflow. Overflow, /// Failed to schedule a task. @@ -175,7 +179,7 @@ decl_error! { } decl_storage! { - trait Store for Module as Authority { + trait Store for Module as Authority { /// Track the next task ID. pub NextTaskIndex get(fn next_task_index): ScheduleTaskIndex; } @@ -183,8 +187,8 @@ decl_storage! { decl_event! { pub enum Event where - ::PalletsOrigin, - ::BlockNumber, + ::PalletsOrigin, + ::BlockNumber, { /// A call is dispatched. [result] Dispatched(DispatchResult), @@ -200,7 +204,7 @@ decl_event! { } decl_module! { - pub struct Module for enum Call where origin: ::Origin { + pub struct Module for enum Call where origin: ::Origin { type Error = Error; fn deposit_event() = default; @@ -245,14 +249,14 @@ decl_module! { }; let schedule_origin = if with_delayed_origin { - let origin: ::Origin = From::from(origin); - let origin: ::Origin = From::from(DelayedOrigin:: { + let origin: ::Origin = From::from(origin); + let origin: ::Origin = From::from(DelayedOrigin:: { delay, origin: Box::new(origin.caller().clone()) }); origin } else { - ::Origin::from(origin) + ::Origin::from(origin) }; let pallets_origin = schedule_origin.caller().clone(); diff --git a/authority/src/mock.rs b/authority/src/mock.rs index b9064560e..d0f6723b9 100644 --- a/authority/src/mock.rs +++ b/authority/src/mock.rs @@ -27,7 +27,7 @@ parameter_types! { pub const AvailableBlockRatio: Perbill = Perbill::one(); } -impl frame_system::Trait for Runtime { +impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = BlockNumber; @@ -58,7 +58,7 @@ impl frame_system::Trait for Runtime { parameter_types! { pub MaximumSchedulerWeight: u32 = Perbill::from_percent(80) * MaximumBlockWeight::get(); } -impl pallet_scheduler::Trait for Runtime { +impl pallet_scheduler::Config for Runtime { type Event = Event; type Origin = Origin; type PalletsOrigin = OriginCaller; @@ -144,7 +144,7 @@ impl AsOriginId for MockAsOriginId { } } -impl Trait for Runtime { +impl Config for Runtime { type Event = Event; type Origin = Origin; type PalletsOrigin = OriginCaller; diff --git a/authority/src/tests.rs b/authority/src/tests.rs index a1c18d5d4..db11f88e4 100644 --- a/authority/src/tests.rs +++ b/authority/src/tests.rs @@ -195,9 +195,9 @@ fn fast_track_scheduled_dispatch_work() { assert!(System::events().iter().any(|record| record.event == event)); let schedule_origin = { - let origin: ::Origin = From::from(Origin::root()); - let origin: ::Origin = - From::from(DelayedOrigin::::PalletsOrigin> { + let origin: ::Origin = From::from(Origin::root()); + let origin: ::Origin = + From::from(DelayedOrigin::::PalletsOrigin> { delay: 1, origin: Box::new(origin.caller().clone()), }); @@ -269,9 +269,9 @@ fn delay_scheduled_dispatch_work() { assert!(System::events().iter().any(|record| record.event == event)); let schedule_origin = { - let origin: ::Origin = From::from(Origin::root()); - let origin: ::Origin = - From::from(DelayedOrigin::::PalletsOrigin> { + let origin: ::Origin = From::from(Origin::root()); + let origin: ::Origin = + From::from(DelayedOrigin::::PalletsOrigin> { delay: 1, origin: Box::new(origin.caller().clone()), }); @@ -342,9 +342,9 @@ fn cancel_scheduled_dispatch_work() { assert!(System::events().iter().any(|record| record.event == event)); let schedule_origin = { - let origin: ::Origin = From::from(Origin::root()); - let origin: ::Origin = - From::from(DelayedOrigin::::PalletsOrigin> { + let origin: ::Origin = From::from(Origin::root()); + let origin: ::Origin = + From::from(DelayedOrigin::::PalletsOrigin> { delay: 1, origin: Box::new(origin.caller().clone()), }); diff --git a/benchmarking/src/lib.rs b/benchmarking/src/lib.rs index a4674bae4..b96817095 100644 --- a/benchmarking/src/lib.rs +++ b/benchmarking/src/lib.rs @@ -127,7 +127,7 @@ pub use sp_runtime::traits::Zero; /// Test functions are automatically generated for each benchmark and are /// accessible to you when you run `cargo test`. All tests are named /// `test_benchmark_`, expect you to pass them the Runtime -/// Trait, and run them in a test externalities environment. The test function +/// Config, and run them in a test externalities environment. The test function /// runs your benchmark just like a regular benchmark, but only testing at the /// lowest and highest values for each component. The function will return /// `Ok(())` if the benchmarks return no errors. @@ -813,7 +813,7 @@ macro_rules! impl_benchmark { let mut whitelist = whitelist.to_vec(); let whitelisted_caller_key = as frame_support::storage::StorageMap<_,_>>::hashed_key_for( - $crate::whitelisted_caller::<<$runtime as frame_system::Trait>::AccountId>() + $crate::whitelisted_caller::<<$runtime as frame_system::Config>::AccountId>() ); whitelist.push(whitelisted_caller_key.into()); $crate::benchmarking::set_whitelist(whitelist); diff --git a/benchmarking/src/tests.rs b/benchmarking/src/tests.rs index 1261ceb7c..368d6d0b0 100644 --- a/benchmarking/src/tests.rs +++ b/benchmarking/src/tests.rs @@ -15,13 +15,13 @@ use sp_runtime::{ use sp_std::prelude::*; decl_storage! { - trait Store for Module as Test { + trait Store for Module as Test { Value get(fn value): Option; } } decl_module! { - pub struct Module for enum Call where origin: T::Origin { + pub struct Module for enum Call where origin: T::Origin { #[weight = 0] fn set_value(origin, n: u32) -> DispatchResult { let _sender = ensure_signed(origin)?; @@ -41,7 +41,7 @@ impl_outer_origin! { pub enum Origin for Test {} } -pub trait Trait: frame_system::Trait { +pub trait Config: frame_system::Config { type Event; type BlockNumber; } @@ -51,7 +51,7 @@ type AccountId = u128; #[derive(Clone, Eq, PartialEq)] pub struct Test; -impl frame_system::Trait for Test { +impl frame_system::Config for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; @@ -79,7 +79,7 @@ impl frame_system::Trait for Test { type SystemWeightInfo = (); } -impl Trait for Test { +impl Config for Test { type Event = (); type BlockNumber = u32; } diff --git a/currencies/README.md b/currencies/README.md index e38897ef8..c4a330b5e 100644 --- a/currencies/README.md +++ b/currencies/README.md @@ -6,4 +6,4 @@ The currencies module provides a mixed currencies system, by configuring a nativ It also provides an adapter, to adapt `frame_support::traits::Currency` implementations into `BasicCurrencyExtended`. -The currencies module provides functionality of both `MultiCurrencyExtended` and `BasicCurrencyExtended`, via unified interfaces, and all calls would be delegated to the underlying multi-currency and base currency system. A native currency ID could be set by `Trait::GetNativeCurrencyId`, to identify the native currency. +The currencies module provides functionality of both `MultiCurrencyExtended` and `BasicCurrencyExtended`, via unified interfaces, and all calls would be delegated to the underlying multi-currency and base currency system. A native currency ID could be set by `Config::GetNativeCurrencyId`, to identify the native currency. diff --git a/currencies/src/lib.rs b/currencies/src/lib.rs index 3c4a245be..53f7465bd 100644 --- a/currencies/src/lib.rs +++ b/currencies/src/lib.rs @@ -12,7 +12,7 @@ //! The currencies module provides functionality of both `MultiCurrencyExtended` //! and `BasicCurrencyExtended`, via unified interfaces, and all calls would be //! delegated to the underlying multi-currency and base currency system. -//! A native currency ID could be set by `Trait::GetNativeCurrencyId`, to +//! A native currency ID could be set by `Config::GetNativeCurrencyId`, to //! identify the native currency. //! //! ### Implementations @@ -32,7 +32,7 @@ //! currency. //! - `transfer_native_currency` - Transfer some balance to another account, in //! native currency set in -//! `Trait::NativeCurrency`. +//! `Config::NativeCurrency`. //! - `update_balance` - Update balance by signed integer amount, in a given //! currency, root origin required. @@ -78,15 +78,15 @@ pub trait WeightInfo { fn update_balance_native_currency_killing() -> Weight; } -type BalanceOf = <::MultiCurrency as MultiCurrency<::AccountId>>::Balance; +type BalanceOf = <::MultiCurrency as MultiCurrency<::AccountId>>::Balance; type CurrencyIdOf = - <::MultiCurrency as MultiCurrency<::AccountId>>::CurrencyId; + <::MultiCurrency as MultiCurrency<::AccountId>>::CurrencyId; type AmountOf = - <::MultiCurrency as MultiCurrencyExtended<::AccountId>>::Amount; + <::MultiCurrency as MultiCurrencyExtended<::AccountId>>::Amount; -pub trait Trait: frame_system::Trait { - type Event: From> + Into<::Event>; +pub trait Config: frame_system::Config { + type Event: From> + Into<::Event>; type MultiCurrency: MergeAccount + MultiCurrencyExtended + MultiLockableCurrency @@ -101,12 +101,12 @@ pub trait Trait: frame_system::Trait { } decl_storage! { - trait Store for Module as Currencies {} + trait Store for Module as Currencies {} } decl_event!( pub enum Event where - ::AccountId, + ::AccountId, Amount = AmountOf, Balance = BalanceOf, CurrencyId = CurrencyIdOf @@ -124,7 +124,7 @@ decl_event!( decl_error! { /// Error for currencies module. - pub enum Error for Module { + pub enum Error for Module { /// Unable to convert the Amount type into Balance. AmountIntoBalanceFailed, /// Balance is too low. @@ -133,7 +133,7 @@ decl_error! { } decl_module! { - pub struct Module for enum Call where origin: T::Origin { + pub struct Module for enum Call where origin: T::Origin { type Error = Error; const NativeCurrencyId: CurrencyIdOf = T::GetNativeCurrencyId::get(); @@ -228,9 +228,9 @@ decl_module! { } } -impl Module {} +impl Module {} -impl MultiCurrency for Module { +impl MultiCurrency for Module { type CurrencyId = CurrencyIdOf; type Balance = BalanceOf; @@ -335,7 +335,7 @@ impl MultiCurrency for Module { } } -impl MultiCurrencyExtended for Module { +impl MultiCurrencyExtended for Module { type Amount = AmountOf; fn update_balance(currency_id: Self::CurrencyId, who: &T::AccountId, by_amount: Self::Amount) -> DispatchResult { @@ -349,7 +349,7 @@ impl MultiCurrencyExtended for Module { } } -impl MultiLockableCurrency for Module { +impl MultiLockableCurrency for Module { type Moment = T::BlockNumber; fn set_lock(lock_id: LockIdentifier, currency_id: Self::CurrencyId, who: &T::AccountId, amount: Self::Balance) { @@ -377,7 +377,7 @@ impl MultiLockableCurrency for Module { } } -impl MultiReservableCurrency for Module { +impl MultiReservableCurrency for Module { fn can_reserve(currency_id: Self::CurrencyId, who: &T::AccountId, value: Self::Balance) -> bool { if currency_id == T::GetNativeCurrencyId::get() { T::NativeCurrency::can_reserve(who, value) @@ -437,7 +437,7 @@ pub struct Currency(marker::PhantomData, marker::PhantomDat impl BasicCurrency for Currency where - T: Trait, + T: Config, GetCurrencyId: Get>, { type Balance = BalanceOf; @@ -485,7 +485,7 @@ where impl BasicCurrencyExtended for Currency where - T: Trait, + T: Config, GetCurrencyId: Get>, { type Amount = AmountOf; @@ -497,7 +497,7 @@ where impl BasicLockableCurrency for Currency where - T: Trait, + T: Config, GetCurrencyId: Get>, { type Moment = T::BlockNumber; @@ -517,7 +517,7 @@ where impl BasicReservableCurrency for Currency where - T: Trait, + T: Config, GetCurrencyId: Get>, { fn can_reserve(who: &T::AccountId, value: Self::Balance) -> bool { @@ -556,7 +556,7 @@ where } } -pub type NativeCurrencyOf = Currency::GetNativeCurrencyId>; +pub type NativeCurrencyOf = Currency::GetNativeCurrencyId>; /// Adapt other currency traits implementation to `BasicCurrency`. pub struct BasicCurrencyAdapter(marker::PhantomData<(T, Currency, Amount, Moment)>); @@ -568,7 +568,7 @@ impl BasicCurrency for BasicCurrencyAdapter where Currency: PalletCurrency, - T: Trait, + T: Config, { type Balance = PalletBalanceOf; @@ -633,7 +633,7 @@ where + Debug + Default, Currency: PalletCurrency, - T: Trait, + T: Config, { type Amount = Amount; @@ -655,7 +655,7 @@ impl BasicLockableCurrency for BasicCurrencyAdapter where Currency: PalletLockableCurrency, - T: Trait, + T: Config, { type Moment = Moment; @@ -677,7 +677,7 @@ impl BasicReservableCurrency for BasicCurrencyAdapter where Currency: PalletReservableCurrency, - T: Trait, + T: Config, { fn can_reserve(who: &AccountId, value: Self::Balance) -> bool { Currency::can_reserve(who, value) @@ -710,7 +710,7 @@ where } } -impl MergeAccount for Module { +impl MergeAccount for Module { fn merge_account(source: &T::AccountId, dest: &T::AccountId) -> DispatchResult { with_transaction_result(|| { // transfer non-native free to dest diff --git a/currencies/src/mock.rs b/currencies/src/mock.rs index 2fa29655e..f85659754 100644 --- a/currencies/src/mock.rs +++ b/currencies/src/mock.rs @@ -42,7 +42,7 @@ parameter_types! { } pub type AccountId = AccountId32; -impl frame_system::Trait for Runtime { +impl frame_system::Config for Runtime { type Origin = Origin; type Call = (); type Index = u64; @@ -78,7 +78,7 @@ parameter_types! { pub const ExistentialDeposit: u64 = 1; } -impl pallet_balances::Trait for Runtime { +impl pallet_balances::Config for Runtime { type Balance = Balance; type DustRemoval = (); type Event = TestEvent; @@ -99,7 +99,7 @@ parameter_types! { pub DustAccount: AccountId = ModuleId(*b"orml/dst").into_account(); } -impl orml_tokens::Trait for Runtime { +impl orml_tokens::Config for Runtime { type Event = TestEvent; type Balance = Balance; type Amount = i64; @@ -117,7 +117,7 @@ parameter_types! { pub const GetNativeCurrencyId: CurrencyId = NATIVE_CURRENCY_ID; } -impl Trait for Runtime { +impl Config for Runtime { type Event = TestEvent; type MultiCurrency = Tokens; type NativeCurrency = AdaptedBasicCurrency; diff --git a/gradually-update/src/lib.rs b/gradually-update/src/lib.rs index 616558a4c..11424a791 100644 --- a/gradually-update/src/lib.rs +++ b/gradually-update/src/lib.rs @@ -1,7 +1,7 @@ //! # Gradually Update //! A module for scheduling gradually updates to storage values. //! -//! - [`Trait`](./trait.Trait.html) +//! - [`Config`](./trait.Config.html) //! - [`Call`](./enum.Call.html) //! - [`Module`](./struct.Module.html) //! @@ -56,8 +56,8 @@ pub struct GraduallyUpdate { pub per_block: StorageValue, } -pub trait Trait: frame_system::Trait { - type Event: From> + Into<::Event>; +pub trait Config: frame_system::Config { + type Event: From> + Into<::Event>; /// The frequency of updating values between blocks type UpdateFrequency: Get; /// The origin that can schedule an update @@ -67,7 +67,7 @@ pub trait Trait: frame_system::Trait { } decl_storage! { - trait Store for Module as GraduallyUpdate { + trait Store for Module as GraduallyUpdate { /// All the on-going updates pub GraduallyUpdates get(fn gradually_updates): Vec; /// The last updated block number @@ -78,7 +78,7 @@ decl_storage! { decl_event!( /// Event for gradually-update module. pub enum Event where - ::BlockNumber, + ::BlockNumber, { /// Gradually update added. [key, per_block, target_value] GraduallyUpdateAdded(StorageKey, StorageValue, StorageValue), @@ -91,7 +91,7 @@ decl_event!( decl_error! { /// Error for gradually-update module. - pub enum Error for Module { + pub enum Error for Module { /// The `per_block` or `target_value` is invalid. InvalidPerBlockOrTargetValue, /// The `target_value` is invalid. @@ -104,7 +104,7 @@ decl_error! { } decl_module! { - pub struct Module for enum Call where origin: T::Origin { + pub struct Module for enum Call where origin: T::Origin { type Error = Error; fn deposit_event() = default; @@ -169,7 +169,7 @@ decl_module! { } } -impl Module { +impl Module { fn _need_update(now: T::BlockNumber) -> bool { now >= Self::last_updated_at() + T::UpdateFrequency::get() } diff --git a/gradually-update/src/mock.rs b/gradually-update/src/mock.rs index 3e350d149..ed5c965e7 100644 --- a/gradually-update/src/mock.rs +++ b/gradually-update/src/mock.rs @@ -37,7 +37,7 @@ parameter_types! { pub type AccountId = u128; pub type BlockNumber = u64; -impl frame_system::Trait for Runtime { +impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = BlockNumber; @@ -70,7 +70,7 @@ parameter_types! { pub const UpdateFrequency: BlockNumber = 10; } -impl Trait for Runtime { +impl Config for Runtime { type Event = TestEvent; type UpdateFrequency = UpdateFrequency; type DispatchOrigin = system::EnsureRoot; diff --git a/nft/src/lib.rs b/nft/src/lib.rs index a7a8e8167..63864aa57 100644 --- a/nft/src/lib.rs +++ b/nft/src/lib.rs @@ -1,7 +1,7 @@ //! # Non Fungible Token //! The module provides implementations for non-fungible-token. //! -//! - [`Trait`](./trait.Trait.html) +//! - [`Config`](./trait.Config.html) //! - [`Call`](./enum.Call.html) //! - [`Module`](./struct.Module.html) //! @@ -55,7 +55,7 @@ pub struct TokenInfo { pub data: Data, } -pub trait Trait: frame_system::Trait { +pub trait Config: frame_system::Config { /// The class ID type type ClassId: Parameter + Member + AtLeast32BitUnsigned + Default + Copy; /// The token ID type @@ -68,7 +68,7 @@ pub trait Trait: frame_system::Trait { decl_error! { /// Error for non-fungible-token module. - pub enum Error for Module { + pub enum Error for Module { /// No available class ID NoAvailableClassId, /// No available token ID @@ -88,11 +88,11 @@ decl_error! { } pub type ClassInfoOf = - ClassInfo<::TokenId, ::AccountId, ::ClassData>; -pub type TokenInfoOf = TokenInfo<::AccountId, ::TokenData>; + ClassInfo<::TokenId, ::AccountId, ::ClassData>; +pub type TokenInfoOf = TokenInfo<::AccountId, ::TokenData>; decl_storage! { - trait Store for Module as NonFungibleToken { + trait Store for Module as NonFungibleToken { /// Next available class ID. pub NextClassId get(fn next_class_id): T::ClassId; /// Next available token ID. @@ -112,11 +112,11 @@ decl_storage! { } decl_module! { - pub struct Module for enum Call where origin: T::Origin { + pub struct Module for enum Call where origin: T::Origin { } } -impl Module { +impl Module { /// Create NFT(non fungible token) class pub fn create_class( owner: &T::AccountId, diff --git a/nft/src/mock.rs b/nft/src/mock.rs index 7fb69b5b7..bef77445d 100644 --- a/nft/src/mock.rs +++ b/nft/src/mock.rs @@ -25,7 +25,7 @@ parameter_types! { pub type AccountId = u128; pub type BlockNumber = u64; -impl frame_system::Trait for Runtime { +impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = BlockNumber; @@ -54,7 +54,7 @@ impl frame_system::Trait for Runtime { } pub type System = frame_system::Module; -impl Trait for Runtime { +impl Config for Runtime { type ClassId = u64; type TokenId = u64; type ClassData = (); @@ -64,10 +64,10 @@ pub type NonFungibleTokenModule = Module; pub const ALICE: AccountId = 1; pub const BOB: AccountId = 2; -pub const CLASS_ID: ::ClassId = 0; -pub const CLASS_ID_NOT_EXIST: ::ClassId = 100; -pub const TOKEN_ID: ::TokenId = 0; -pub const TOKEN_ID_NOT_EXIST: ::TokenId = 100; +pub const CLASS_ID: ::ClassId = 0; +pub const CLASS_ID_NOT_EXIST: ::ClassId = 100; +pub const TOKEN_ID: ::TokenId = 0; +pub const TOKEN_ID_NOT_EXIST: ::TokenId = 100; pub struct ExtBuilder; diff --git a/nft/src/tests.rs b/nft/src/tests.rs index 720829284..63faa99d7 100644 --- a/nft/src/tests.rs +++ b/nft/src/tests.rs @@ -18,7 +18,7 @@ fn create_class_should_work() { #[test] fn create_class_should_fail() { ExtBuilder::default().build().execute_with(|| { - NextClassId::::mutate(|id| *id = ::ClassId::max_value()); + NextClassId::::mutate(|id| *id = ::ClassId::max_value()); assert_noop!( NonFungibleTokenModule::create_class(&ALICE, vec![1], ()), Error::::NoAvailableClassId @@ -53,14 +53,14 @@ fn mint_should_fail() { ExtBuilder::default().build().execute_with(|| { assert_ok!(NonFungibleTokenModule::create_class(&ALICE, vec![1], ())); Classes::::mutate(CLASS_ID, |class_info| { - class_info.as_mut().unwrap().total_issuance = ::TokenId::max_value(); + class_info.as_mut().unwrap().total_issuance = ::TokenId::max_value(); }); assert_noop!( NonFungibleTokenModule::mint(&BOB, CLASS_ID, vec![1], ()), Error::::NumOverflow ); - NextTokenId::::mutate(CLASS_ID, |id| *id = ::TokenId::max_value()); + NextTokenId::::mutate(CLASS_ID, |id| *id = ::TokenId::max_value()); assert_noop!( NonFungibleTokenModule::mint(&BOB, CLASS_ID, vec![1], ()), Error::::NoAvailableTokenId diff --git a/oracle/src/default_combine_data.rs b/oracle/src/default_combine_data.rs index 56cf6b8cc..5c097e495 100644 --- a/oracle/src/default_combine_data.rs +++ b/oracle/src/default_combine_data.rs @@ -1,4 +1,4 @@ -use crate::{DefaultInstance, Instance, MomentOf, TimestampedValueOf, Trait}; +use crate::{Config, DefaultInstance, Instance, MomentOf, TimestampedValueOf}; use frame_support::traits::{Get, Time}; use orml_traits::CombineData; use sp_std::{marker, prelude::*}; @@ -9,16 +9,16 @@ pub struct DefaultCombineData( marker::PhantomData<(T, I, MinimumCount, ExpiresIn)>, ); -impl CombineData<>::OracleKey, TimestampedValueOf> +impl CombineData<>::OracleKey, TimestampedValueOf> for DefaultCombineData where - T: Trait, + T: Config, I: Instance, MinimumCount: Get, ExpiresIn: Get>, { fn combine_data( - _key: &>::OracleKey, + _key: &>::OracleKey, mut values: Vec>, prev_value: Option>, ) -> Option> { diff --git a/oracle/src/lib.rs b/oracle/src/lib.rs index 797fa8249..6a34b7507 100644 --- a/oracle/src/lib.rs +++ b/oracle/src/lib.rs @@ -1,7 +1,7 @@ //! # Oracle //! A module to allow oracle operators to feed external data. //! -//! - [`Trait`](./trait.Trait.html) +//! - [`Config`](./trait.Config.html) //! - [`Call`](./enum.Call.html) //! - [`Module`](./struct.Module.html) //! @@ -48,8 +48,8 @@ use serde::{Deserialize, Serialize}; use sp_runtime::{traits::Member, DispatchResult, RuntimeDebug}; use sp_std::{prelude::*, vec}; -type MomentOf = <>::Time as Time>::Moment; -pub type TimestampedValueOf = TimestampedValue<>::OracleValue, MomentOf>; +type MomentOf = <>::Time as Time>::Moment; +pub type TimestampedValueOf = TimestampedValue<>::OracleValue, MomentOf>; #[derive(Encode, Decode, RuntimeDebug, Eq, PartialEq, Clone, Copy, Ord, PartialOrd)] #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] @@ -58,8 +58,8 @@ pub struct TimestampedValue { pub timestamp: Moment, } -pub trait Trait: frame_system::Trait { - type Event: From> + Into<::Event>; +pub trait Config: frame_system::Config { + type Event: From> + Into<::Event>; /// Hook on new data received type OnNewData: OnNewData; @@ -85,7 +85,7 @@ pub trait Trait: frame_system::Trait { } decl_error! { - pub enum Error for Module, I: Instance> { + pub enum Error for Module, I: Instance> { /// Sender does not have permission NoPermission, /// Feeder has already feeded at this block @@ -95,9 +95,9 @@ decl_error! { decl_event!( pub enum Event where - ::AccountId, - >::OracleKey, - >::OracleValue, + ::AccountId, + >::OracleKey, + >::OracleValue, { /// New feed data is submitted. [sender, values] NewFeedData(AccountId, Vec<(OracleKey, OracleValue)>), @@ -105,16 +105,16 @@ decl_event!( ); decl_storage! { - trait Store for Module, I: Instance=DefaultInstance> as Oracle { + trait Store for Module, I: Instance=DefaultInstance> as Oracle { /// Raw values for each oracle operators pub RawValues get(fn raw_values): double_map hasher(twox_64_concat) T::AccountId, hasher(twox_64_concat) T::OracleKey => Option>; /// True if Self::values(key) is up to date, otherwise the value is stale - pub IsUpdated get(fn is_updated): map hasher(twox_64_concat) >::OracleKey => bool; + pub IsUpdated get(fn is_updated): map hasher(twox_64_concat) >::OracleKey => bool; /// Combined value, may not be up to date - pub Values get(fn values): map hasher(twox_64_concat) >::OracleKey => Option>; + pub Values get(fn values): map hasher(twox_64_concat) >::OracleKey => Option>; /// If an oracle operator has feed a value in this block HasDispatched: OrderedSet; @@ -132,7 +132,7 @@ decl_storage! { } decl_module! { - pub struct Module, I: Instance=DefaultInstance> for enum Call where origin: T::Origin { + pub struct Module, I: Instance=DefaultInstance> for enum Call where origin: T::Origin { type Error = Error; fn deposit_event() = default; @@ -162,7 +162,7 @@ decl_module! { } } -impl, I: Instance> Module { +impl, I: Instance> Module { pub fn read_raw_values(key: &T::OracleKey) -> Vec> { Self::members() .0 @@ -242,7 +242,7 @@ impl, I: Instance> Module { } } -impl, I: Instance> InitializeMembers for Module { +impl, I: Instance> InitializeMembers for Module { fn initialize_members(members: &[T::AccountId]) { if !members.is_empty() { assert!(Members::::get().0.is_empty(), "Members are already initialized!"); @@ -251,7 +251,7 @@ impl, I: Instance> InitializeMembers for Module } } -impl, I: Instance> ChangeMembers for Module { +impl, I: Instance> ChangeMembers for Module { fn change_members_sorted(_incoming: &[T::AccountId], outgoing: &[T::AccountId], new: &[T::AccountId]) { // remove session keys and its values for removed in outgoing { @@ -269,12 +269,12 @@ impl, I: Instance> ChangeMembers for Module { } } -impl, I: Instance> DataProvider for Module { +impl, I: Instance> DataProvider for Module { fn get(key: &T::OracleKey) -> Option { Self::get(key).map(|timestamped_value| timestamped_value.value) } } -impl, I: Instance> DataProviderExtended> for Module { +impl, I: Instance> DataProviderExtended> for Module { fn get_no_op(key: &T::OracleKey) -> Option> { Self::get_no_op(key) } @@ -284,7 +284,7 @@ impl, I: Instance> DataProviderExtended, I: Instance> DataFeeder for Module { +impl, I: Instance> DataFeeder for Module { fn feed_value(who: T::AccountId, key: T::OracleKey, value: T::OracleValue) -> DispatchResult { Self::do_feed_values(who, vec![(key, value)])?; Ok(()) diff --git a/oracle/src/mock.rs b/oracle/src/mock.rs index 0f9c380aa..b0db22883 100644 --- a/oracle/src/mock.rs +++ b/oracle/src/mock.rs @@ -48,7 +48,7 @@ parameter_types! { pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75); } -impl frame_system::Trait for Test { +impl frame_system::Config for Test { type Origin = Origin; type Call = Call; type Index = u64; @@ -102,7 +102,7 @@ parameter_types! { pub const RootOperatorAccountId: AccountId = 4; } -impl Trait for Test { +impl Config for Test { type Event = TestEvent; type OnNewData = (); type CombineData = DefaultCombineData; diff --git a/rewards/src/lib.rs b/rewards/src/lib.rs index 48053b3bf..43e8cecf5 100644 --- a/rewards/src/lib.rs +++ b/rewards/src/lib.rs @@ -34,7 +34,7 @@ pub struct PoolInfo { pub total_withdrawn_rewards: Balance, } -pub trait Trait: frame_system::Trait { +pub trait Config: frame_system::Config { /// The share type of pool. type Share: Parameter + Member @@ -72,7 +72,7 @@ pub trait Trait: frame_system::Trait { } decl_storage! { - trait Store for Module as Rewards { + trait Store for Module as Rewards { /// Stores reward pool info. pub Pools get(fn pools): map hasher(twox_64_concat) T::PoolId => PoolInfo; @@ -82,7 +82,7 @@ decl_storage! { } decl_module! { - pub struct Module for enum Call where origin: T::Origin { + pub struct Module for enum Call where origin: T::Origin { fn on_initialize(now: T::BlockNumber) -> Weight { let mut count = 0; @@ -97,7 +97,7 @@ decl_module! { } } -impl Module { +impl Module { pub fn add_share(who: &T::AccountId, pool: T::PoolId, add_amount: T::Share) { if add_amount.is_zero() { return; diff --git a/rewards/src/mock.rs b/rewards/src/mock.rs index 104732134..61fa057ab 100644 --- a/rewards/src/mock.rs +++ b/rewards/src/mock.rs @@ -38,7 +38,7 @@ parameter_types! { pub const AvailableBlockRatio: Perbill = Perbill::one(); } -impl frame_system::Trait for Runtime { +impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = BlockNumber; @@ -113,7 +113,7 @@ impl RewardHandler for Handler { } } -impl Trait for Runtime { +impl Config for Runtime { type Share = Share; type Balance = Balance; type PoolId = PoolId; diff --git a/tokens/src/imbalances.rs b/tokens/src/imbalances.rs index 5c6a857aa..49395e92c 100644 --- a/tokens/src/imbalances.rs +++ b/tokens/src/imbalances.rs @@ -1,6 +1,6 @@ // wrapping these imbalances in a private module is necessary to ensure absolute // privacy of the inner member. -use crate::{TotalIssuance, Trait}; +use crate::{Config, TotalIssuance}; use frame_support::storage::StorageMap; use frame_support::traits::{Get, Imbalance, TryDrop}; use sp_runtime::traits::{Saturating, Zero}; @@ -10,12 +10,12 @@ use sp_std::{marker, mem, result}; /// denoting that funds have been created without any equal and opposite /// accounting. #[must_use] -pub struct PositiveImbalance>( +pub struct PositiveImbalance>( T::Balance, marker::PhantomData, ); -impl> PositiveImbalance { +impl> PositiveImbalance { /// Create a new positive imbalance from a balance. pub fn new(amount: T::Balance) -> Self { PositiveImbalance(amount, marker::PhantomData::) @@ -26,25 +26,25 @@ impl> PositiveImbalance>( +pub struct NegativeImbalance>( T::Balance, marker::PhantomData, ); -impl> NegativeImbalance { +impl> NegativeImbalance { /// Create a new negative imbalance from a balance. pub fn new(amount: T::Balance) -> Self { NegativeImbalance(amount, marker::PhantomData::) } } -impl> TryDrop for PositiveImbalance { +impl> TryDrop for PositiveImbalance { fn try_drop(self) -> result::Result<(), Self> { self.drop_zero() } } -impl> Imbalance for PositiveImbalance { +impl> Imbalance for PositiveImbalance { type Opposite = NegativeImbalance; fn zero() -> Self { @@ -89,13 +89,13 @@ impl> Imbalance for Posi } } -impl> TryDrop for NegativeImbalance { +impl> TryDrop for NegativeImbalance { fn try_drop(self) -> result::Result<(), Self> { self.drop_zero() } } -impl> Imbalance for NegativeImbalance { +impl> Imbalance for NegativeImbalance { type Opposite = PositiveImbalance; fn zero() -> Self { @@ -140,14 +140,14 @@ impl> Imbalance for Nega } } -impl> Drop for PositiveImbalance { +impl> Drop for PositiveImbalance { /// Basic drop handler will just square up the total issuance. fn drop(&mut self) { >::mutate(GetCurrencyId::get(), |v| *v = v.saturating_add(self.0)); } } -impl> Drop for NegativeImbalance { +impl> Drop for NegativeImbalance { /// Basic drop handler will just square up the total issuance. fn drop(&mut self) { >::mutate(GetCurrencyId::get(), |v| *v = v.saturating_sub(self.0)); diff --git a/tokens/src/lib.rs b/tokens/src/lib.rs index de0a45a47..995f71ec8 100644 --- a/tokens/src/lib.rs +++ b/tokens/src/lib.rs @@ -88,7 +88,7 @@ pub trait WeightInfo { pub struct TransferDust(marker::PhantomData<(T, GetAccountId)>); impl OnDust for TransferDust where - T: Trait, + T: Config, GetAccountId: Get, { fn on_dust(who: &T::AccountId, currency_id: T::CurrencyId, amount: T::Balance) { @@ -99,7 +99,7 @@ where } pub struct BurnDust(marker::PhantomData); -impl OnDust for BurnDust { +impl OnDust for BurnDust { fn on_dust(who: &T::AccountId, currency_id: T::CurrencyId, amount: T::Balance) { // burn the dust, ignore the result, // if failed will leave some dust which still could be recycled. @@ -107,8 +107,8 @@ impl OnDust for BurnDust { } } -pub trait Trait: frame_system::Trait { - type Event: From> + Into<::Event>; +pub trait Config: frame_system::Config { + type Event: From> + Into<::Event>; /// The balance type type Balance: Parameter + Member + AtLeast32BitUnsigned + Default + Copy + MaybeSerializeDeserialize; @@ -184,7 +184,7 @@ impl AccountData { } decl_storage! { - trait Store for Module as Tokens { + trait Store for Module as Tokens { /// The total issuance of a token type. pub TotalIssuance get(fn total_issuance) build(|config: &GenesisConfig| { config @@ -232,9 +232,9 @@ decl_storage! { decl_event!( pub enum Event where - ::AccountId, - ::CurrencyId, - ::Balance + ::AccountId, + ::CurrencyId, + ::Balance { /// Token transfer success. \[currency_id, from, to, amount\] Transferred(CurrencyId, AccountId, AccountId, Balance), @@ -245,7 +245,7 @@ decl_event!( ); decl_module! { - pub struct Module for enum Call where origin: T::Origin { + pub struct Module for enum Call where origin: T::Origin { type Error = Error; fn deposit_event() = default; @@ -304,7 +304,7 @@ decl_module! { decl_error! { /// Error for token module. - pub enum Error for Module { + pub enum Error for Module { /// The balance is too low BalanceTooLow, /// This operation will cause balance to overflow @@ -320,7 +320,7 @@ decl_error! { } } -impl Module { +impl Module { /// Check whether account_id is a module account fn is_module_account_id(account_id: &T::AccountId) -> bool { ModuleId::try_from_account(account_id).is_some() @@ -430,7 +430,7 @@ impl Module { } } -impl MultiCurrency for Module { +impl MultiCurrency for Module { type CurrencyId = T::CurrencyId; type Balance = T::Balance; @@ -572,7 +572,7 @@ impl MultiCurrency for Module { } } -impl MultiCurrencyExtended for Module { +impl MultiCurrencyExtended for Module { type Amount = T::Amount; fn update_balance(currency_id: Self::CurrencyId, who: &T::AccountId, by_amount: Self::Amount) -> DispatchResult { @@ -598,7 +598,7 @@ impl MultiCurrencyExtended for Module { } } -impl MultiLockableCurrency for Module { +impl MultiLockableCurrency for Module { type Moment = T::BlockNumber; // Set a lock on the balance of `who` under `currency_id`. @@ -657,7 +657,7 @@ impl MultiLockableCurrency for Module { } } -impl MultiReservableCurrency for Module { +impl MultiReservableCurrency for Module { /// Check if `who` can reserve `value` from their free balance. /// /// Always `true` if value to be reserved is zero. @@ -767,7 +767,7 @@ pub struct CurrencyAdapter(marker::PhantomData<(T, GetCurrency impl PalletCurrency for CurrencyAdapter where - T: Trait, + T: Config, GetCurrencyId: Get, { type Balance = T::Balance; @@ -937,7 +937,7 @@ where impl PalletReservableCurrency for CurrencyAdapter where - T: Trait, + T: Config, GetCurrencyId: Get, { fn can_reserve(who: &T::AccountId, value: Self::Balance) -> bool { @@ -973,7 +973,7 @@ where impl PalletLockableCurrency for CurrencyAdapter where - T: Trait, + T: Config, GetCurrencyId: Get, { type Moment = T::BlockNumber; @@ -992,7 +992,7 @@ where } } -impl MergeAccount for Module { +impl MergeAccount for Module { #[transactional] fn merge_account(source: &T::AccountId, dest: &T::AccountId) -> DispatchResult { Accounts::::iter_prefix(source).try_for_each(|(currency_id, account_data)| -> DispatchResult { diff --git a/tokens/src/mock.rs b/tokens/src/mock.rs index 3efd2e39e..be3db4702 100644 --- a/tokens/src/mock.rs +++ b/tokens/src/mock.rs @@ -58,7 +58,7 @@ parameter_types! { pub const AvailableBlockRatio: Perbill = Perbill::one(); } -impl frame_system::Trait for Runtime { +impl frame_system::Config for Runtime { type Origin = Origin; type Call = (); type Index = u64; @@ -134,7 +134,7 @@ parameter_types! { pub const GetTokenId: CurrencyId = DOT; } -impl pallet_treasury::Trait for Runtime { +impl pallet_treasury::Config for Runtime { type ModuleId = TreasuryModuleId; type Currency = CurrencyAdapter; type ApproveOrigin = frame_system::EnsureRoot; @@ -252,7 +252,7 @@ parameter_types! { pub const ElectionsPhragmenModuleId: LockIdentifier = *b"phrelect"; } -impl pallet_elections_phragmen::Trait for Runtime { +impl pallet_elections_phragmen::Config for Runtime { type ModuleId = ElectionsPhragmenModuleId; type Event = TestEvent; type Currency = CurrencyAdapter; @@ -284,7 +284,7 @@ parameter_types! { pub DustAccount: AccountId = ModuleId(*b"orml/dst").into_account(); } -impl Trait for Runtime { +impl Config for Runtime { type Event = TestEvent; type Balance = Balance; type Amount = i64; @@ -294,7 +294,7 @@ impl Trait for Runtime { type OnDust = TransferDust; } pub type Tokens = Module; -pub type TreasuryCurrencyAdapter = ::Currency; +pub type TreasuryCurrencyAdapter = ::Currency; pub struct ExtBuilder { endowed_accounts: Vec<(AccountId, CurrencyId, Balance)>, diff --git a/tokens/src/tests.rs b/tokens/src/tests.rs index 29bc64d57..8f4877840 100644 --- a/tokens/src/tests.rs +++ b/tokens/src/tests.rs @@ -471,120 +471,120 @@ fn currency_adapter_ensure_currency_adapter_should_work() { assert_eq!(Tokens::reserved_balance(DOT, &TREASURY_ACCOUNT), 5); assert_eq!(Tokens::free_balance(DOT, &TREASURY_ACCOUNT), 95); assert_eq!( - ::Currency::total_balance(&TREASURY_ACCOUNT), + ::Currency::total_balance(&TREASURY_ACCOUNT), 100 ); assert_eq!( - ::Currency::can_slash(&TREASURY_ACCOUNT, 10), + ::Currency::can_slash(&TREASURY_ACCOUNT, 10), true ); assert_eq!( - ::Currency::total_issuance(), + ::Currency::total_issuance(), 102 ); assert_eq!( - ::Currency::minimum_balance(), + ::Currency::minimum_balance(), 2 ); assert_eq!( - ::Currency::can_reserve(&TREASURY_ACCOUNT, 5), + ::Currency::can_reserve(&TREASURY_ACCOUNT, 5), true ); // burn - let imbalance = ::Currency::burn(10); + let imbalance = ::Currency::burn(10); assert_eq!( - ::Currency::total_issuance(), + ::Currency::total_issuance(), 92 ); drop(imbalance); assert_eq!( - ::Currency::total_issuance(), + ::Currency::total_issuance(), 102 ); // issue - let imbalance = ::Currency::issue(20); + let imbalance = ::Currency::issue(20); assert_eq!( - ::Currency::total_issuance(), + ::Currency::total_issuance(), 122 ); drop(imbalance); assert_eq!( - ::Currency::total_issuance(), + ::Currency::total_issuance(), 102 ); // transfer assert_eq!( - ::Currency::free_balance(&TREASURY_ACCOUNT), + ::Currency::free_balance(&TREASURY_ACCOUNT), 95 ); assert_ok!( - ::Currency::ensure_can_withdraw( + ::Currency::ensure_can_withdraw( &TREASURY_ACCOUNT, 10, WithdrawReasons::TRANSFER, 0 ) ); - assert_ok!(::Currency::transfer( + assert_ok!(::Currency::transfer( &TREASURY_ACCOUNT, &ALICE, 11, ExistenceRequirement::KeepAlive )); assert_eq!( - ::Currency::free_balance(&TREASURY_ACCOUNT), + ::Currency::free_balance(&TREASURY_ACCOUNT), 84 ); // deposit assert_eq!( - ::Currency::total_issuance(), + ::Currency::total_issuance(), 102 ); let imbalance = TreasuryCurrencyAdapter::deposit_creating(&TREASURY_ACCOUNT, 11); assert_eq!( - ::Currency::free_balance(&TREASURY_ACCOUNT), + ::Currency::free_balance(&TREASURY_ACCOUNT), 95 ); assert_eq!( - ::Currency::total_issuance(), + ::Currency::total_issuance(), 102 ); drop(imbalance); assert_eq!( - ::Currency::free_balance(&TREASURY_ACCOUNT), + ::Currency::free_balance(&TREASURY_ACCOUNT), 95 ); assert_eq!( - ::Currency::total_issuance(), + ::Currency::total_issuance(), 113 ); // withdraw - let imbalance = ::Currency::withdraw( + let imbalance = ::Currency::withdraw( &TREASURY_ACCOUNT, 10, WithdrawReasons::TRANSFER, ExistenceRequirement::KeepAlive, ); assert_eq!( - ::Currency::free_balance(&TREASURY_ACCOUNT), + ::Currency::free_balance(&TREASURY_ACCOUNT), 85 ); assert_eq!( - ::Currency::total_issuance(), + ::Currency::total_issuance(), 113 ); drop(imbalance); assert_eq!( - ::Currency::free_balance(&TREASURY_ACCOUNT), + ::Currency::free_balance(&TREASURY_ACCOUNT), 85 ); assert_eq!( - ::Currency::total_issuance(), + ::Currency::total_issuance(), 103 ); }); diff --git a/utilities/src/lib.rs b/utilities/src/lib.rs index 91a71e64b..2304d9e5d 100644 --- a/utilities/src/lib.rs +++ b/utilities/src/lib.rs @@ -37,14 +37,14 @@ mod tests { use sp_io::TestExternalities; use sp_runtime::{DispatchError, DispatchResult}; - pub trait Trait: frame_system::Trait {} + pub trait Config: frame_system::Config {} decl_module! { - pub struct Module for enum Call where origin: T::Origin {} + pub struct Module for enum Call where origin: T::Origin {} } decl_storage! { - trait Store for Module as StorageTransactions { + trait Store for Module as StorageTransactions { pub Value: u32; pub Map: map hasher(twox_64_concat) String => u32; } diff --git a/vesting/src/lib.rs b/vesting/src/lib.rs index 72bf9cd50..90f03d537 100644 --- a/vesting/src/lib.rs +++ b/vesting/src/lib.rs @@ -106,18 +106,18 @@ impl VestingSche } } -pub type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; -pub type VestingScheduleOf = VestingSchedule<::BlockNumber, BalanceOf>; +pub type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; +pub type VestingScheduleOf = VestingSchedule<::BlockNumber, BalanceOf>; pub type ScheduledItem = ( - ::AccountId, - ::BlockNumber, - ::BlockNumber, + ::AccountId, + ::BlockNumber, + ::BlockNumber, u32, BalanceOf, ); -pub trait Trait: frame_system::Trait { - type Event: From> + Into<::Event>; +pub trait Config: frame_system::Config { + type Event: From> + Into<::Event>; type Currency: LockableCurrency; /// The minimum amount transferred to call `vested_transfer`. @@ -131,7 +131,7 @@ pub trait Trait: frame_system::Trait { } decl_storage! { - trait Store for Module as Vesting { + trait Store for Module as Vesting { /// Vesting schedules of an account. pub VestingSchedules get(fn vesting_schedules) build(|config: &GenesisConfig| { config.vesting.iter() @@ -152,7 +152,7 @@ decl_storage! { decl_event!( pub enum Event where - ::AccountId, + ::AccountId, Balance = BalanceOf, VestingSchedule = VestingScheduleOf { @@ -167,7 +167,7 @@ decl_event!( decl_error! { /// Error for vesting module. - pub enum Error for Module { + pub enum Error for Module { /// Vesting period is zero ZeroVestingPeriod, /// Number of vests is zero @@ -184,7 +184,7 @@ decl_error! { } decl_module! { - pub struct Module for enum Call where origin: T::Origin { + pub struct Module for enum Call where origin: T::Origin { type Error = Error; /// The minimum amount to be transferred to create a new vesting schedule. @@ -259,7 +259,7 @@ decl_module! { const VESTING_LOCK_ID: LockIdentifier = *b"ormlvest"; -impl Module { +impl Module { fn do_claim(who: &T::AccountId) -> BalanceOf { let locked = Self::locked_balance(who); if locked.is_zero() { diff --git a/vesting/src/mock.rs b/vesting/src/mock.rs index 55f2ef219..852cc7d87 100644 --- a/vesting/src/mock.rs +++ b/vesting/src/mock.rs @@ -36,7 +36,7 @@ parameter_types! { } pub type AccountId = u128; -impl frame_system::Trait for Runtime { +impl frame_system::Config for Runtime { type Origin = Origin; type Call = (); type Index = u64; @@ -72,7 +72,7 @@ parameter_types! { pub const MinVestedTransfer: u64 = 5; } -impl pallet_balances::Trait for Runtime { +impl pallet_balances::Config for Runtime { type Balance = Balance; type DustRemoval = (); type Event = TestEvent; @@ -101,7 +101,7 @@ impl EnsureOrigin for EnsureAliceOrBob { } } -impl Trait for Runtime { +impl Config for Runtime { type Event = TestEvent; type Currency = PalletBalances; type MinVestedTransfer = MinVestedTransfer;