@1delta/providers 0.0.49 → 0.0.50

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/dist/index.js CHANGED
@@ -25281,19 +25281,24 @@ function isTransportError(e) {
25281
25281
  const msg = e instanceof Error ? (e.message ?? "") + (e.details ?? "") : "";
25282
25282
  return msg.includes("is not a constructor") || msg.includes("Dynamic require") || msg.includes("is not supported") || msg.includes("wrong json-rpc response") || msg.includes("there is neither result nor error");
25283
25283
  }
25284
- function isRateLimitError(e) {
25284
+ function isHttpError(e) {
25285
25285
  if (e instanceof BaseError2) {
25286
25286
  let err = e;
25287
25287
  while (err) {
25288
- if (err.status === 429) return true;
25288
+ const status = err.status;
25289
+ if (status && status >= 400) return true;
25289
25290
  const details = err.details ?? "";
25290
- if (details.includes("rate-limit") || details.includes("Too Many Requests"))
25291
+ if (details.includes("rate-limit") || details.includes("Too Many Requests") || details.includes("Bad gateway") || details.includes("<!DOCTYPE html>"))
25291
25292
  return true;
25292
25293
  err = err.cause ?? null;
25293
25294
  }
25294
25295
  }
25295
25296
  return false;
25296
25297
  }
25298
+ function isOutOfGasError(e) {
25299
+ const msg = e instanceof Error ? (e.message ?? "") + (e.details ?? "") : "";
25300
+ return msg.includes("out of gas") || msg.includes("gas exhausted");
25301
+ }
25297
25302
  function isContractRevert(e) {
25298
25303
  if (!(e instanceof BaseError2)) return false;
25299
25304
  let err = e;
@@ -25384,7 +25389,22 @@ function createMulticallRetry(customRpcs = LIST_OVERRIDES) {
25384
25389
  );
25385
25390
  }
25386
25391
  }
25387
- if ((isRateLimitError(e) || isTransportError(e)) && maxSkips > 0) {
25392
+ if (isOutOfGasError(e) && batchSize > 1) {
25393
+ if (logErrors) console.debug(e);
25394
+ return await multicallRetry2(
25395
+ chain,
25396
+ calls,
25397
+ abi2,
25398
+ Math.max(1, Math.floor(batchSize / 2)),
25399
+ maxRetries,
25400
+ providerId,
25401
+ allowFailure,
25402
+ logErrors,
25403
+ revertedIndices,
25404
+ maxSkips
25405
+ );
25406
+ }
25407
+ if ((isHttpError(e) || isTransportError(e)) && maxSkips > 0) {
25388
25408
  if (logErrors) console.debug(e);
25389
25409
  return await multicallRetry2(
25390
25410
  chain,
package/dist/index.mjs CHANGED
@@ -11521,19 +11521,24 @@ function isTransportError(e) {
11521
11521
  const msg = e instanceof Error ? (e.message ?? "") + (e.details ?? "") : "";
11522
11522
  return msg.includes("is not a constructor") || msg.includes("Dynamic require") || msg.includes("is not supported") || msg.includes("wrong json-rpc response") || msg.includes("there is neither result nor error");
11523
11523
  }
11524
- function isRateLimitError(e) {
11524
+ function isHttpError(e) {
11525
11525
  if (e instanceof BaseError) {
11526
11526
  let err = e;
11527
11527
  while (err) {
11528
- if (err.status === 429) return true;
11528
+ const status = err.status;
11529
+ if (status && status >= 400) return true;
11529
11530
  const details = err.details ?? "";
11530
- if (details.includes("rate-limit") || details.includes("Too Many Requests"))
11531
+ if (details.includes("rate-limit") || details.includes("Too Many Requests") || details.includes("Bad gateway") || details.includes("<!DOCTYPE html>"))
11531
11532
  return true;
11532
11533
  err = err.cause ?? null;
11533
11534
  }
11534
11535
  }
11535
11536
  return false;
11536
11537
  }
11538
+ function isOutOfGasError(e) {
11539
+ const msg = e instanceof Error ? (e.message ?? "") + (e.details ?? "") : "";
11540
+ return msg.includes("out of gas") || msg.includes("gas exhausted");
11541
+ }
11537
11542
  function isContractRevert(e) {
11538
11543
  if (!(e instanceof BaseError)) return false;
11539
11544
  let err = e;
@@ -11624,7 +11629,22 @@ function createMulticallRetry(customRpcs = LIST_OVERRIDES) {
11624
11629
  );
11625
11630
  }
11626
11631
  }
11627
- if ((isRateLimitError(e) || isTransportError(e)) && maxSkips > 0) {
11632
+ if (isOutOfGasError(e) && batchSize > 1) {
11633
+ if (logErrors) console.debug(e);
11634
+ return await multicallRetry2(
11635
+ chain,
11636
+ calls,
11637
+ abi2,
11638
+ Math.max(1, Math.floor(batchSize / 2)),
11639
+ maxRetries,
11640
+ providerId,
11641
+ allowFailure,
11642
+ logErrors,
11643
+ revertedIndices,
11644
+ maxSkips
11645
+ );
11646
+ }
11647
+ if ((isHttpError(e) || isTransportError(e)) && maxSkips > 0) {
11628
11648
  if (logErrors) console.debug(e);
11629
11649
  return await multicallRetry2(
11630
11650
  chain,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1delta/providers",
3
- "version": "0.0.49",
3
+ "version": "0.0.50",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -18,8 +18,8 @@
18
18
  "license": "ISC",
19
19
  "dependencies": {
20
20
  "vitest": "^4.0.18",
21
- "@1delta/chain-registry": "0.0.4",
22
- "@1delta/data-sdk": "0.0.17"
21
+ "@1delta/data-sdk": "0.0.17",
22
+ "@1delta/chain-registry": "0.0.4"
23
23
  },
24
24
  "devDependencies": {
25
25
  "tsup": "^8.5.1",
@@ -20,16 +20,19 @@ function isTransportError(e: unknown): boolean {
20
20
  )
21
21
  }
22
22
 
23
- /** Return true if the error is a rate-limit (429) response */
24
- function isRateLimitError(e: unknown): boolean {
23
+ /** Return true if the error is an HTTP-level failure (429, 502, 503, etc.) rather than a contract/RPC error */
24
+ function isHttpError(e: unknown): boolean {
25
25
  if (e instanceof BaseError) {
26
26
  let err: any = e
27
27
  while (err) {
28
- if (err.status === 429) return true
28
+ const status = err.status as number | undefined
29
+ if (status && status >= 400) return true
29
30
  const details: string = err.details ?? ''
30
31
  if (
31
32
  details.includes('rate-limit') ||
32
- details.includes('Too Many Requests')
33
+ details.includes('Too Many Requests') ||
34
+ details.includes('Bad gateway') ||
35
+ details.includes('<!DOCTYPE html>')
33
36
  )
34
37
  return true
35
38
  err = err.cause ?? null
@@ -38,6 +41,13 @@ function isRateLimitError(e: unknown): boolean {
38
41
  return false
39
42
  }
40
43
 
44
+ /** Return true if the multicall ran out of gas (batch too large for the RPC gas limit) */
45
+ function isOutOfGasError(e: unknown): boolean {
46
+ const msg =
47
+ e instanceof Error ? (e.message ?? '') + ((e as any).details ?? '') : ''
48
+ return msg.includes('out of gas') || msg.includes('gas exhausted')
49
+ }
50
+
41
51
  /** Return true if it is a revert case */
42
52
  function isContractRevert(e: unknown): boolean {
43
53
  if (!(e instanceof BaseError)) return false
@@ -190,9 +200,26 @@ export function createMulticallRetry(
190
200
  }
191
201
  }
192
202
 
203
+ // Out-of-gas: batch too large for the RPC gas limit — halve batch size and retry
204
+ if (isOutOfGasError(e) && batchSize > 1) {
205
+ if (logErrors) console.debug(e)
206
+ return await multicallRetry(
207
+ chain,
208
+ calls,
209
+ abi,
210
+ Math.max(1, Math.floor(batchSize / 2)),
211
+ maxRetries,
212
+ providerId,
213
+ allowFailure,
214
+ logErrors,
215
+ revertedIndices,
216
+ maxSkips,
217
+ )
218
+ }
219
+
193
220
  // Rate-limit (429) or transport/environment errors:
194
221
  // skip to next RPC without consuming a retry
195
- if ((isRateLimitError(e) || isTransportError(e)) && maxSkips > 0) {
222
+ if ((isHttpError(e) || isTransportError(e)) && maxSkips > 0) {
196
223
  if (logErrors) console.debug(e)
197
224
  return await multicallRetry(
198
225
  chain,