@1delta/providers 0.0.48 → 0.0.49

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.d.mts CHANGED
@@ -8269,7 +8269,7 @@ declare const LIST_OVERRIDES: Record<string, string[]>;
8269
8269
  declare function createTransport(url: string, config?: any): viem.WebSocketTransport | viem.HttpTransport<undefined, false>;
8270
8270
  declare function getTransport(url: string): viem.WebSocketTransport | viem.HttpTransport<undefined, false>;
8271
8271
 
8272
- declare const DEFAULT_BATCH_SIZE = 4096;
8272
+ declare const DEFAULT_BATCH_SIZE = 1024;
8273
8273
  declare function trimTrailingSlash(url?: string): string | undefined;
8274
8274
  declare function deepCompare(a: any, b: any): boolean;
8275
8275
  declare function uniq<T>(array: T[]): T[];
package/dist/index.d.ts CHANGED
@@ -8269,7 +8269,7 @@ declare const LIST_OVERRIDES: Record<string, string[]>;
8269
8269
  declare function createTransport(url: string, config?: any): viem.WebSocketTransport | viem.HttpTransport<undefined, false>;
8270
8270
  declare function getTransport(url: string): viem.WebSocketTransport | viem.HttpTransport<undefined, false>;
8271
8271
 
8272
- declare const DEFAULT_BATCH_SIZE = 4096;
8272
+ declare const DEFAULT_BATCH_SIZE = 1024;
8273
8273
  declare function trimTrailingSlash(url?: string): string | undefined;
8274
8274
  declare function deepCompare(a: any, b: any): boolean;
8275
8275
  declare function uniq<T>(array: T[]): T[];
package/dist/index.js CHANGED
@@ -25162,7 +25162,7 @@ function getTransport(url) {
25162
25162
  }
25163
25163
 
25164
25164
  // src/utils/utils.ts
25165
- var DEFAULT_BATCH_SIZE = 4096;
25165
+ var DEFAULT_BATCH_SIZE = 1024;
25166
25166
  function trimTrailingSlash(url) {
25167
25167
  if (!url) return void 0;
25168
25168
  return url.endsWith("/") ? url.slice(0, -1) : url;
@@ -25281,6 +25281,19 @@ 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) {
25285
+ if (e instanceof BaseError2) {
25286
+ let err = e;
25287
+ while (err) {
25288
+ if (err.status === 429) return true;
25289
+ const details = err.details ?? "";
25290
+ if (details.includes("rate-limit") || details.includes("Too Many Requests"))
25291
+ return true;
25292
+ err = err.cause ?? null;
25293
+ }
25294
+ }
25295
+ return false;
25296
+ }
25284
25297
  function isContractRevert(e) {
25285
25298
  if (!(e instanceof BaseError2)) return false;
25286
25299
  let err = e;
@@ -25294,7 +25307,7 @@ function isContractRevert(e) {
25294
25307
  return false;
25295
25308
  }
25296
25309
  function createMulticallRetry(customRpcs = LIST_OVERRIDES) {
25297
- return async function multicallRetry2(chain, calls, abi2, batchSize = DEFAULT_BATCH_SIZE, maxRetries = 3, providerId = 0, allowFailure = true, logErrors = false, revertedIndices = /* @__PURE__ */ new Set(), maxSkips = 3) {
25310
+ return async function multicallRetry2(chain, calls, abi2, batchSize = DEFAULT_BATCH_SIZE, maxRetries = 3, providerId = 0, allowFailure = true, logErrors = false, revertedIndices = /* @__PURE__ */ new Set(), maxSkips = 6) {
25298
25311
  const abiIsArray = isArray(abi2[0]);
25299
25312
  try {
25300
25313
  const nonRevertedIndices = calls.map((_, i) => i).filter((i) => !revertedIndices.has(i));
@@ -25371,7 +25384,7 @@ function createMulticallRetry(customRpcs = LIST_OVERRIDES) {
25371
25384
  );
25372
25385
  }
25373
25386
  }
25374
- if (isTransportError(e) && maxSkips > 0) {
25387
+ if ((isRateLimitError(e) || isTransportError(e)) && maxSkips > 0) {
25375
25388
  if (logErrors) console.debug(e);
25376
25389
  return await multicallRetry2(
25377
25390
  chain,
package/dist/index.mjs CHANGED
@@ -11402,7 +11402,7 @@ function getTransport(url) {
11402
11402
  }
11403
11403
 
11404
11404
  // src/utils/utils.ts
11405
- var DEFAULT_BATCH_SIZE = 4096;
11405
+ var DEFAULT_BATCH_SIZE = 1024;
11406
11406
  function trimTrailingSlash(url) {
11407
11407
  if (!url) return void 0;
11408
11408
  return url.endsWith("/") ? url.slice(0, -1) : url;
@@ -11521,6 +11521,19 @@ 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) {
11525
+ if (e instanceof BaseError) {
11526
+ let err = e;
11527
+ while (err) {
11528
+ if (err.status === 429) return true;
11529
+ const details = err.details ?? "";
11530
+ if (details.includes("rate-limit") || details.includes("Too Many Requests"))
11531
+ return true;
11532
+ err = err.cause ?? null;
11533
+ }
11534
+ }
11535
+ return false;
11536
+ }
11524
11537
  function isContractRevert(e) {
11525
11538
  if (!(e instanceof BaseError)) return false;
11526
11539
  let err = e;
@@ -11534,7 +11547,7 @@ function isContractRevert(e) {
11534
11547
  return false;
11535
11548
  }
11536
11549
  function createMulticallRetry(customRpcs = LIST_OVERRIDES) {
11537
- return async function multicallRetry2(chain, calls, abi2, batchSize = DEFAULT_BATCH_SIZE, maxRetries = 3, providerId = 0, allowFailure = true, logErrors = false, revertedIndices = /* @__PURE__ */ new Set(), maxSkips = 3) {
11550
+ return async function multicallRetry2(chain, calls, abi2, batchSize = DEFAULT_BATCH_SIZE, maxRetries = 3, providerId = 0, allowFailure = true, logErrors = false, revertedIndices = /* @__PURE__ */ new Set(), maxSkips = 6) {
11538
11551
  const abiIsArray = isArray(abi2[0]);
11539
11552
  try {
11540
11553
  const nonRevertedIndices = calls.map((_, i) => i).filter((i) => !revertedIndices.has(i));
@@ -11611,7 +11624,7 @@ function createMulticallRetry(customRpcs = LIST_OVERRIDES) {
11611
11624
  );
11612
11625
  }
11613
11626
  }
11614
- if (isTransportError(e) && maxSkips > 0) {
11627
+ if ((isRateLimitError(e) || isTransportError(e)) && maxSkips > 0) {
11615
11628
  if (logErrors) console.debug(e);
11616
11629
  return await multicallRetry2(
11617
11630
  chain,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1delta/providers",
3
- "version": "0.0.48",
3
+ "version": "0.0.49",
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/data-sdk": "0.0.17",
22
- "@1delta/chain-registry": "0.0.4"
21
+ "@1delta/chain-registry": "0.0.4",
22
+ "@1delta/data-sdk": "0.0.17"
23
23
  },
24
24
  "devDependencies": {
25
25
  "tsup": "^8.5.1",
@@ -20,6 +20,24 @@ 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 {
25
+ if (e instanceof BaseError) {
26
+ let err: any = e
27
+ while (err) {
28
+ if (err.status === 429) return true
29
+ const details: string = err.details ?? ''
30
+ if (
31
+ details.includes('rate-limit') ||
32
+ details.includes('Too Many Requests')
33
+ )
34
+ return true
35
+ err = err.cause ?? null
36
+ }
37
+ }
38
+ return false
39
+ }
40
+
23
41
  /** Return true if it is a revert case */
24
42
  function isContractRevert(e: unknown): boolean {
25
43
  if (!(e instanceof BaseError)) return false
@@ -69,7 +87,7 @@ export function createMulticallRetry(
69
87
  allowFailure = true,
70
88
  logErrors = false,
71
89
  revertedIndices: Set<number> = new Set(),
72
- maxSkips = 3,
90
+ maxSkips = 6,
73
91
  ): Promise<any[]> {
74
92
  const abiIsArray = isArray(abi[0])
75
93
 
@@ -172,9 +190,9 @@ export function createMulticallRetry(
172
190
  }
173
191
  }
174
192
 
175
- // Transport/environment errors (e.g. WebSocket not available):
193
+ // Rate-limit (429) or transport/environment errors:
176
194
  // skip to next RPC without consuming a retry
177
- if (isTransportError(e) && maxSkips > 0) {
195
+ if ((isRateLimitError(e) || isTransportError(e)) && maxSkips > 0) {
178
196
  if (logErrors) console.debug(e)
179
197
  return await multicallRetry(
180
198
  chain,
@@ -1,4 +1,4 @@
1
- export const DEFAULT_BATCH_SIZE = 4096
1
+ export const DEFAULT_BATCH_SIZE = 1024
2
2
 
3
3
  export function trimTrailingSlash(url?: string) {
4
4
  if (!url) return undefined