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 <[email protected]>

Co-authored-by: joe petrowski <[email protected]>
Co-authored-by: parity-processbot <>
  • Loading branch information
dharjeezy and joepetrowski authored Dec 8, 2022
1 parent ea3ca3f commit fae9e36
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 fae9e36

Please sign in to comment.