UNPKG

@ledgerhq/live-common

Version:
33 lines 1.41 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getCryptoCurrencyIds = getCryptoCurrencyIds; exports.isCurrencyInCatalog = isCurrencyInCatalog; exports.getRampServiceProviders = getRampServiceProviders; const isEmpty_1 = __importDefault(require("lodash/isEmpty")); const uniq_1 = __importDefault(require("lodash/uniq")); /** Flatten all providers' currencies into a single array */ function getCryptoCurrencyIds(entries) { if (!entries || (0, isEmpty_1.default)(entries)) { return null; } return (0, uniq_1.default)(Object.values(entries).flat()); } function isCurrencyInCatalog(currencyId, catalog, status) { if (!catalog || (0, isEmpty_1.default)(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 */ function getRampServiceProviders(currencyId, catalog) { if (!catalog || (0, isEmpty_1.default)(catalog)) { return null; } const providers = Object.keys(catalog).filter(provider => catalog[provider].includes(currencyId)); return providers; } //# sourceMappingURL=helpers.js.map