@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
45 lines • 1.5 kB
JavaScript
import { isCurrencySupported } from "../../currencies";
import allSpecs from "../../generated/specs";
export 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 allSpecs) {
if (filterFamilies.length > 0 && !filterFamilies.includes(family))
continue;
const familySpecs = allSpecs[family];
for (const key in familySpecs) {
const spec = familySpecs[key];
if (!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