-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Currencies: ED consistent between tokens and assets #1596
Changes from 2 commits
7dd7071
96fc2a6
b6daff0
bcf82c4
3aa473b
8d086b8
f19d085
d4510e6
d0d9388
fe8b41d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,12 @@ pub mod migrations; | |
pub mod oracle; | ||
pub mod xcm; | ||
|
||
use cfg_primitives::Balance; | ||
use cfg_types::tokens::CurrencyId; | ||
use orml_traits::GetByKey; | ||
use sp_runtime::traits::Get; | ||
use sp_std::marker::PhantomData; | ||
|
||
#[macro_export] | ||
macro_rules! production_or_benchmark { | ||
($production:expr, $benchmark:expr) => {{ | ||
|
@@ -37,6 +43,22 @@ macro_rules! production_or_benchmark { | |
}}; | ||
} | ||
|
||
pub struct CurrencyEDs<T>(PhantomData<T>); | ||
impl<T> GetByKey<CurrencyId, Balance> for CurrencyEDs<T> | ||
where | ||
T: pallet_balances::Config<Balance = Balance> | ||
+ orml_asset_registry::Config<AssetId = CurrencyId, Balance = Balance>, | ||
{ | ||
fn get(currency_id: &CurrencyId) -> Balance { | ||
match currency_id { | ||
CurrencyId::Native => T::ExistentialDeposit::get(), | ||
currency_id => orml_asset_registry::Pallet::<T>::metadata(currency_id) | ||
.map(|metadata| metadata.existential_deposit) | ||
.unwrap_or_default(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Default will be 0. given that we have some currencies that have internal usage as, should we maybe consider having some other default here instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Such internal currencies will have a representation in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, I think we do not register internal currencies. E.g.: staking. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, looking into it, they already have them I'm still not sure what value they should have or how to set this from Also, I still do not understand why polkadot 0.9.43 forces us to have some ED even for internal currencies as the stacking one. cc @wischli There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lemunozm yeah we need a special arm case for the Stacking Currencies. Those are internal so we should be safe hardcoding here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok. If all of you agree, I propose to merge this PR as it it, because ED is 0 at this point in our |
||
} | ||
} | ||
} | ||
|
||
pub mod xcm_fees { | ||
use cfg_primitives::{constants::currency_decimals, types::Balance}; | ||
use frame_support::weights::constants::{ExtrinsicBaseWeight, WEIGHT_REF_TIME_PER_SECOND}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit but this is not getting existential depositS (plural)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure not? The own associated name in
orml_tokens
containsS
too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A currency has one associated existential deposit, not multiple. In
orml_tokens
it is plural because it's calledExistentialDeposits
(i.e, the struct that handles all the existential deposits so it's less incorrect). This struct we are adding here is "Currency Existential Deposits" which, again, is semantically incorrect. In any case, even iforml_tokens
named itCurrencyEDs
, we shouldn't propagate bad naming.This is a nit and not a blocker at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if you see it as:
CurrencyED
CurrencyEDs
It reminds me to Haskell partial applications 😄:
Thing -> CurrencyID -> Balance
-> Receives 2 parameters and returns a valueThing -> (CurrencyID -> Balance)
-> Receives 1 parameter and returns a function that receives 1 parameter and returns a value.And actually both things are the same, because the parenthesis is optional. So I would say that it depends of the PoV of such parenthesis 🤣. But yeah, I can update it. I have no strong opinion from my side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!