@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
34 lines • 1.21 kB
JavaScript
import { makeRe } from "minimatch";
import { listTokens } from "@ledgerhq/cryptoassets";
import { listSupportedCurrencies } from "@ledgerhq/coin-framework/currencies/index";
export function isCryptoCurrency(currency) {
return currency.type === "CryptoCurrency";
}
export function isTokenCurrency(currency) {
return currency.type === "TokenCurrency";
}
export function isUTXOCompliant(currencyFamily) {
return currencyFamily === "bitcoin" || currencyFamily === "cardano";
}
export function listCurrencies(includeTokens) {
const currencies = listSupportedCurrencies();
if (!includeTokens) {
return currencies;
}
const allTokens = listTokens();
return [...currencies, ...allTokens];
}
export function filterCurrencies(currencies, filters) {
const filterCurrencyRegexes = filters.currencies
? filters.currencies.map(filter => makeRe(filter))
: null;
return currencies.filter(currency => {
if (filterCurrencyRegexes &&
filterCurrencyRegexes.length &&
!filterCurrencyRegexes.some(regex => currency.id.match(regex))) {
return false;
}
return true;
});
}
//# sourceMappingURL=helpers.js.map