diff --git a/package.json b/package.json index f14220a..bf1f732 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "g1flux", "private": true, - "version": "1.4.0", + "version": "1.4.1", "type": "module", "scripts": { "dev": "vite", diff --git a/src/services/DataService.ts b/src/services/DataService.ts index 3968270..9d199d0 100644 --- a/src/services/DataService.ts +++ b/src/services/DataService.ts @@ -12,7 +12,7 @@ * Pour activer : définir VITE_USE_LIVE_API=true dans .env.local */ -import { fetchTransfers, buildIdentityKeyMap, fetchCurrentUD } from './adapters/SubsquidAdapter'; +import { fetchTransfers, buildIdentityKeyMap, fetchCurrentUD, ss58ToDuniterKey } from './adapters/SubsquidAdapter'; import { resolveGeoByKeys, cleanCityName } from './adapters/CesiumAdapter'; import { getTransactionsForPeriod, @@ -69,9 +69,14 @@ async function fetchLiveTransactions(periodDays: number): Promise<{ } // Clés Duniter uniques des émetteurs ET destinataires (un seul appel Cesium+) + // Pour les membres WoT : via keyMap (genesis key = _id Cesium+) + // Pour les non-membres : conversion directe SS58 → Duniter key + const resolveKey = (ss58: string): string => + keyMap.get(ss58) ?? ss58ToDuniterKey(ss58); + const allDuniterKeys = [...new Set([ - ...rawTransfers.map((t) => keyMap.get(t.fromId)), - ...rawTransfers.map((t) => keyMap.get(t.toId)), + ...rawTransfers.map((t) => t.fromId ? resolveKey(t.fromId) : undefined), + ...rawTransfers.map((t) => t.toId ? resolveKey(t.toId) : undefined), ].filter(Boolean) as string[])]; // Résolution géo par clé Duniter (_id Cesium+) @@ -89,7 +94,7 @@ async function fetchLiveTransactions(periodDays: number): Promise<{ const arcs: TransactionArc[] = []; for (const t of rawTransfers) { - const fromDuniterKey = keyMap.get(t.fromId); + const fromDuniterKey = t.fromId ? resolveKey(t.fromId) : undefined; if (!fromDuniterKey) continue; const fromGeo = geoMap.get(fromDuniterKey); if (!fromGeo) continue; @@ -110,7 +115,7 @@ async function fetchLiveTransactions(periodDays: number): Promise<{ }); // Arc : les deux extrémités géolocalisées + villes différentes - const toDuniterKey = keyMap.get(t.toId); + const toDuniterKey = t.toId ? resolveKey(t.toId) : undefined; if (!toDuniterKey) continue; const toGeo = geoMap.get(toDuniterKey); if (!toGeo) continue;