UNPKG

@ledgerhq/live-common

Version:
31 lines 1.44 kB
import { getTokensWithFundsMap } from "./getTokensWithFunds"; export function getTotalStakeableAssets(accounts, stakingCurrenciesEnabled, partnerStakingCurrenciesEnabled) { if (!accounts) return { combinedIds: new Set(), stakeableAssets: [] }; const accountsWithFundsCurrencies = accounts .filter(account => account?.balance.isGreaterThan(0)) .map(account => account?.currency); const allStakingCurrenciesEnabled = new Set([ ...stakingCurrenciesEnabled, ...partnerStakingCurrenciesEnabled, ]); const tokenWithFundsMap = getTokensWithFundsMap(accounts); const filteredAccountCurrencyIds = [...accountsWithFundsCurrencies].filter(currency => allStakingCurrenciesEnabled.has(currency.id)); const filteredTokenWithFunds = [...tokenWithFundsMap.values()].filter(token => allStakingCurrenciesEnabled.has(token.id)); const combined = new Map(); for (const currency of filteredAccountCurrencyIds) { combined.set(currency.id, { ticker: currency.ticker, networkName: currency.name, id: currency.id, }); } for (const token of filteredTokenWithFunds) { combined.set(token.id, token); } return { combinedIds: new Set(Array.from(combined.values(), details => details.id)), stakeableAssets: Array.from(combined.values()), }; } //# sourceMappingURL=getTotalStakeableAssets.js.map