@defillama/sdk 5.0.147 → 5.0.148

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -236,7 +236,7 @@ async function getLogs(options) {
236
236
  // -------------------------------------------------------------------------
237
237
  // Pull logs
238
238
  // -------------------------------------------------------------------------
239
- const rawLogs = [];
239
+ const allLogs = [];
240
240
  const debugTimeKey = `Indexer-getLogs-${chain}-${topic}-${address}_${Math.random()}`;
241
241
  if (debugMode) {
242
242
  (0, debugLog_1.debugLog)("[Indexer] Pulling logs " + debugTimeKey);
@@ -275,10 +275,11 @@ async function getLogs(options) {
275
275
  }
276
276
  return true;
277
277
  });
278
- const transformed = filtered.map(transformLog);
278
+ // we need to the { raw, transformed } structure to allow for post‑processing like clustering based on `source` field
279
+ const transformed = filtered.map((log) => ({ raw: log, transformed: transformLog(log) }));
279
280
  if (processor)
280
- await processor(transformed);
281
- rawLogs.push(...transformed);
281
+ await processor(transformed.map((i) => i.transformed));
282
+ allLogs.push(...transformed);
282
283
  logCount += _logs.length;
283
284
  chunkOffset += limit;
284
285
  if (_logs.length < limit || totalCount <= logCount || _logs.length === 0)
@@ -287,7 +288,7 @@ async function getLogs(options) {
287
288
  }
288
289
  if (debugMode) {
289
290
  console.timeEnd(debugTimeKey);
290
- (0, debugLog_1.debugLog)("Logs pulled " + chain, address, rawLogs.length);
291
+ (0, debugLog_1.debugLog)("Logs pulled " + chain, address, allLogs.length);
291
292
  }
292
293
  // -------------------------------------------------------------------------
293
294
  // Map / transform result
@@ -297,15 +298,15 @@ async function getLogs(options) {
297
298
  const mapped = targets.map(() => []);
298
299
  const indexMap = {};
299
300
  targets.forEach((t, i) => (indexMap[t.toLowerCase()] = i));
300
- rawLogs.forEach((log) => {
301
- const idx = indexMap[log.source.toLowerCase()];
301
+ allLogs.forEach(({ raw, transformed }) => {
302
+ const idx = indexMap[raw.source.toLowerCase()];
302
303
  if (idx === undefined)
303
304
  return; // ignore unknown sources
304
- mapped[idx].push(log);
305
+ mapped[idx].push(transformed);
305
306
  });
306
307
  return mapped;
307
308
  }
308
- return rawLogs;
309
+ return allLogs.map(i => i.transformed);
309
310
  }
310
311
  exports.getLogs = getLogs;
311
312
  // ---------------------------------------------------------------------------
@@ -412,7 +413,7 @@ async function getTokenTransfers({ chain = "ethereum", fromAddressFilter, fromBl
412
413
  if (splitByAddress) {
413
414
  const mapped = targets.map(() => []);
414
415
  const indexMap = {};
415
- targets.forEach((t, i) => (indexMap[t] = i));
416
+ targets.forEach((t, i) => (indexMap[t.toLowerCase()] = i));
416
417
  filteredTransfers.forEach((log) => {
417
418
  const sourceField = transferType === "in" ? "to_address" : "from_address";
418
419
  const idx = indexMap[log[sourceField].toLowerCase()];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defillama/sdk",
3
- "version": "5.0.147",
3
+ "version": "5.0.148",
4
4
  "description": "SDK for calculating TVL",
5
5
  "main": "build/index.js",
6
6
  "scripts": {