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

* check if an asset exists via loose coupling

* Update frame/support/src/traits/tokens/fungibles.rs

Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>

Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
Co-authored-by: parity-processbot <>
This commit is contained in:
dharjeezy
2022-12-08 15:09:17 +01:00
committed by GitHub
parent 9a014d1ecd
commit 200f49d66d
2 changed files with 7 additions and 0 deletions
@@ -59,6 +59,10 @@ impl<T: Config<I>, I: 'static> fungibles::Inspect<<T as SystemConfig>::AccountId
) -> WithdrawConsequence<Self::Balance> {
Pallet::<T, I>::can_decrease(asset, who, amount, false)
}
fn asset_exists(asset: Self::AssetId) -> bool {
Asset::<T, I>::contains_key(asset)
}
}
impl<T: Config<I>, I: 'static> fungibles::InspectMetadata<<T as SystemConfig>::AccountId>
@@ -83,6 +83,9 @@ pub trait Inspect<AccountId> {
who: &AccountId,
amount: Self::Balance,
) -> WithdrawConsequence<Self::Balance>;
/// Returns `true` if an `asset` exists.
fn asset_exists(asset: Self::AssetId) -> bool;
}
/// Trait for reading metadata from a fungible asset.