@defillama/sdk 5.0.124 → 5.0.126
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/util/indexer.js
CHANGED
|
@@ -13,6 +13,7 @@ const cache_1 = require("./cache");
|
|
|
13
13
|
const debugLog_1 = require("./debugLog");
|
|
14
14
|
const env_1 = require("./env");
|
|
15
15
|
const logs_1 = require("./logs");
|
|
16
|
+
const _1 = require(".");
|
|
16
17
|
const indexerURL = (0, env_1.getEnvValue)('LLAMA_INDEXER_ENDPOINT');
|
|
17
18
|
const LLAMA_INDEXER_API_KEY = (0, env_1.getEnvValue)('LLAMA_INDEXER_API_KEY');
|
|
18
19
|
const axiosIndexer = axios_1.default.create({
|
|
@@ -131,7 +132,7 @@ async function getTokens(address, { onlyWhitelisted = true, skipCacheRead = fals
|
|
|
131
132
|
}
|
|
132
133
|
exports.getTokens = getTokens;
|
|
133
134
|
async function getLogs({ chain = 'ethereum', topic, topics, fromBlock, toBlock, all = true, limit = 1000, offset = 0, target, targets, eventAbi, entireLog = false, flatten = true, extraTopics, fromTimestamp, toTimestamp, debugMode = false }) {
|
|
134
|
-
var _a, _b;
|
|
135
|
+
var _a, _b, _c;
|
|
135
136
|
checkIndexerConfig();
|
|
136
137
|
const chainId = chainToIDMapping[chain];
|
|
137
138
|
if (!chainId)
|
|
@@ -160,6 +161,7 @@ async function getLogs({ chain = 'ethereum', topic, topics, fromBlock, toBlock,
|
|
|
160
161
|
targets = [target];
|
|
161
162
|
if (Array.isArray(targets))
|
|
162
163
|
address = targets.join(',');
|
|
164
|
+
const hasAddressFilter = address && address.length;
|
|
163
165
|
if (address)
|
|
164
166
|
address = address.toLowerCase();
|
|
165
167
|
const chainIndexStatus = await getChainIndexStatus();
|
|
@@ -182,27 +184,32 @@ async function getLogs({ chain = 'ethereum', topic, topics, fromBlock, toBlock,
|
|
|
182
184
|
console.time(debugTimeKey);
|
|
183
185
|
}
|
|
184
186
|
const addressSet = new Set(address === null || address === void 0 ? void 0 : address.split(','));
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
187
|
+
const addressChunks = (0, _1.sliceIntoChunks)((_c = address === null || address === void 0 ? void 0 : address.split(',')) !== null && _c !== void 0 ? _c : [], 10);
|
|
188
|
+
for (const chunk of addressChunks) {
|
|
189
|
+
let _logAgg = [];
|
|
190
|
+
do {
|
|
191
|
+
const params = {
|
|
192
|
+
addresses: hasAddressFilter ? chunk.join(',') : undefined,
|
|
193
|
+
chainId,
|
|
194
|
+
topic0: topic,
|
|
195
|
+
from_block: fromBlock,
|
|
196
|
+
to_block: toBlock,
|
|
197
|
+
limit,
|
|
198
|
+
offset,
|
|
199
|
+
};
|
|
200
|
+
const { data: { logs: _logs, totalCount } } = await axiosIndexer(`/logs`, { params, });
|
|
201
|
+
_logAgg.push(..._logs.filter((l) => {
|
|
202
|
+
if (!addressSet.size)
|
|
203
|
+
return true;
|
|
204
|
+
return addressSet.has(l === null || l === void 0 ? void 0 : l.source.toLowerCase());
|
|
205
|
+
}));
|
|
206
|
+
offset += limit;
|
|
207
|
+
// If we have all the logs, or we have reached the limit, or there are no logs, we stop
|
|
208
|
+
if (_logs.length < limit || totalCount <= _logAgg.length || _logs.length === 0)
|
|
209
|
+
hasMore = false;
|
|
210
|
+
} while (all && hasMore);
|
|
211
|
+
logs.push(..._logAgg);
|
|
212
|
+
}
|
|
206
213
|
if (debugMode) {
|
|
207
214
|
console.timeEnd(debugTimeKey);
|
|
208
215
|
(0, debugLog_1.debugLog)('Logs pulled ' + chain, address, logs.length);
|
|
@@ -77,6 +77,9 @@ async function main() {
|
|
|
77
77
|
continue;
|
|
78
78
|
providerList[key] = providerList[shorName];
|
|
79
79
|
}
|
|
80
|
+
if (providerList.hyperliquid) {
|
|
81
|
+
providerList.hyperliquid.rpc.push('https://hyperliquid.cloud.blockscout.com/api/eth-rpc');
|
|
82
|
+
}
|
|
80
83
|
const droppedChains = Object.keys(oldProviders).filter(oldChain => providerList[oldChain] === undefined);
|
|
81
84
|
if (droppedChains.length > 20) {
|
|
82
85
|
throw new Error(`Following chains used to be included but is not anymore, can the devs fix please?\n${droppedChains.join('\n')}`);
|