@defillama/sdk 5.0.187 → 5.0.192

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.
@@ -205,7 +205,9 @@ function getTempLocalCache({ file, defaultData = {}, clearAfter = exports.ONE_WE
205
205
  // this removes data only from the file cache, not from the R2 cache
206
206
  async function deleteCache(file) {
207
207
  const filePath = getFilePath(file);
208
- await fs.unlink(filePath);
208
+ await fs.unlink(filePath).catch(() => {
209
+ // ignore errors
210
+ });
209
211
  }
210
212
  async function readExpiringJsonCache(file) {
211
213
  const options = { readFromR2Cache: false, skipR2Cache: true, skipCompression: true };
@@ -214,7 +216,7 @@ async function readExpiringJsonCache(file) {
214
216
  if (!data || Object.keys(data).length === 0)
215
217
  return null;
216
218
  if (data.expiryTimestamp < (Date.now() / 1e3)) {
217
- await deleteCache(file);
219
+ await deleteCache(`${file}-uncompressed`);
218
220
  return null;
219
221
  }
220
222
  return data.data;
@@ -120,7 +120,7 @@ function sumSingleBalance(balances, token, balance, chain) {
120
120
  if (typeof balance.toString === 'function')
121
121
  balance = balance.toString();
122
122
  else
123
- throw new Error('Invalid balance value:' + balance);
123
+ throw new Error('Invalid balance value:' + balance + ' ' + token);
124
124
  }
125
125
  if (typeof balance === 'number' || (balances[token] && typeof balances[token] === 'number')) {
126
126
  const prevBalance = +(balances.hasOwnProperty(token) ? balances[token] : 0);
@@ -140,7 +140,7 @@ function sumSingleBalance(balances, token, balance, chain) {
140
140
  if (typeof value === 'bigint')
141
141
  return;
142
142
  if ([null, undefined].includes(value) || isNaN(+value))
143
- throw new Error(`Invalid balance: ${balance}`);
143
+ throw new Error(`Invalid balance: ${balance} - ${token}`);
144
144
  }
145
145
  }
146
146
  function mergeBalances(balances, balancesToMerge) {
package/build/util/env.js CHANGED
@@ -19,13 +19,14 @@ exports.shouldSkipBlockValidation = shouldSkipBlockValidation;
19
19
  exports.getBoolEnvValue = getBoolEnvValue;
20
20
  const whitelistedEnvConstants = [
21
21
  'R2_ENDPOINT', 'R2_ACCESS_KEY_ID', 'R2_SECRET_ACCESS_KEY', 'TRON_PRO_API_KEY', 'COINS_API_KEY',
22
- 'ELASTICSEARCH_CONFIG', 'GRAPH_API_KEY', 'LLAMA_INDEXER_ENDPOINT', 'LLAMA_INDEXER_API_KEY', 'LLAMA_INDEXER_V2_ENDPOINT', 'LLAMA_INDEXER_V2_API_KEY',
22
+ 'ELASTICSEARCH_CONFIG', 'GRAPH_API_KEY', 'LLAMA_INDEXER_ENDPOINT', 'LLAMA_INDEXER_API_KEY', 'LLAMA_INDEXER_V2_ENDPOINT', 'LLAMA_INDEXER_V2_API_KEY', 'LLAMA_INDEXER_TIMEOUT_MS'
23
23
  ];
24
24
  const isDebugLevel3 = process.env.LLAMA_SDK_DEBUG_LEVEL_3 === 'true';
25
25
  const defaultEnvValues = {
26
26
  INTERNAL_SDK_CACHE_FILE: './cache.json',
27
27
  TRON_RPC_CONCURRENCY_LIMIT: '5',
28
28
  LLAMA_INDEXER_ADDRESS_CHUNK_SIZE: '20',
29
+ LLAMA_INDEXER_TIMEOUT_MS: '300000',
29
30
  TRON_WALLET_RPC: 'https://api.trongrid.io',
30
31
  // TRON_EVM_RPC: 'https://rpc.ankr.com/tron_jsonrpc', // no longer used
31
32
  NAKA_RPC: 'https://node.nakachain.xyz',
@@ -27,10 +27,26 @@ export type IndexerGetLogsOptions = {
27
27
  offset?: number;
28
28
  debugMode?: boolean;
29
29
  noTarget?: boolean;
30
+ collect?: boolean;
30
31
  parseLog?: boolean;
31
32
  processor?: (logs: any[]) => Promise<void> | void;
32
33
  maxBlockRange?: number;
33
34
  allowParseFailure?: boolean;
35
+ /** Feature flag: enable client-side streaming of /logs v2 */
36
+ clientStreaming?: boolean;
37
+ /** Decoder type: 'viem' (faster) or 'ethers' (fallback) */
38
+ decoderType?: "viem" | "ethers";
39
+ /** Metrics hooks (optional) */
40
+ onWireStats?: (s: {
41
+ chunkSize: number;
42
+ bytesReceived: number;
43
+ itemsProcessed: number;
44
+ }) => void;
45
+ onDecodeStats?: (s: {
46
+ batchSize: number;
47
+ decodeTime: number;
48
+ itemsDecoded: number;
49
+ }) => void;
34
50
  };
35
51
  export type IndexerGetTokenTransfersOptions = {
36
52
  target?: Address;