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 #12782

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions frame/assets/src/impl_fungibles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
3 changes: 3 additions & 0 deletions frame/support/src/traits/tokens/fungibles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down