@1delta/providers 0.0.48 → 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.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +36 -3
- package/dist/index.mjs +36 -3
- package/package.json +1 -1
- package/src/multicall/multicall.ts +48 -3
- package/src/utils/utils.ts +1 -1
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 =
|
|
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 =
|
|
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 =
|
|
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,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 isHttpError(e) {
|
|
25285
|
+
if (e instanceof BaseError2) {
|
|
25286
|
+
let err = e;
|
|
25287
|
+
while (err) {
|
|
25288
|
+
const status = err.status;
|
|
25289
|
+
if (status && status >= 400) return true;
|
|
25290
|
+
const details = err.details ?? "";
|
|
25291
|
+
if (details.includes("rate-limit") || details.includes("Too Many Requests") || details.includes("Bad gateway") || details.includes("<!DOCTYPE html>"))
|
|
25292
|
+
return true;
|
|
25293
|
+
err = err.cause ?? null;
|
|
25294
|
+
}
|
|
25295
|
+
}
|
|
25296
|
+
return false;
|
|
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
|
+
}
|
|
25284
25302
|
function isContractRevert(e) {
|
|
25285
25303
|
if (!(e instanceof BaseError2)) return false;
|
|
25286
25304
|
let err = e;
|
|
@@ -25294,7 +25312,7 @@ function isContractRevert(e) {
|
|
|
25294
25312
|
return false;
|
|
25295
25313
|
}
|
|
25296
25314
|
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 =
|
|
25315
|
+
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
25316
|
const abiIsArray = isArray(abi2[0]);
|
|
25299
25317
|
try {
|
|
25300
25318
|
const nonRevertedIndices = calls.map((_, i) => i).filter((i) => !revertedIndices.has(i));
|
|
@@ -25371,7 +25389,22 @@ function createMulticallRetry(customRpcs = LIST_OVERRIDES) {
|
|
|
25371
25389
|
);
|
|
25372
25390
|
}
|
|
25373
25391
|
}
|
|
25374
|
-
if (
|
|
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) {
|
|
25375
25408
|
if (logErrors) console.debug(e);
|
|
25376
25409
|
return await multicallRetry2(
|
|
25377
25410
|
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 =
|
|
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,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 isHttpError(e) {
|
|
11525
|
+
if (e instanceof BaseError) {
|
|
11526
|
+
let err = e;
|
|
11527
|
+
while (err) {
|
|
11528
|
+
const status = err.status;
|
|
11529
|
+
if (status && status >= 400) return true;
|
|
11530
|
+
const details = err.details ?? "";
|
|
11531
|
+
if (details.includes("rate-limit") || details.includes("Too Many Requests") || details.includes("Bad gateway") || details.includes("<!DOCTYPE html>"))
|
|
11532
|
+
return true;
|
|
11533
|
+
err = err.cause ?? null;
|
|
11534
|
+
}
|
|
11535
|
+
}
|
|
11536
|
+
return false;
|
|
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
|
+
}
|
|
11524
11542
|
function isContractRevert(e) {
|
|
11525
11543
|
if (!(e instanceof BaseError)) return false;
|
|
11526
11544
|
let err = e;
|
|
@@ -11534,7 +11552,7 @@ function isContractRevert(e) {
|
|
|
11534
11552
|
return false;
|
|
11535
11553
|
}
|
|
11536
11554
|
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 =
|
|
11555
|
+
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
11556
|
const abiIsArray = isArray(abi2[0]);
|
|
11539
11557
|
try {
|
|
11540
11558
|
const nonRevertedIndices = calls.map((_, i) => i).filter((i) => !revertedIndices.has(i));
|
|
@@ -11611,7 +11629,22 @@ function createMulticallRetry(customRpcs = LIST_OVERRIDES) {
|
|
|
11611
11629
|
);
|
|
11612
11630
|
}
|
|
11613
11631
|
}
|
|
11614
|
-
if (
|
|
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) {
|
|
11615
11648
|
if (logErrors) console.debug(e);
|
|
11616
11649
|
return await multicallRetry2(
|
|
11617
11650
|
chain,
|
package/package.json
CHANGED
|
@@ -20,6 +20,34 @@ function isTransportError(e: unknown): boolean {
|
|
|
20
20
|
)
|
|
21
21
|
}
|
|
22
22
|
|
|
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
|
+
if (e instanceof BaseError) {
|
|
26
|
+
let err: any = e
|
|
27
|
+
while (err) {
|
|
28
|
+
const status = err.status as number | undefined
|
|
29
|
+
if (status && status >= 400) return true
|
|
30
|
+
const details: string = err.details ?? ''
|
|
31
|
+
if (
|
|
32
|
+
details.includes('rate-limit') ||
|
|
33
|
+
details.includes('Too Many Requests') ||
|
|
34
|
+
details.includes('Bad gateway') ||
|
|
35
|
+
details.includes('<!DOCTYPE html>')
|
|
36
|
+
)
|
|
37
|
+
return true
|
|
38
|
+
err = err.cause ?? null
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return false
|
|
42
|
+
}
|
|
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
|
+
|
|
23
51
|
/** Return true if it is a revert case */
|
|
24
52
|
function isContractRevert(e: unknown): boolean {
|
|
25
53
|
if (!(e instanceof BaseError)) return false
|
|
@@ -69,7 +97,7 @@ export function createMulticallRetry(
|
|
|
69
97
|
allowFailure = true,
|
|
70
98
|
logErrors = false,
|
|
71
99
|
revertedIndices: Set<number> = new Set(),
|
|
72
|
-
maxSkips =
|
|
100
|
+
maxSkips = 6,
|
|
73
101
|
): Promise<any[]> {
|
|
74
102
|
const abiIsArray = isArray(abi[0])
|
|
75
103
|
|
|
@@ -172,9 +200,26 @@ export function createMulticallRetry(
|
|
|
172
200
|
}
|
|
173
201
|
}
|
|
174
202
|
|
|
175
|
-
//
|
|
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
|
+
|
|
220
|
+
// Rate-limit (429) or transport/environment errors:
|
|
176
221
|
// skip to next RPC without consuming a retry
|
|
177
|
-
if (isTransportError(e) && maxSkips > 0) {
|
|
222
|
+
if ((isHttpError(e) || isTransportError(e)) && maxSkips > 0) {
|
|
178
223
|
if (logErrors) console.debug(e)
|
|
179
224
|
return await multicallRetry(
|
|
180
225
|
chain,
|
package/src/utils/utils.ts
CHANGED