@defillama/sdk 5.0.136 → 5.0.137
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/abi/multicall3.js +1 -0
- package/build/providers.json +1 -1
- package/build/util/LlamaProvider.js +10 -2
- package/build/util/env.js +1 -0
- package/build/util/indexer.js +10 -10
- package/package.json +1 -1
|
@@ -110,6 +110,12 @@ class LlamaProvider extends ethers_1.FallbackProvider {
|
|
|
110
110
|
runners.splice(1, 0, primaryRunner);
|
|
111
111
|
}
|
|
112
112
|
runners = runners.slice(0, attempts);
|
|
113
|
+
// print stats every 5 minutes
|
|
114
|
+
let currentTimeMS = Date.now();
|
|
115
|
+
if (currentTimeMS - lastPrintTimeMS > 1000 * 60 * 5) {
|
|
116
|
+
lastPrintTimeMS = currentTimeMS;
|
|
117
|
+
printRPCCallStats();
|
|
118
|
+
}
|
|
113
119
|
// if (this.chainName === 'rsk' && method === 'getLogs') {
|
|
114
120
|
// const hostString = getEnvValue('RSK_ARCHIVAL_RPC')
|
|
115
121
|
// if (!hostString)
|
|
@@ -309,9 +315,11 @@ function getMedianBlockValue(blocks) {
|
|
|
309
315
|
const mid = Math.floor(blocks.length / 3);
|
|
310
316
|
return blocks.length % 2 !== 0 ? blocks[mid] : (blocks[mid - 1] + blocks[mid]) / 2;
|
|
311
317
|
}
|
|
312
|
-
|
|
318
|
+
let lastPrintTimeMS = Date.now();
|
|
319
|
+
function printRPCCallStats() {
|
|
313
320
|
if (Object.keys(rpcRequestCounter).length > 7) {
|
|
314
321
|
(0, debugLog_1.debugLog)('RPC request count per chain');
|
|
315
322
|
(0, debugLog_1.debugTable)(rpcRequestCounter);
|
|
316
323
|
}
|
|
317
|
-
}
|
|
324
|
+
}
|
|
325
|
+
process.on('exit', printRPCCallStats);
|
package/build/util/env.js
CHANGED
|
@@ -12,6 +12,7 @@ const whitelistedEnvConstants = [
|
|
|
12
12
|
const defaultEnvValues = {
|
|
13
13
|
INTERNAL_SDK_CACHE_FILE: './cache.json',
|
|
14
14
|
TRON_RPC_CONCURRENCY_LIMIT: '5',
|
|
15
|
+
LLAMA_INDEXER_ADDRESS_CHUNK_SIZE: '20',
|
|
15
16
|
TRON_RPC: 'https://api.trongrid.io',
|
|
16
17
|
TRON_EVM_RPC: 'https://rpc.ankr.com/tron_jsonrpc',
|
|
17
18
|
NAKA_RPC: 'https://node.nakachain.xyz',
|
package/build/util/indexer.js
CHANGED
|
@@ -16,6 +16,7 @@ const logs_1 = require("./logs");
|
|
|
16
16
|
const _1 = require(".");
|
|
17
17
|
const indexerURL = (0, env_1.getEnvValue)('LLAMA_INDEXER_ENDPOINT');
|
|
18
18
|
const LLAMA_INDEXER_API_KEY = (0, env_1.getEnvValue)('LLAMA_INDEXER_API_KEY');
|
|
19
|
+
const addressChunkSize = +(0, env_1.getEnvValue)('LLAMA_INDEXER_ADDRESS_CHUNK_SIZE');
|
|
19
20
|
const axiosIndexer = axios_1.default.create({
|
|
20
21
|
headers: {
|
|
21
22
|
"x-api-key": LLAMA_INDEXER_API_KEY,
|
|
@@ -186,12 +187,12 @@ async function getLogs({ chain = 'ethereum', topic, topics, fromBlock, toBlock,
|
|
|
186
187
|
console.time(debugTimeKey);
|
|
187
188
|
}
|
|
188
189
|
const addressSet = new Set(address === null || address === void 0 ? void 0 : address.split(','));
|
|
189
|
-
const addressChunks = (0, _1.sliceIntoChunks)((_c = address === null || address === void 0 ? void 0 : address.split(',')) !== null && _c !== void 0 ? _c : [],
|
|
190
|
+
const addressChunks = (0, _1.sliceIntoChunks)((_c = address === null || address === void 0 ? void 0 : address.split(',')) !== null && _c !== void 0 ? _c : [], addressChunkSize);
|
|
190
191
|
// to ensure that we have at least one chunk to process if no target is provided
|
|
191
192
|
if (noTarget && addressChunks.length === 0)
|
|
192
193
|
addressChunks.push(undefined);
|
|
193
194
|
for (const chunk of addressChunks) {
|
|
194
|
-
let
|
|
195
|
+
let logCount = 0;
|
|
195
196
|
do {
|
|
196
197
|
const params = {
|
|
197
198
|
addresses: hasAddressFilter ? chunk.join(',') : undefined,
|
|
@@ -206,18 +207,17 @@ async function getLogs({ chain = 'ethereum', topic, topics, fromBlock, toBlock,
|
|
|
206
207
|
// getLogs uses 'address' field to return log source, so we add the field here to make it compatible
|
|
207
208
|
_logs.forEach((l) => {
|
|
208
209
|
l.address = l.source;
|
|
210
|
+
const iswhitelisted = !addressSet.size || addressSet.has(l.source.toLowerCase());
|
|
211
|
+
if (iswhitelisted) {
|
|
212
|
+
logs.push(l);
|
|
213
|
+
}
|
|
209
214
|
});
|
|
210
|
-
|
|
211
|
-
if (!addressSet.size)
|
|
212
|
-
return true;
|
|
213
|
-
return addressSet.has(l === null || l === void 0 ? void 0 : l.source.toLowerCase());
|
|
214
|
-
}));
|
|
215
|
+
logCount += _logs.length;
|
|
215
216
|
offset += limit;
|
|
216
217
|
// If we have all the logs, or we have reached the limit, or there are no logs, we stop
|
|
217
|
-
if (_logs.length < limit || totalCount <=
|
|
218
|
+
if (_logs.length < limit || totalCount <= logCount || _logs.length === 0)
|
|
218
219
|
hasMore = false;
|
|
219
220
|
} while (all && hasMore);
|
|
220
|
-
logs.push(..._logAgg);
|
|
221
221
|
}
|
|
222
222
|
if (debugMode) {
|
|
223
223
|
console.timeEnd(debugTimeKey);
|
|
@@ -239,7 +239,7 @@ async function getLogs({ chain = 'ethereum', topic, topics, fromBlock, toBlock,
|
|
|
239
239
|
log.transactionHash = log.transaction_hash;
|
|
240
240
|
log.blockNumber = log.block_number;
|
|
241
241
|
log.topics = [log.topic0, log.topic1, log.topic2, log.topic3,].filter(t => t !== '').map(i => ethers_1.ethers.zeroPadValue(i, 32));
|
|
242
|
-
const deleteKeys = ['chain', '
|
|
242
|
+
const deleteKeys = ['chain', 'block_number', 'log_index', 'topic0', 'topic1', 'topic2', 'topic3', 'decodedArgs', 'transaction_hash',];
|
|
243
243
|
deleteKeys.forEach(k => delete log[k]);
|
|
244
244
|
const parsedLog = iface === null || iface === void 0 ? void 0 : iface.parseLog({ data: log.data, topics: log.topics, });
|
|
245
245
|
log.args = parsedLog === null || parsedLog === void 0 ? void 0 : parsedLog.args;
|