Open gavofyork opened 1 year ago
I made a comment here, but will bring it here too.
While changing from Currency
to Fungible
trait, I think you should also update the name of the Associated type.
For example, this is weird to me:
/// Currency type that this works on.
type Currency: FunInspect<Self::AccountId, Balance = Self::CurrencyBalance>
+ FunMutate<Self::AccountId>
+ FunBalanced<Self::AccountId>
+ FunHoldMutate<Self::AccountId, Reason = Self::RuntimeHoldReason>;
Perhaps we should use the name NativeBalance
for the native token balance (Balances pallet), and TokenBalance
for use of the Assets pallet and stuff.
We can observe various approaches to this refactoring. I think it does not provide the best developer experience to see the "same" stuff implemented in multiple ways within a single repository:
// 1.
type Currency: Mutate<Self::AccountId> + Balanced<Self::AccountId>;
// 2.
type Currency: frame_support::traits::fungible::Inspect<Self::AccountId>;
// 3.
/// This is kind of unclear `Fn` as Function? or `Fn` as Fungible? What about Fungibles? Fns?
type Currency: FnMutate<Self::AccountId>
+ FnMutateHold<Self::AccountId, Reason = Self::RuntimeHoldReason>
+ FnBalanced<Self::AccountId>;
// 4.
/// Also `Fun` as Function? or `Fun` as Fungible? What about Fungibles? Funs?
type Currency: FunMutate<Self::AccountId>
+ FunMutateHold<Self::AccountId, Reason = Self::RuntimeHoldReason>
+ FunBalanced<Self::AccountId>;
// 5.
type Currency: InspectFungible<Self::AccountId>
+ MutateFungible<Self::AccountId>
+ HoldMutateFungible<Self::AccountId, Reason = Self::RuntimeHoldReason>;
If we reach a consensus, I have no problem completing the refactoring according to the chosen approach (at least for already merged code).
I would vote for //5.
as it appears to be the most readable and avoids potential discrepancies between fungible
and fungibles
in the same context.
// 5.
InspectFungible
MutateFungible
HoldMutateFungible
BalancedFungible
Any thoughts?
Yeah I also really dislike 2,3,4. Thanks for this, good that we standardise.
I also don't really like 5. Instead I would suggest
fungible
or fungibles
in the scope, approach 1. fungible
and fungibles
in the scope, just use fungible::Inspect
, fungibles::Balanced
, etc to differentiate them instead of doing a bunch of as
namings. Imo it's cleaner to differentiate traits using our existing module structure rather than making up a new pattern and writing as
everywhere which imo is tedious to implement.
Let me know what you think.
Yeah I also really dislike 2,3,4. Thanks for this, good that we standardise.
I also don't really like 5. Instead I would suggest
* If we are using only one of `fungible` or `fungibles` in the scope, approach 1. * If we are using both of `fungible` and `fungibles` in the scope, just use `fungible::Inspect`, `fungibles::Balanced`, etc to differentiate them instead of doing a bunch of `as` namings.
Imo it's cleaner to differentiate traits using our existing module structure rather than making up a new pattern and writing
as
everywhere which imo is tedious to implement.Let me know what you think.
cool, I am with you, yes, lets avoid those as
, and simplify that,
I will prepare PR (probably based on https://github.com/paritytech/polkadot-sdk/pull/1801) and lets see
This issue has been mentioned on Polkadot Forum. There might be relevant details there:
https://forum.polkadot.network/t/polkadot-release-analysis-v1-4-0/5152/1
Currency
tofungible
traits:lock
/reserve
and instating afreeze
/hold
.hold
instead oflock
.Currency
traits as deprecated.Eventually, we will also want to deprecate and remove
Balances
dispatchables:fungible
API.Pallet migrations needed
Here's a list of pallets, turning this into a tracking issue of the migration process.
CurrencyAdapter
, as per https://github.com/paritytech/polkadot-sdk/issues/1833 https://github.com/paritytech/polkadot-sdk/pull/2292.type Currency: LockableCurrency
type Currency: ReservableCurrency<Self::AccountId>;
type Currency: LockableCurrency<Self::AccountId, Moment = Self::BlockNumber>
https://github.com/paritytech/polkadot-sdk/pull/2011type Currency: ReservableCurrency<Self::AccountId> + Currency<Self::AccountId>;
type Currency: ReservableCurrency<Self::AccountId>;
https://github.com/paritytech/polkadot-sdk/pull/1810type Currency: Currency<Self::AccountId> + ReservableCurrency<Self::AccountId>;
@juangirinitype Currency: ReservableCurrency<Self::AccountId>;
https://github.com/paritytech/polkadot-sdk/pull/1801type Currency: Currency<Self::AccountId>;
https://github.com/paritytech/polkadot-sdk/pull/1801type Currency: ReservableCurrency<Self::AccountId>;
https://github.com/paritytech/polkadot-sdk/pull/1804type Currency: ReservableCurrency<Self::AccountId>;
https://github.com/paritytech/polkadot-sdk/pull/1866type Currency: FunInspect<Self::AccountId, Balance = Self::CurrencyBalance>
type Currency: LockableCurrency<Self::AccountId>;
https://github.com/paritytech/polkadot-sdk/pull/1760type Currency: ReservableCurrency<Self::AccountId> // TODO: Move to fungible traits
type Currency: ReservableCurrency<Self::AccountId>;
@juangirini https://github.com/paritytech/polkadot-sdk/pull/2822type Currency: ReservableCurrency<Self::AccountId>;
https://github.com/paritytech/polkadot-sdk/pull/1772type Currency: ReservableCurrency<Self::AccountId>;
https://github.com/paritytech/polkadot-sdk/pull/1853type Currency: ReservableCurrency<Self::AccountId>;
https://github.com/paritytech/polkadot-sdk/pull/1782type Currency: Inspect<Self::AccountId, Balance = Self::Balance>;
type Currency: Currency<Self::AccountId>;
type Currency: ReservableCurrency<Self::AccountId>;
https://github.com/paritytech/polkadot-sdk/pull/1675type Currency: Inspect<Self::AccountId>;
type Currency: ReservableCurrency<Self::AccountId>;
@juangirini https://github.com/paritytech/polkadot-sdk/pull/1807type Currency: ReservableCurrency<Self::AccountId>;
https://github.com/paritytech/substrate/pull/13666type Currency: ReservableCurrency<Self::AccountId>
https://github.com/paritytech/polkadot-sdk/pull/1821type Currency: ReservableCurrency<Self::AccountId>;
https://github.com/paritytech/polkadot-sdk/pull/1837type Currency: ReservableCurrency<Self::AccountId>;
https://github.com/paritytech/polkadot-sdk/pull/1789type Currency: ReservableCurrency<Self::AccountId>;
https://github.com/paritytech/polkadot-sdk/pull/1800type Currency: ReservableCurrency<Self::AccountId>;
https://github.com/paritytech/polkadot-sdk/pull/1785Currency: NamedReservableCurrency<AccountId>
(@bkontur working on it)ReservableCurrency
(@bkontur working on it)