@gearbox-protocol/sdk 14.0.0-next.7 → 14.0.0-next.9
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/cjs/dev/RevolverTransport.js +10 -4
- package/dist/cjs/dev/logSplitterTransport.js +10 -1
- package/dist/esm/dev/RevolverTransport.js +10 -4
- package/dist/esm/dev/logSplitterTransport.js +10 -1
- package/dist/types/dev/RevolverTransport.d.ts +2 -1
- package/dist/types/dev/logSplitterTransport.d.ts +3 -1
- package/package.json +1 -1
|
@@ -87,8 +87,14 @@ const revolverTransportConfigSchema = import_v4.z.union([
|
|
|
87
87
|
})
|
|
88
88
|
]);
|
|
89
89
|
class NoAvailableTransportsError extends import_viem.BaseError {
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
statuses;
|
|
91
|
+
constructor(statuses, cause) {
|
|
92
|
+
super("No available transports", {
|
|
93
|
+
cause,
|
|
94
|
+
metaMessages: statuses.length > 0 ? statuses.map((s) => `- ${s.id}: ${s.status}`) : ["No transports configured"],
|
|
95
|
+
name: "NoAvailableTransportsError"
|
|
96
|
+
});
|
|
97
|
+
this.statuses = statuses;
|
|
92
98
|
}
|
|
93
99
|
}
|
|
94
100
|
class RevolverTransport {
|
|
@@ -146,7 +152,7 @@ class RevolverTransport {
|
|
|
146
152
|
);
|
|
147
153
|
}
|
|
148
154
|
if (transports.length === 0) {
|
|
149
|
-
throw new NoAvailableTransportsError();
|
|
155
|
+
throw new NoAvailableTransportsError([]);
|
|
150
156
|
}
|
|
151
157
|
this.#isSingle = transports.length === 1;
|
|
152
158
|
const selectionStrategy = config.selectionStrategy ?? "simple";
|
|
@@ -197,7 +203,7 @@ class RevolverTransport {
|
|
|
197
203
|
}
|
|
198
204
|
} while (this.#selector.canRotate());
|
|
199
205
|
this.#requests.delete(r);
|
|
200
|
-
throw new NoAvailableTransportsError(error);
|
|
206
|
+
throw new NoAvailableTransportsError(this.#selector.statuses(), error);
|
|
201
207
|
};
|
|
202
208
|
get config() {
|
|
203
209
|
return {
|
|
@@ -43,7 +43,9 @@ const RANGE_ERROR_PATTERNS = [
|
|
|
43
43
|
/eth_getLogs is limited to/i,
|
|
44
44
|
/eth_getLogs requests with up to/i,
|
|
45
45
|
/range is too large/i,
|
|
46
|
-
/exceeded max allowed range/i
|
|
46
|
+
/exceeded max allowed range/i,
|
|
47
|
+
// Encountered on DRPC: "query exceeds max results 20000, retry with the range …"
|
|
48
|
+
/exceeds max results/i
|
|
47
49
|
];
|
|
48
50
|
function isRangeError(error) {
|
|
49
51
|
const msg = errorMessage(error);
|
|
@@ -51,10 +53,17 @@ function isRangeError(error) {
|
|
|
51
53
|
}
|
|
52
54
|
const GENERIC_BLOCKS_RE = /(\d+)\s*block/i;
|
|
53
55
|
const ALCHEMY_RANGE_RE = /this block range should work: \[(0x[0-9a-fA-F]+),\s*(0x[0-9a-fA-F]+)\]/;
|
|
56
|
+
const DRPC_RANGE_RE = /retry with the range (\d+)-(\d+)/;
|
|
54
57
|
function parsePageSizeHint(error) {
|
|
55
58
|
const alchemy = tryAlchemyHint(error);
|
|
56
59
|
if (alchemy != null) return alchemy;
|
|
57
60
|
const msg = errorMessage(error);
|
|
61
|
+
const drpc = msg.match(DRPC_RANGE_RE);
|
|
62
|
+
if (drpc) {
|
|
63
|
+
const from = Number(drpc[1]);
|
|
64
|
+
const to = Number(drpc[2]);
|
|
65
|
+
return to - from + 1;
|
|
66
|
+
}
|
|
58
67
|
const m = msg.match(GENERIC_BLOCKS_RE);
|
|
59
68
|
return m ? Number(m[1]) : null;
|
|
60
69
|
}
|
|
@@ -70,8 +70,14 @@ const revolverTransportConfigSchema = z.union([
|
|
|
70
70
|
})
|
|
71
71
|
]);
|
|
72
72
|
class NoAvailableTransportsError extends BaseError {
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
statuses;
|
|
74
|
+
constructor(statuses, cause) {
|
|
75
|
+
super("No available transports", {
|
|
76
|
+
cause,
|
|
77
|
+
metaMessages: statuses.length > 0 ? statuses.map((s) => `- ${s.id}: ${s.status}`) : ["No transports configured"],
|
|
78
|
+
name: "NoAvailableTransportsError"
|
|
79
|
+
});
|
|
80
|
+
this.statuses = statuses;
|
|
75
81
|
}
|
|
76
82
|
}
|
|
77
83
|
class RevolverTransport {
|
|
@@ -129,7 +135,7 @@ class RevolverTransport {
|
|
|
129
135
|
);
|
|
130
136
|
}
|
|
131
137
|
if (transports.length === 0) {
|
|
132
|
-
throw new NoAvailableTransportsError();
|
|
138
|
+
throw new NoAvailableTransportsError([]);
|
|
133
139
|
}
|
|
134
140
|
this.#isSingle = transports.length === 1;
|
|
135
141
|
const selectionStrategy = config.selectionStrategy ?? "simple";
|
|
@@ -180,7 +186,7 @@ class RevolverTransport {
|
|
|
180
186
|
}
|
|
181
187
|
} while (this.#selector.canRotate());
|
|
182
188
|
this.#requests.delete(r);
|
|
183
|
-
throw new NoAvailableTransportsError(error);
|
|
189
|
+
throw new NoAvailableTransportsError(this.#selector.statuses(), error);
|
|
184
190
|
};
|
|
185
191
|
get config() {
|
|
186
192
|
return {
|
|
@@ -21,7 +21,9 @@ const RANGE_ERROR_PATTERNS = [
|
|
|
21
21
|
/eth_getLogs is limited to/i,
|
|
22
22
|
/eth_getLogs requests with up to/i,
|
|
23
23
|
/range is too large/i,
|
|
24
|
-
/exceeded max allowed range/i
|
|
24
|
+
/exceeded max allowed range/i,
|
|
25
|
+
// Encountered on DRPC: "query exceeds max results 20000, retry with the range …"
|
|
26
|
+
/exceeds max results/i
|
|
25
27
|
];
|
|
26
28
|
function isRangeError(error) {
|
|
27
29
|
const msg = errorMessage(error);
|
|
@@ -29,10 +31,17 @@ function isRangeError(error) {
|
|
|
29
31
|
}
|
|
30
32
|
const GENERIC_BLOCKS_RE = /(\d+)\s*block/i;
|
|
31
33
|
const ALCHEMY_RANGE_RE = /this block range should work: \[(0x[0-9a-fA-F]+),\s*(0x[0-9a-fA-F]+)\]/;
|
|
34
|
+
const DRPC_RANGE_RE = /retry with the range (\d+)-(\d+)/;
|
|
32
35
|
function parsePageSizeHint(error) {
|
|
33
36
|
const alchemy = tryAlchemyHint(error);
|
|
34
37
|
if (alchemy != null) return alchemy;
|
|
35
38
|
const msg = errorMessage(error);
|
|
39
|
+
const drpc = msg.match(DRPC_RANGE_RE);
|
|
40
|
+
if (drpc) {
|
|
41
|
+
const from = Number(drpc[1]);
|
|
42
|
+
const to = Number(drpc[2]);
|
|
43
|
+
return to - from + 1;
|
|
44
|
+
}
|
|
36
45
|
const m = msg.match(GENERIC_BLOCKS_RE);
|
|
37
46
|
return m ? Number(m[1]) : null;
|
|
38
47
|
}
|
|
@@ -167,7 +167,8 @@ export type RevolverTransportConfig = {
|
|
|
167
167
|
onRotateFailed?: (oldTransportName: string, reason?: BaseError) => void | Promise<void>;
|
|
168
168
|
} & z.infer<typeof revolverTransportConfigSchema>;
|
|
169
169
|
export declare class NoAvailableTransportsError extends BaseError {
|
|
170
|
-
|
|
170
|
+
statuses: ProviderStatus[];
|
|
171
|
+
constructor(statuses: ProviderStatus[], cause?: Error);
|
|
171
172
|
}
|
|
172
173
|
export interface RevolverTransportValue {
|
|
173
174
|
/**
|
|
@@ -56,7 +56,9 @@ export declare function isRangeError(error: unknown): boolean;
|
|
|
56
56
|
* 1. **Alchemy JSON details** — parses the `details` field of a
|
|
57
57
|
* {@link HttpRequestError} for a suggested `[fromHex, toHex]` range and
|
|
58
58
|
* computes the span as `toHex - fromHex + 1`.
|
|
59
|
-
* 2. **
|
|
59
|
+
* 2. **DRPC decimal range** — matches `retry with the range <from>-<to>` and
|
|
60
|
+
* computes the span as `to - from + 1`.
|
|
61
|
+
* 3. **Generic N-blocks pattern** — matches `/<number> block(s)/i` in the
|
|
60
62
|
* error message.
|
|
61
63
|
*
|
|
62
64
|
* @param error - Any thrown value.
|