maybe_total_supply in pallet-assets (#10799)

* maybe_total_supply in pallet-assets

* Update frame/assets/src/functions.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
girazokiandBastian Köcher authored and GitHub committed 2022-02-05 11:06:44 +00:00
1 parent d5c8593566
commit 074ff19dbc
1 file changed
+6 -1
+6 -1
View File
@@ -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(