Skip to content

Commit

Permalink
maybe_total_supply in pallet-assets (paritytech#10799)
Browse files Browse the repository at this point in the history
* maybe_total_supply in pallet-assets

* Update frame/assets/src/functions.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
  • Loading branch information
2 people authored and grishasobol committed Mar 28, 2022
1 parent d06a6a7 commit f075ce1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion frame/assets/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {

/// Get the total supply of an asset `id`.
pub fn total_supply(id: T::AssetId) -> T::Balance {
Asset::<T, I>::get(id).map(|x| x.supply).unwrap_or_else(Zero::zero)
Self::maybe_total_supply(id).unwrap_or_default()
}

/// Get the total supply of an asset `id` if the asset exists.
pub fn maybe_total_supply(id: T::AssetId) -> Option<T::Balance> {
Asset::<T, I>::get(id).map(|x| x.supply)
}

pub(super) fn new_account(
Expand Down

0 comments on commit f075ce1

Please sign in to comment.