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:
girazoki
2022-02-05 12:06:44 +01:00
committed by GitHub
parent d5c8593566
commit 074ff19dbc
+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(