"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.filterCurrencies = exports.listCurrencies = exports.isUTXOCompliant = exports.isTokenCurrency = exports.isCryptoCurrency = void 0;
const minimatch_1 = require("minimatch");
const cryptoassets_1 = require("@ledgerhq/cryptoassets");
const index_1 = require("@ledgerhq/coin-framework/currencies/index");
function isCryptoCurrency(currency) {
    return currency.type === "CryptoCurrency";
}
exports.isCryptoCurrency = isCryptoCurrency;
function isTokenCurrency(currency) {
    return currency.type === "TokenCurrency";
}
exports.isTokenCurrency = isTokenCurrency;
function isUTXOCompliant(currencyFamily) {
    return currencyFamily === "bitcoin" || currencyFamily === "cardano";
}
exports.isUTXOCompliant = isUTXOCompliant;
function listCurrencies(includeTokens) {
    const currencies = (0, index_1.listSupportedCurrencies)();
    if (!includeTokens) {
        return currencies;
    }
    const allTokens = (0, cryptoassets_1.listTokens)();
    return [...currencies, ...allTokens];
}
exports.listCurrencies = listCurrencies;
function filterCurrencies(currencies, filters) {
    const filterCurrencyRegexes = filters.currencies
        ? filters.currencies.map(filter => (0, minimatch_1.makeRe)(filter))
        : null;
    return currencies.filter(currency => {
        if (filterCurrencyRegexes &&
            filterCurrencyRegexes.length &&
            !filterCurrencyRegexes.some(regex => currency.id.match(regex))) {
            return false;
        }
        return true;
    });
}
exports.filterCurrencies = filterCurrencies;
//# sourceMappingURL=helpers.js.map