import { Currency } from "@keplr-wallet/types" ; import { CoinPrimitive } from "../types" ; import { CoinPretty , Dec , Int } from "@keplr-wallet/unit" ; export class StoreUtils { public static getBalancesFromCurrencies ( currenciesMap , bals ) { const result = [ ] ; for ( const bal of bals ) { const currency = currenciesMap [ bal . denom ] ; if ( currency ) { const amount = new Dec ( bal . amount ) ; if ( amount . truncate ( ) . gt ( new Int ( 0 ) ) ) { result . push ( new CoinPretty ( currency , amount ) ) ; } } } return result ; } public static getBalanceFromCurrency ( currency , bals ) { const result = StoreUtils . getBalancesFromCurrencies ( { [ currency . coinMinimalDenom ] : currency , } , bals ) ; if ( result . length === 1 ) { return result [ 0 ] ; } return new CoinPretty ( currency , new Int ( 0 ) ) . ready ( false ) ; } }