@defillama/sdk 5.0.149 → 5.0.150

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.
@@ -83,6 +83,7 @@ class LlamaProvider extends ethers_1.FallbackProvider {
83
83
  return this._performAction('getTransactionReceipt', [_hash]);
84
84
  }
85
85
  async _performAction(method, params, attempts = 7) {
86
+ var _a;
86
87
  if (!rpcRequestCounter[this.chainName])
87
88
  rpcRequestCounter[this.chainName] = 0;
88
89
  rpcRequestCounter[this.chainName]++;
@@ -133,10 +134,10 @@ class LlamaProvider extends ethers_1.FallbackProvider {
133
134
  }
134
135
  catch (e) {
135
136
  // console.log('failed', runner.url, (e as any).message)
136
- errors.push({ host: runner.url, error: e });
137
+ errors.push({ host: runner.url, error: ((_a = e === null || e === void 0 ? void 0 : e.message) !== null && _a !== void 0 ? _a : e) });
137
138
  }
138
139
  }
139
- throw { llamaRPCError: true, errors };
140
+ throw { llamaRPCError: true, errors, method, };
140
141
  }
141
142
  }
142
143
  exports.LlamaProvider = LlamaProvider;
@@ -325,9 +326,10 @@ function getMedianBlockValue(blocks) {
325
326
  }
326
327
  let lastPrintTimeMS = Date.now();
327
328
  function printRPCCallStats() {
328
- if (Object.keys(rpcRequestCounter).length > 7) {
329
- (0, debugLog_1.debugLog)('RPC request count per chain');
330
- (0, debugLog_1.debugTable)(rpcRequestCounter);
329
+ const entries = Object.entries(rpcRequestCounter).map(([chain, count]) => ({ chain, count })).filter(i => i.count > 50);
330
+ if (entries.length > 7) {
331
+ (0, debugLog_1.debugLog)('RPC request count per chain (only over 100)');
332
+ (0, debugLog_1.debugTable)(entries);
331
333
  }
332
334
  }
333
335
  process.on('exit', printRPCCallStats);
@@ -26,4 +26,6 @@ export declare function normalizeBalances(balances: {
26
26
  }): {
27
27
  [address: string]: string;
28
28
  };
29
- export declare function tableToString(data: any, columns?: any): string;
29
+ export declare function tableToString(data: any, columns?: any, { title }?: {
30
+ title?: string;
31
+ }): string;
@@ -162,14 +162,17 @@ function normalizeBalances(balances) {
162
162
  return balances;
163
163
  }
164
164
  exports.normalizeBalances = normalizeBalances;
165
- function tableToString(data, columns) {
165
+ function tableToString(data, columns, { title } = {}) {
166
166
  let tableString = '';
167
167
  if (!data || !Array.isArray(data) || data.length === 0) {
168
168
  return '';
169
169
  }
170
+ data = [...data]; // Ensure we don't modify the original data
170
171
  if (!columns || !Array.isArray(columns) || columns.length === 0) {
171
172
  columns = Object.keys(data[0] || {});
172
173
  }
174
+ if (title)
175
+ tableString += `# ${title}\n\n`;
173
176
  // Add the header row
174
177
  const headerObject = {};
175
178
  const headerObject1 = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defillama/sdk",
3
- "version": "5.0.149",
3
+ "version": "5.0.150",
4
4
  "description": "SDK for calculating TVL",
5
5
  "main": "build/index.js",
6
6
  "scripts": {