UNPKG

@ledgerhq/live-common

Version:
34 lines 1.59 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getTotalStakeableAssets = getTotalStakeableAssets; const getTokensWithFunds_1 = require("./getTokensWithFunds"); 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 = (0, getTokensWithFunds_1.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