Skip to content

Commit

Permalink
[pallet-assets] add asset_exists(id: AssetId) function (paritytech#12782
Browse files Browse the repository at this point in the history
)

* 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 <>
  • Loading branch information
2 people authored and ark0f committed Feb 27, 2023
1 parent 0a1355d commit 7190f7e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
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

0 comments on commit 7190f7e

Please sign in to comment.