@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.
- package/build/providers.json +1 -1
- package/build/util/indexer.js +11 -10
- package/package.json +1 -1
package/build/util/indexer.js
CHANGED
|
@@ -236,7 +236,7 @@ async function getLogs(options) {
|
|
|
236
236
|
// -------------------------------------------------------------------------
|
|
237
237
|
// Pull logs
|
|
238
238
|
// -------------------------------------------------------------------------
|
|
239
|
-
const
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
301
|
-
const idx = indexMap[
|
|
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(
|
|
305
|
+
mapped[idx].push(transformed);
|
|
305
306
|
});
|
|
306
307
|
return mapped;
|
|
307
308
|
}
|
|
308
|
-
return
|
|
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()];
|