@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
51 lines • 1.8 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getSpecsPerBots = getSpecsPerBots;
const currencies_1 = require("../../currencies");
const specs_1 = __importDefault(require("../../generated/specs"));
function getSpecsPerBots(seeds, filters = {}) {
const filterFamilies = filters.families
?.split(",")
.map(f => f.trim())
.filter(Boolean) || [];
const filterCurrencies = filters.currencies
?.split(",")
.map(f => f.trim())
.filter(Boolean) || [];
// allSpecs allows to know and infer what are the coins to sync
const specs = [];
for (const family in specs_1.default) {
if (filterFamilies.length > 0 && !filterFamilies.includes(family))
continue;
const familySpecs = specs_1.default[family];
for (const key in familySpecs) {
const spec = familySpecs[key];
if (!(0, currencies_1.isCurrencySupported)(spec.currency) || spec.disabled) {
continue;
}
if (filterCurrencies.length > 0 && !filterCurrencies.includes(spec.currency.id)) {
continue;
}
specs.push({ spec, family, key });
}
}
// prepare the jobs
const specsPerBots = Object.keys(seeds).flatMap(seed => {
return specs.map(({ spec, family, key }) => {
return {
seed,
env: {
SEED: seeds[seed],
},
spec,
family,
key,
};
});
});
return specsPerBots;
}
//# sourceMappingURL=logic.js.map