Skip to content

Commit 25ad9f2

Browse files
authored
🐛 fix icon coverage tracker against new dada API shape (#117)
dada is deprecating currenciesOrder.currenciesIds (returned empty, removal in a later release). Reconstruct the ranked ledger ID list from currenciesOrder.metaCurrencyIds and each meta-currency's assetsIds map. Verified locally: 400 / 410 covered, 10 missing.
1 parent c91163e commit 25ad9f2

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

.github/scripts/check-icon-coverage.mjs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,30 @@ async function main() {
1111
const assets = await assetsRes.json();
1212
const index = await indexRes.json();
1313

14-
const rankedIds = assets.currenciesOrder?.currenciesIds ?? [];
15-
const mappedIds = new Set(Object.keys(index));
16-
17-
const missing = rankedIds.filter((id) => !mappedIds.has(id));
18-
const covered = rankedIds.length - missing.length;
14+
const cryptoAssets = assets.cryptoAssets ?? {};
15+
const metaCurrencyIds = assets.currenciesOrder?.metaCurrencyIds ?? [];
1916

20-
// Build a ledgerId → { name, ticker } lookup from the assets response
17+
// Build a ledgerId → { name, ticker } lookup, and expand the ranked
18+
// meta-currency list into its underlying ledger IDs (preserving rank order).
2119
const idToInfo = {};
22-
for (const asset of Object.values(assets.cryptoAssets ?? {})) {
20+
const rankedIds = [];
21+
const seen = new Set();
22+
for (const metaId of metaCurrencyIds) {
23+
const asset = cryptoAssets[metaId];
24+
if (!asset) continue;
2325
for (const ledgerId of Object.values(asset.assetsIds ?? {})) {
2426
idToInfo[ledgerId] = { name: asset.name ?? 'N/A', ticker: asset.ticker ?? 'N/A' };
27+
if (!seen.has(ledgerId)) {
28+
seen.add(ledgerId);
29+
rankedIds.push(ledgerId);
30+
}
2531
}
2632
}
2733

34+
const mappedIds = new Set(Object.keys(index));
35+
const missing = rankedIds.filter((id) => !mappedIds.has(id));
36+
const covered = rankedIds.length - missing.length;
37+
2838
const date = new Date().toISOString().split('T')[0];
2939
const rows = missing.map((id) => {
3040
const { name, ticker } = idToInfo[id] ?? { name: 'N/A', ticker: 'N/A' };

0 commit comments

Comments
 (0)