Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit c40d301

Browse files
authored
Revert "Move LockableCurrency trait to fungibles::Lockable and deprecate LockableCurrency (#12798)"
This reverts commit ea3ca3f.
1 parent 9a0644c commit c40d301

File tree

20 files changed

+105
-135
lines changed

20 files changed

+105
-135
lines changed

bin/node/runtime/src/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ use frame_support::{
3232
pallet_prelude::Get,
3333
parameter_types,
3434
traits::{
35-
fungible::ItemOf, fungibles, AsEnsureOriginWithArg, ConstBool, ConstU128, ConstU16,
36-
ConstU32, Currency, EitherOfDiverse, EqualPrivilegeOnly, Everything, Imbalance,
37-
InstanceFilter, KeyOwnerProofSystem, Nothing, OnUnbalanced, U128CurrencyToVote,
35+
fungible::ItemOf, AsEnsureOriginWithArg, ConstBool, ConstU128, ConstU16, ConstU32,
36+
Currency, EitherOfDiverse, EqualPrivilegeOnly, Everything, Imbalance, InstanceFilter,
37+
KeyOwnerProofSystem, LockIdentifier, Nothing, OnUnbalanced, U128CurrencyToVote,
3838
WithdrawReasons,
3939
},
4040
weights::{
@@ -1006,7 +1006,7 @@ parameter_types! {
10061006
pub const DesiredRunnersUp: u32 = 7;
10071007
pub const MaxVoters: u32 = 10 * 1000;
10081008
pub const MaxCandidates: u32 = 1000;
1009-
pub const ElectionsPhragmenPalletId: fungibles::LockIdentifier = *b"phrelect";
1009+
pub const ElectionsPhragmenPalletId: LockIdentifier = *b"phrelect";
10101010
}
10111011

10121012
// Make sure that there are no more than `MaxMembers` members elected via elections-phragmen.

frame/balances/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ that you need, then you can avoid coupling with the Balances module.
5757
fungible assets system.
5858
- [`ReservableCurrency`](https://docs.rs/frame-support/latest/frame_support/traits/trait.ReservableCurrency.html):
5959
Functions for dealing with assets that can be reserved from an account.
60-
- [`Lockable`](https://docs.rs/frame-support/latest/frame_support/traits/fungibles/trait.Lockable.html): Functions for
60+
- [`LockableCurrency`](https://docs.rs/frame-support/latest/frame_support/traits/trait.LockableCurrency.html): Functions for
6161
dealing with accounts that allow liquidity restrictions.
6262
- [`Imbalance`](https://docs.rs/frame-support/latest/frame_support/traits/trait.Imbalance.html): Functions for handling
6363
imbalances between total issuance in the system and account balances. Must be used when a function
@@ -88,13 +88,13 @@ pub type NegativeImbalanceOf<T> = <<T as Config>::Currency as Currency<<T as fra
8888

8989
```
9090

91-
The Staking module uses the `fungibles::Lockable` trait to lock a stash account's funds:
91+
The Staking module uses the `LockableCurrency` trait to lock a stash account's funds:
9292

9393
```rust
94-
use frame_support::traits::{WithdrawReasons, fungibles};
94+
use frame_support::traits::{WithdrawReasons, LockableCurrency};
9595
use sp_runtime::traits::Bounded;
9696
pub trait Config: frame_system::Config {
97-
type Currency: fungibles::Lockable<Self::AccountId, Moment=Self::BlockNumber>;
97+
type Currency: LockableCurrency<Self::AccountId, Moment=Self::BlockNumber>;
9898
}
9999

100100
fn update_ledger<T: Config>(

frame/balances/src/lib.rs

+12-14
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
//! - [`ReservableCurrency`](frame_support::traits::ReservableCurrency):
8080
//! - [`NamedReservableCurrency`](frame_support::traits::NamedReservableCurrency):
8181
//! Functions for dealing with assets that can be reserved from an account.
82-
//! - [`Lockable`](frame_support::traits::fungibles::Lockable): Functions for
82+
//! - [`LockableCurrency`](frame_support::traits::LockableCurrency): Functions for
8383
//! dealing with accounts that allow liquidity restrictions.
8484
//! - [`Imbalance`](frame_support::traits::Imbalance): Functions for handling
8585
//! imbalances between total issuance in the system and account balances. Must be used when a
@@ -113,13 +113,13 @@
113113
//! # fn main() {}
114114
//! ```
115115
//!
116-
//! The Staking pallet uses the `fungibles::Lockable` trait to lock a stash account's funds:
116+
//! The Staking pallet uses the `LockableCurrency` trait to lock a stash account's funds:
117117
//!
118118
//! ```
119-
//! use frame_support::traits::{WithdrawReasons, fungibles, fungibles::Lockable};
119+
//! use frame_support::traits::{WithdrawReasons, LockableCurrency};
120120
//! use sp_runtime::traits::Bounded;
121121
//! pub trait Config: frame_system::Config {
122-
//! type Currency: fungibles::Lockable<Self::AccountId, Moment=Self::BlockNumber>;
122+
//! type Currency: LockableCurrency<Self::AccountId, Moment=Self::BlockNumber>;
123123
//! }
124124
//! # struct StakingLedger<T: Config> {
125125
//! # stash: <T as frame_system::Config>::AccountId,
@@ -171,13 +171,11 @@ use frame_support::{
171171
ensure,
172172
pallet_prelude::DispatchResult,
173173
traits::{
174-
tokens::{
175-
fungible, fungibles, BalanceStatus as Status, DepositConsequence, WithdrawConsequence,
176-
},
174+
tokens::{fungible, BalanceStatus as Status, DepositConsequence, WithdrawConsequence},
177175
Currency, DefensiveSaturating, ExistenceRequirement,
178176
ExistenceRequirement::{AllowDeath, KeepAlive},
179-
Get, Imbalance, NamedReservableCurrency, OnUnbalanced, ReservableCurrency, SignedImbalance,
180-
StoredMap, TryDrop, WithdrawReasons,
177+
Get, Imbalance, LockIdentifier, LockableCurrency, NamedReservableCurrency, OnUnbalanced,
178+
ReservableCurrency, SignedImbalance, StoredMap, TryDrop, WithdrawReasons,
181179
},
182180
WeakBoundedVec,
183181
};
@@ -664,7 +662,7 @@ impl BitOr for Reasons {
664662
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, MaxEncodedLen, TypeInfo)]
665663
pub struct BalanceLock<Balance> {
666664
/// An identifier for this lock. Only one lock may be in existence for each identifier.
667-
pub id: fungibles::LockIdentifier,
665+
pub id: LockIdentifier,
668666
/// The amount which the free balance may not drop below when this lock is in effect.
669667
pub amount: Balance,
670668
/// If true, then the lock remains in effect even for payment of transaction fees.
@@ -2133,7 +2131,7 @@ where
21332131
}
21342132
}
21352133

2136-
impl<T: Config<I>, I: 'static> fungibles::Lockable<T::AccountId> for Pallet<T, I>
2134+
impl<T: Config<I>, I: 'static> LockableCurrency<T::AccountId> for Pallet<T, I>
21372135
where
21382136
T::Balance: MaybeSerializeDeserialize + Debug,
21392137
{
@@ -2144,7 +2142,7 @@ where
21442142
// Set a lock on the balance of `who`.
21452143
// Is a no-op if lock amount is zero or `reasons` `is_none()`.
21462144
fn set_lock(
2147-
id: fungibles::LockIdentifier,
2145+
id: LockIdentifier,
21482146
who: &T::AccountId,
21492147
amount: T::Balance,
21502148
reasons: WithdrawReasons,
@@ -2166,7 +2164,7 @@ where
21662164
// Extend a lock on the balance of `who`.
21672165
// Is a no-op if lock amount is zero or `reasons` `is_none()`.
21682166
fn extend_lock(
2169-
id: fungibles::LockIdentifier,
2167+
id: LockIdentifier,
21702168
who: &T::AccountId,
21712169
amount: T::Balance,
21722170
reasons: WithdrawReasons,
@@ -2195,7 +2193,7 @@ where
21952193
Self::update_locks(who, &locks[..]);
21962194
}
21972195

2198-
fn remove_lock(id: fungibles::LockIdentifier, who: &T::AccountId) {
2196+
fn remove_lock(id: LockIdentifier, who: &T::AccountId) {
21992197
let mut locks = Self::locks(who);
22002198
locks.retain(|l| l.id != id);
22012199
Self::update_locks(who, &locks[..]);

frame/balances/src/tests.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ macro_rules! decl_tests {
2828
use frame_support::{
2929
assert_noop, assert_storage_noop, assert_ok, assert_err,
3030
traits::{
31-
fungibles, fungibles::Lockable, WithdrawReasons,
31+
LockableCurrency, LockIdentifier, WithdrawReasons,
3232
Currency, ReservableCurrency, ExistenceRequirement::AllowDeath
3333
}
3434
};
3535
use pallet_transaction_payment::{ChargeTransactionPayment, Multiplier};
3636
use frame_system::RawOrigin;
3737

38-
const ID_1: fungibles::LockIdentifier = *b"1 ";
39-
const ID_2: fungibles::LockIdentifier = *b"2 ";
38+
const ID_1: LockIdentifier = *b"1 ";
39+
const ID_2: LockIdentifier = *b"2 ";
4040

4141
pub const CALL: &<$test as frame_system::Config>::RuntimeCall =
4242
&RuntimeCall::Balances(pallet_balances::Call::transfer { dest: 0, value: 0 });

frame/contracts/src/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use frame_support::{
3737
parameter_types,
3838
storage::child,
3939
traits::{
40-
fungibles::Lockable, BalanceStatus, ConstU32, ConstU64, Contains, Currency, Get, OnIdle,
40+
BalanceStatus, ConstU32, ConstU64, Contains, Currency, Get, LockableCurrency, OnIdle,
4141
OnInitialize, ReservableCurrency, WithdrawReasons,
4242
},
4343
weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight},

frame/conviction-voting/src/benchmarking.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use assert_matches::assert_matches;
2323
use frame_benchmarking::{account, benchmarks_instance_pallet, whitelist_account};
2424
use frame_support::{
2525
dispatch::RawOrigin,
26-
traits::{Currency, Get},
26+
traits::{fungible, Currency, Get},
2727
};
2828
use sp_runtime::traits::Bounded;
2929
use sp_std::collections::btree_map::BTreeMap;

frame/conviction-voting/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use frame_support::{
3131
dispatch::{DispatchError, DispatchResult},
3232
ensure,
3333
traits::{
34-
fungible, fungibles, fungibles::Lockable, Currency, Get, PollStatus, Polling,
34+
fungible, Currency, Get, LockIdentifier, LockableCurrency, PollStatus, Polling,
3535
ReservableCurrency, WithdrawReasons,
3636
},
3737
};
@@ -60,7 +60,7 @@ mod tests;
6060
#[cfg(feature = "runtime-benchmarks")]
6161
pub mod benchmarking;
6262

63-
const CONVICTION_VOTING_ID: fungibles::LockIdentifier = *b"pyconvot";
63+
const CONVICTION_VOTING_ID: LockIdentifier = *b"pyconvot";
6464

6565
type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;
6666
type BalanceOf<T, I = ()> =
@@ -104,7 +104,7 @@ pub mod pallet {
104104
type WeightInfo: WeightInfo;
105105
/// Currency type with which voting happens.
106106
type Currency: ReservableCurrency<Self::AccountId>
107-
+ fungibles::Lockable<Self::AccountId, Moment = Self::BlockNumber>
107+
+ LockableCurrency<Self::AccountId, Moment = Self::BlockNumber>
108108
+ fungible::Inspect<Self::AccountId>;
109109

110110
/// The implementation of the logic which conducts polls.

frame/democracy/src/lib.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,9 @@ use frame_support::{
157157
ensure,
158158
traits::{
159159
defensive_prelude::*,
160-
fungibles,
161-
fungibles::Lockable,
162160
schedule::{v3::Named as ScheduleNamed, DispatchTime},
163-
Bounded, Currency, Get, OnUnbalanced, QueryPreimage, ReservableCurrency, StorePreimage,
164-
WithdrawReasons,
161+
Bounded, Currency, Get, LockIdentifier, LockableCurrency, OnUnbalanced, QueryPreimage,
162+
ReservableCurrency, StorePreimage, WithdrawReasons,
165163
},
166164
weights::Weight,
167165
};
@@ -191,7 +189,7 @@ pub mod benchmarking;
191189

192190
pub mod migrations;
193191

194-
const DEMOCRACY_ID: fungibles::LockIdentifier = *b"democrac";
192+
const DEMOCRACY_ID: LockIdentifier = *b"democrac";
195193

196194
/// A proposal index.
197195
pub type PropIndex = u32;
@@ -236,7 +234,7 @@ pub mod pallet {
236234

237235
/// Currency type for this pallet.
238236
type Currency: ReservableCurrency<Self::AccountId>
239-
+ fungibles::Lockable<Self::AccountId, Moment = Self::BlockNumber>;
237+
+ LockableCurrency<Self::AccountId, Moment = Self::BlockNumber>;
240238

241239
/// The period between a proposal being approved and enacted.
242240
///

frame/elections-phragmen/src/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@
101101
use codec::{Decode, Encode};
102102
use frame_support::{
103103
traits::{
104-
defensive_prelude::*, fungibles, fungibles::Lockable, ChangeMembers, Contains,
105-
ContainsLengthBound, Currency, CurrencyToVote, Get, InitializeMembers, OnUnbalanced,
104+
defensive_prelude::*, ChangeMembers, Contains, ContainsLengthBound, Currency,
105+
CurrencyToVote, Get, InitializeMembers, LockIdentifier, LockableCurrency, OnUnbalanced,
106106
ReservableCurrency, SortedMembers, WithdrawReasons,
107107
},
108108
weights::Weight,
@@ -199,10 +199,10 @@ pub mod pallet {
199199

200200
/// Identifier for the elections-phragmen pallet's lock
201201
#[pallet::constant]
202-
type PalletId: Get<fungibles::LockIdentifier>;
202+
type PalletId: Get<LockIdentifier>;
203203

204204
/// The currency that people are electing with.
205-
type Currency: fungibles::Lockable<Self::AccountId, Moment = Self::BlockNumber>
205+
type Currency: LockableCurrency<Self::AccountId, Moment = Self::BlockNumber>
206206
+ ReservableCurrency<Self::AccountId>;
207207

208208
/// What to do when the members change.
@@ -1274,7 +1274,7 @@ mod tests {
12741274
}
12751275

12761276
parameter_types! {
1277-
pub const ElectionsPhragmenPalletId: fungibles::LockIdentifier = *b"phrelect";
1277+
pub const ElectionsPhragmenPalletId: LockIdentifier = *b"phrelect";
12781278
pub const PhragmenMaxVoters: u32 = 1000;
12791279
pub const PhragmenMaxCandidates: u32 = 100;
12801280
}

frame/executive/src/lib.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,10 @@ mod tests {
620620

621621
use frame_support::{
622622
assert_err, parameter_types,
623-
traits::{fungibles, ConstU32, ConstU64, ConstU8, Currency, WithdrawReasons},
623+
traits::{
624+
ConstU32, ConstU64, ConstU8, Currency, LockIdentifier, LockableCurrency,
625+
WithdrawReasons,
626+
},
624627
weights::{ConstantMultiplier, IdentityFee, RuntimeDbWeight, Weight, WeightToFee},
625628
};
626629
use frame_system::{Call as SystemCall, ChainContext, LastRuntimeUpgradeInfo};
@@ -1182,11 +1185,11 @@ mod tests {
11821185

11831186
#[test]
11841187
fn can_pay_for_tx_fee_on_full_lock() {
1185-
let id: fungibles::LockIdentifier = *b"0 ";
1188+
let id: LockIdentifier = *b"0 ";
11861189
let execute_with_lock = |lock: WithdrawReasons| {
11871190
let mut t = new_test_ext(1);
11881191
t.execute_with(|| {
1189-
<pallet_balances::Pallet<Runtime> as fungibles::Lockable<Balance>>::set_lock(
1192+
<pallet_balances::Pallet<Runtime> as LockableCurrency<Balance>>::set_lock(
11901193
id, &1, 110, lock,
11911194
);
11921195
let xt = TestXt::new(

frame/referenda/src/lib.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// This file is part of Substrate.
2+
13
// Copyright (C) 2017-2022 Parity Technologies (UK) Ltd.
24
// SPDX-License-Identifier: Apache-2.0
35

@@ -66,12 +68,11 @@ use codec::{Codec, Encode};
6668
use frame_support::{
6769
ensure,
6870
traits::{
69-
fungibles,
7071
schedule::{
7172
v3::{Anon as ScheduleAnon, Named as ScheduleNamed},
7273
DispatchTime,
7374
},
74-
Currency, OnUnbalanced, OriginTrait, PollStatus, Polling, QueryPreimage,
75+
Currency, LockIdentifier, OnUnbalanced, OriginTrait, PollStatus, Polling, QueryPreimage,
7576
ReservableCurrency, StorePreimage, VoteTally,
7677
},
7778
BoundedVec,
@@ -132,7 +133,7 @@ macro_rules! impl_tracksinfo_get {
132133
};
133134
}
134135

135-
const ASSEMBLY_ID: fungibles::LockIdentifier = *b"assembly";
136+
const ASSEMBLY_ID: LockIdentifier = *b"assembly";
136137

137138
#[frame_support::pallet]
138139
pub mod pallet {

frame/staking/src/pallet/impls.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ use frame_support::{
2525
dispatch::WithPostDispatchInfo,
2626
pallet_prelude::*,
2727
traits::{
28-
fungibles::Lockable, Currency, CurrencyToVote, Defensive, DefensiveResult,
29-
EstimateNextNewSession, Get, Imbalance, OnUnbalanced, TryCollect, UnixTime,
30-
WithdrawReasons,
28+
Currency, CurrencyToVote, Defensive, DefensiveResult, EstimateNextNewSession, Get,
29+
Imbalance, LockableCurrency, OnUnbalanced, TryCollect, UnixTime, WithdrawReasons,
3130
},
3231
weights::Weight,
3332
};

frame/staking/src/pallet/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ use frame_support::{
2424
dispatch::Codec,
2525
pallet_prelude::*,
2626
traits::{
27-
fungibles, fungibles::Lockable, Currency, CurrencyToVote, Defensive, DefensiveResult,
28-
DefensiveSaturating, EnsureOrigin, EstimateNextNewSession, Get, OnUnbalanced, TryCollect,
27+
Currency, CurrencyToVote, Defensive, DefensiveResult, DefensiveSaturating, EnsureOrigin,
28+
EstimateNextNewSession, Get, LockIdentifier, LockableCurrency, OnUnbalanced, TryCollect,
2929
UnixTime,
3030
},
3131
weights::Weight,
@@ -50,7 +50,7 @@ use crate::{
5050
ValidatorPrefs,
5151
};
5252

53-
const STAKING_ID: fungibles::LockIdentifier = *b"staking ";
53+
const STAKING_ID: LockIdentifier = *b"staking ";
5454

5555
#[frame_support::pallet]
5656
pub mod pallet {
@@ -78,7 +78,7 @@ pub mod pallet {
7878
#[pallet::config]
7979
pub trait Config: frame_system::Config {
8080
/// The staking balance.
81-
type Currency: fungibles::Lockable<
81+
type Currency: LockableCurrency<
8282
Self::AccountId,
8383
Moment = Self::BlockNumber,
8484
Balance = Self::CurrencyBalance,

frame/support/src/traits.rs

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
//! NOTE: If you're looking for `parameter_types`, it has moved in to the top-level module.
2121
2222
pub mod tokens;
23-
#[allow(deprecated)]
2423
pub use tokens::{
2524
currency::{
2625
ActiveIssuanceOf, Currency, LockIdentifier, LockableCurrency, NamedReservableCurrency,

frame/support/src/traits/tokens/currency.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ use sp_std::fmt::Debug;
3232
mod reservable;
3333
pub use reservable::{NamedReservableCurrency, ReservableCurrency};
3434
mod lockable;
35-
36-
#[deprecated(note = "Deprecated in favour of using fungibles::Lockable trait directly")]
37-
pub use super::fungibles::{LockIdentifier, Lockable as LockableCurrency};
38-
pub use lockable::VestingSchedule;
35+
pub use lockable::{LockIdentifier, LockableCurrency, VestingSchedule};
3936

4037
/// Abstraction over a fungible assets system.
4138
pub trait Currency<AccountId> {

0 commit comments

Comments
 (0)