@defillama/sdk 5.0.89 → 5.0.91

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.
@@ -169,9 +169,10 @@ async function getLogs({ chain = 'ethereum', topic, topics, fromBlock, toBlock,
169
169
  (0, debugLog_1.debugLog)('[Indexer] Pulling logs ' + debugTimeKey);
170
170
  console.time(debugTimeKey);
171
171
  }
172
+ const addressSet = new Set(address === null || address === void 0 ? void 0 : address.split(','));
172
173
  do {
173
174
  const params = {
174
- address,
175
+ addresses: address,
175
176
  chain: chainId,
176
177
  topic0: topic,
177
178
  from_block: fromBlock,
@@ -180,7 +181,11 @@ async function getLogs({ chain = 'ethereum', topic, topics, fromBlock, toBlock,
180
181
  offset,
181
182
  };
182
183
  const { data: { logs: _logs, totalCount } } = await axios_1.default.get(`${indexerURL}/logs`, { params });
183
- logs.push(..._logs);
184
+ logs.push(..._logs.filter((l) => {
185
+ if (!addressSet.size)
186
+ return true;
187
+ return addressSet.has(l === null || l === void 0 ? void 0 : l.source.toLowerCase());
188
+ }));
184
189
  offset += limit;
185
190
  // If we have all the logs, or we have reached the limit, or there are no logs, we stop
186
191
  if (_logs.length < limit || totalCount <= logs.length || _logs.length === 0)
@@ -200,6 +205,7 @@ async function getLogs({ chain = 'ethereum', topic, topics, fromBlock, toBlock,
200
205
  }
201
206
  }
202
207
  logs = logs.map((log) => {
208
+ const source = log.source.toLowerCase();
203
209
  log.logIndex = log.log_index;
204
210
  log.index = log.log_index;
205
211
  log.transactionHash = log.transaction_hash;
@@ -214,7 +220,7 @@ async function getLogs({ chain = 'ethereum', topic, topics, fromBlock, toBlock,
214
220
  log.args = parsedLog === null || parsedLog === void 0 ? void 0 : parsedLog.args;
215
221
  log = !entireLog ? log.args : log;
216
222
  if (splitByAddress) {
217
- const index = addressIndexMap[log.source.toLowerCase()];
223
+ const index = addressIndexMap[source];
218
224
  mappedLogs[index].push(log);
219
225
  }
220
226
  return log;
@@ -44,7 +44,7 @@ async function getLogs(options) {
44
44
  if (targets === null || targets === void 0 ? void 0 : targets.length) {
45
45
  const newOptions = { ...options, fromBlock, toBlock };
46
46
  delete newOptions.targets;
47
- const res = await Promise.all(targets.map(i => getLogs({ ...newOptions, target: i })));
47
+ const res = await Promise.all(targets.map(i => getLogs({ ...newOptions, target: i, skipIndexer: true })));
48
48
  if (flatten)
49
49
  return res.flat();
50
50
  return res;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defillama/sdk",
3
- "version": "5.0.89",
3
+ "version": "5.0.91",
4
4
  "description": "SDK for calculating TVL",
5
5
  "main": "build/index.js",
6
6
  "scripts": {