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

[pallet-assets] add asset_exists(id: AssetId) function #12444

Closed
2 tasks done
bernardoaraujor opened this issue Oct 7, 2022 · 7 comments · Fixed by #12782
Closed
2 tasks done

[pallet-assets] add asset_exists(id: AssetId) function #12444

bernardoaraujor opened this issue Oct 7, 2022 · 7 comments · Fixed by #12782
Assignees
Labels
J0-enhancement An additional feature request.

Comments

@bernardoaraujor
Copy link
Contributor

Is there an existing issue?

  • I have searched the existing issues

Experiencing problems? Have you tried our Stack Exchange first?

  • This is not a support question.

Description of bug

While working on an implementation of an Asset Registry for paritytech/trappist#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 bernardoaraujor added the J0-enhancement An additional feature request. label Oct 7, 2022
@Doordashcon
Copy link
Contributor

@bernardoaraujor who should ideally have the privilege of calling this function/extrinsic?

@joepetrowski
Copy link
Contributor

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.

@bernardoaraujor
Copy link
Contributor Author

bernardoaraujor commented Oct 10, 2022

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.

@joepetrowski
Copy link
Contributor

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.

@bernardoaraujor
Copy link
Contributor Author

yes... as long as it's accessible via loose coupling, it should be enough.

@dharjeezy
Copy link
Contributor

I have gone ahead to open a PR for this @joepetrowski @bernardoaraujor since it has not been worked on for over a month

@Polkadot-Forum
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
J0-enhancement An additional feature request.
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

7 participants