substrate
substrate copied to clipboard
[pallet-assets] add asset_exists(id: AssetId) function
Is there an existing issue?
- [X] I have searched the existing issues
Experiencing problems? Have you tried our Stack Exchange first?
- [X] This is not a support question.
Description of bug
While working on an implementation of an Asset Registry for https://github.com/paritytech/trappist/issues/51, we needed to check whether an Asset exists.
We are currently doing the following, which feels a bit like a hack:
fn asset_exists(asset_id: AssetIdOf<T>) -> bool {
!T::Assets::minimum_balance(asset_id).is_zero()
}
Ideally, pallet-assets should provide a function that does this, because it is basic functionality that is missing from the pallet.
Steps to reproduce
No response
@bernardoaraujor who should ideally have the privilege of calling this function/extrinsic?
Can you explain the context in which you are unable to do this?
For example, within FRAME, you can just use Asset::<T, I>::contains_key(id) (example).
Asset is also a pub storage item, so any UI or tool using a library like Polkadot JS API should be able to read this and check if some key exists.
This is coming from a pallet that has a loose-coupling with pallet-assets (via Inspect trait).
Correct me if I'm wrong, but as far as I could tell, I could only read Asset if I used tight coupling.
I see, so you are looking for either a pub fn asset_class_exists(id) -> bool; function within Inspect, or
impl<T: Config<I>, I: 'static> Pallet<T, I> {
pub fn asset_class_exists(id: T::AssetId) -> bool { }
}
within the Assets pallet? Seems like a good issue for @vieira-giulia to figure out. Also posting https://substrate.stackexchange.com/questions/922/pallet-loose-couplingtight-coupling-and-missing-traits for reference.
yes... as long as it's accessible via loose coupling, it should be enough.
I have gone ahead to open a PR for this @joepetrowski @bernardoaraujor since it has not been worked on for over a month
This issue has been mentioned on Polkadot Forum. There might be relevant details there:
https://forum.polkadot.network/t/polkadot-release-analysis-v0-9-36/1529/1