UNPKG

@ledgerhq/live-common

Version:
25 lines 942 B
import isEmpty from "lodash/isEmpty"; import uniq from "lodash/uniq"; /** Flatten all providers' currencies into a single array */ export function getCryptoCurrencyIds(entries) { if (!entries || isEmpty(entries)) { return null; } return uniq(Object.values(entries).flat()); } export function isCurrencyInCatalog(currencyId, catalog, status) { if (!catalog || isEmpty(catalog[status])) { return false; } const currencies = getCryptoCurrencyIds(catalog[status]); return !currencies ? false : currencies.includes(currencyId); } /** Get the array of providers in the catalog that support the given currency */ export function getRampServiceProviders(currencyId, catalog) { if (!catalog || isEmpty(catalog)) { return null; } const providers = Object.keys(catalog).filter(provider => catalog[provider].includes(currencyId)); return providers; } //# sourceMappingURL=helpers.js.map