@defillama/sdk 5.0.188 → 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;
@@ -98,16 +98,21 @@ function enrichEthersArgsWithNamedProperties(ethersArgs, event, iface) {
98
98
  if (!ethersArgs || !event || !event.inputs) {
99
99
  return ethersArgs;
100
100
  }
101
- // Create a new args object with named properties
102
- const enrichedArgs = Object.create(null);
103
- // Copy all existing properties (numeric and named if present)
101
+ const inputs = event.inputs;
102
+ const length = typeof ethersArgs.length === 'number' ? ethersArgs.length : inputs.length;
103
+ const enrichedArgs = new Array(length);
104
+ for (let i = 0; i < length; i++) {
105
+ if (i in ethersArgs) {
106
+ enrichedArgs[i] = ethersArgs[i];
107
+ }
108
+ }
104
109
  for (const key in ethersArgs) {
105
- if (ethersArgs.hasOwnProperty && !ethersArgs.hasOwnProperty(key))
110
+ if (!Object.prototype.hasOwnProperty.call(ethersArgs, key))
106
111
  continue;
107
- enrichedArgs[key] = ethersArgs[key];
112
+ if (!/^\d+$/.test(key)) {
113
+ enrichedArgs[key] = ethersArgs[key];
114
+ }
108
115
  }
109
- // Ensure named properties are present
110
- const inputs = event.inputs;
111
116
  for (let i = 0; i < inputs.length; i++) {
112
117
  const input = inputs[i];
113
118
  const value = ethersArgs[i];
@@ -115,23 +120,20 @@ function enrichEthersArgsWithNamedProperties(ethersArgs, event, iface) {
115
120
  if (input.name && !(input.name in enrichedArgs)) {
116
121
  enrichedArgs[input.name] = value;
117
122
  }
118
- enrichedArgs[i] = value;
123
+ if (!(i in enrichedArgs)) {
124
+ enrichedArgs[i] = value;
125
+ }
119
126
  }
120
127
  }
121
- if (typeof ethersArgs.length === 'number') {
122
- enrichedArgs.length = ethersArgs.length;
123
- }
124
128
  return enrichedArgs;
125
129
  }
126
130
  function buildEthersCompatibleArgs(decodedArgs, eventInputs, normalizeFn = normalizeValueByType) {
127
131
  var _a, _b;
128
132
  if (!decodedArgs) {
129
- const args = Object.create(null);
130
- args.length = eventInputs.length;
133
+ const args = new Array(eventInputs.length);
131
134
  return args;
132
135
  }
133
- const args = Object.create(null);
134
- args.length = eventInputs.length;
136
+ const args = new Array(eventInputs.length);
135
137
  try {
136
138
  if (Array.isArray(decodedArgs)) {
137
139
  const len = Math.min(decodedArgs.length, eventInputs.length);
@@ -205,8 +207,7 @@ function createViemFastPathBatchDecoder(eventAbi) {
205
207
  const decodedNon = nonIndexed.length && logData && logData !== '0x'
206
208
  ? (0, viem_1.decodeAbiParameters)(nonIndexedTypes, logData)
207
209
  : [];
208
- const args = Object.create(null);
209
- args.length = inputs.length;
210
+ const args = new Array(inputs.length);
210
211
  let topicIdx = 1; // topics[0] = event signature
211
212
  let nonIndexedIdx = 0;
212
213
  for (let j = 0; j < inputs.length; j++) {
@@ -274,8 +275,7 @@ function createViemFastPathBatchDecoder(eventAbi) {
274
275
  }
275
276
  catch (e) {
276
277
  // Fallback: return empty args on decode error
277
- const args = Object.create(null);
278
- args.length = inputs.length;
278
+ const args = new Array(inputs.length);
279
279
  out[i] = args;
280
280
  }
281
281
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defillama/sdk",
3
- "version": "5.0.188",
3
+ "version": "5.0.192",
4
4
  "description": "SDK for calculating TVL",
5
5
  "main": "build/index.js",
6
6
  "scripts": {