Skip to content

Commit 7190f7e

Browse files
dharjeezyjoepetrowski
authored andcommitted
[pallet-assets] add asset_exists(id: AssetId) function (paritytech#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 <>
1 parent 0a1355d commit 7190f7e

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

frame/assets/src/impl_fungibles.rs

+4
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ impl<T: Config<I>, I: 'static> fungibles::Inspect<<T as SystemConfig>::AccountId
5959
) -> WithdrawConsequence<Self::Balance> {
6060
Pallet::<T, I>::can_decrease(asset, who, amount, false)
6161
}
62+
63+
fn asset_exists(asset: Self::AssetId) -> bool {
64+
Asset::<T, I>::contains_key(asset)
65+
}
6266
}
6367

6468
impl<T: Config<I>, I: 'static> fungibles::InspectMetadata<<T as SystemConfig>::AccountId>

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

+3
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ pub trait Inspect<AccountId> {
8383
who: &AccountId,
8484
amount: Self::Balance,
8585
) -> WithdrawConsequence<Self::Balance>;
86+
87+
/// Returns `true` if an `asset` exists.
88+
fn asset_exists(asset: Self::AssetId) -> bool;
8689
}
8790

8891
/// Trait for reading metadata from a fungible asset.

0 commit comments

Comments
 (0)