@metamask-previews/network-controller 26.0.0-preview-e3eb8eca → 26.0.0-preview-58cfb208
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/CHANGELOG.md +0 -19
- package/dist/NetworkController.cjs +10 -37
- package/dist/NetworkController.cjs.map +1 -1
- package/dist/NetworkController.d.cts +11 -146
- package/dist/NetworkController.d.cts.map +1 -1
- package/dist/NetworkController.d.mts +11 -146
- package/dist/NetworkController.d.mts.map +1 -1
- package/dist/NetworkController.mjs +10 -37
- package/dist/NetworkController.mjs.map +1 -1
- package/dist/constants.cjs +10 -18
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +10 -18
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.mts +10 -18
- package/dist/constants.d.mts.map +1 -1
- package/dist/constants.mjs +10 -18
- package/dist/constants.mjs.map +1 -1
- package/dist/create-auto-managed-network-client.cjs +1 -4
- package/dist/create-auto-managed-network-client.cjs.map +1 -1
- package/dist/create-auto-managed-network-client.d.cts +2 -5
- package/dist/create-auto-managed-network-client.d.cts.map +1 -1
- package/dist/create-auto-managed-network-client.d.mts +2 -5
- package/dist/create-auto-managed-network-client.d.mts.map +1 -1
- package/dist/create-auto-managed-network-client.mjs +1 -4
- package/dist/create-auto-managed-network-client.mjs.map +1 -1
- package/dist/create-network-client.cjs +42 -115
- package/dist/create-network-client.cjs.map +1 -1
- package/dist/create-network-client.d.cts +2 -5
- package/dist/create-network-client.d.cts.map +1 -1
- package/dist/create-network-client.d.mts +2 -5
- package/dist/create-network-client.d.mts.map +1 -1
- package/dist/create-network-client.mjs +42 -115
- package/dist/create-network-client.mjs.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/rpc-service/rpc-service-chain.cjs +39 -255
- package/dist/rpc-service/rpc-service-chain.cjs.map +1 -1
- package/dist/rpc-service/rpc-service-chain.d.cts +25 -117
- package/dist/rpc-service/rpc-service-chain.d.cts.map +1 -1
- package/dist/rpc-service/rpc-service-chain.d.mts +25 -117
- package/dist/rpc-service/rpc-service-chain.d.mts.map +1 -1
- package/dist/rpc-service/rpc-service-chain.mjs +39 -255
- package/dist/rpc-service/rpc-service-chain.mjs.map +1 -1
- package/dist/rpc-service/rpc-service-requestable.cjs.map +1 -1
- package/dist/rpc-service/rpc-service-requestable.d.cts +5 -15
- package/dist/rpc-service/rpc-service-requestable.d.cts.map +1 -1
- package/dist/rpc-service/rpc-service-requestable.d.mts +5 -15
- package/dist/rpc-service/rpc-service-requestable.d.mts.map +1 -1
- package/dist/rpc-service/rpc-service-requestable.mjs.map +1 -1
- package/dist/rpc-service/rpc-service.cjs +33 -63
- package/dist/rpc-service/rpc-service.cjs.map +1 -1
- package/dist/rpc-service/rpc-service.d.cts +24 -35
- package/dist/rpc-service/rpc-service.d.cts.map +1 -1
- package/dist/rpc-service/rpc-service.d.mts +24 -35
- package/dist/rpc-service/rpc-service.d.mts.map +1 -1
- package/dist/rpc-service/rpc-service.mjs +34 -64
- package/dist/rpc-service/rpc-service.mjs.map +1 -1
- package/dist/rpc-service/shared.cjs.map +1 -1
- package/dist/rpc-service/shared.d.cts +3 -30
- package/dist/rpc-service/shared.d.cts.map +1 -1
- package/dist/rpc-service/shared.d.mts +3 -30
- package/dist/rpc-service/shared.d.mts.map +1 -1
- package/dist/rpc-service/shared.mjs.map +1 -1
- package/package.json +1 -2
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { Json, JsonRpcParams, JsonRpcRequest, JsonRpcResponse } from "@metamask/utils";
|
|
2
2
|
import { RpcService } from "./rpc-service.cjs";
|
|
3
3
|
import type { RpcServiceOptions } from "./rpc-service.cjs";
|
|
4
|
-
import type {
|
|
5
|
-
type
|
|
4
|
+
import type { RpcServiceRequestable } from "./rpc-service-requestable.cjs";
|
|
5
|
+
import type { FetchOptions } from "./shared.cjs";
|
|
6
6
|
/**
|
|
7
|
-
* This class constructs
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* This class constructs a chain of RpcService objects which represent a
|
|
8
|
+
* particular network. The first object in the chain is intended to be the
|
|
9
|
+
* primary way of reaching the network and the remaining objects are used as
|
|
10
|
+
* failovers.
|
|
11
11
|
*/
|
|
12
|
-
export declare class RpcServiceChain {
|
|
12
|
+
export declare class RpcServiceChain implements RpcServiceRequestable {
|
|
13
13
|
#private;
|
|
14
14
|
/**
|
|
15
15
|
* Constructs a new RpcServiceChain object.
|
|
@@ -18,129 +18,38 @@ export declare class RpcServiceChain {
|
|
|
18
18
|
* that you want to construct. Each object in this array is the same as
|
|
19
19
|
* {@link RpcServiceOptions}.
|
|
20
20
|
*/
|
|
21
|
-
constructor(rpcServiceConfigurations: [
|
|
22
|
-
RpcServiceConfiguration,
|
|
23
|
-
...RpcServiceConfiguration[]
|
|
24
|
-
]);
|
|
21
|
+
constructor(rpcServiceConfigurations: Omit<RpcServiceOptions, 'failoverService'>[]);
|
|
25
22
|
/**
|
|
26
|
-
*
|
|
23
|
+
* Listens for when any of the RPC services retry a request.
|
|
27
24
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* @param listener - The callback to be called.
|
|
31
|
-
* @returns An object with a `dispose` method which can be used to unregister
|
|
32
|
-
* the event listener.
|
|
25
|
+
* @param listener - The callback to be called when the retry occurs.
|
|
26
|
+
* @returns What {@link RpcService.onRetry} returns.
|
|
33
27
|
*/
|
|
34
|
-
|
|
35
|
-
primaryEndpointUrl: string;
|
|
36
|
-
}>): {
|
|
28
|
+
onRetry(listener: Parameters<RpcService['onRetry']>[0]): {
|
|
37
29
|
dispose(): void;
|
|
38
30
|
};
|
|
39
31
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* RPC services in the chain, and all services' underlying circuits have
|
|
43
|
-
* broken.
|
|
44
|
-
*
|
|
45
|
-
* The callback will not be called if a service's circuit breaks but its
|
|
46
|
-
* failover does not. Use `onServiceBreak` if you'd like a lower level of
|
|
47
|
-
* granularity.
|
|
48
|
-
*
|
|
49
|
-
* @param listener - The callback to be called.
|
|
50
|
-
* @returns An object with a `dispose` method which can be used to unregister
|
|
51
|
-
* the callback.
|
|
52
|
-
*/
|
|
53
|
-
onBreak(listener: CockatielEventToEventListenerWithData<RpcService['onBreak'], {
|
|
54
|
-
primaryEndpointUrl: string;
|
|
55
|
-
}>): import("cockatiel").IDisposable;
|
|
56
|
-
/**
|
|
57
|
-
* Calls the provided callback each time when, for *any* of the RPC services
|
|
58
|
-
* in this chain, the maximum number of failed consecutive attempts to receive
|
|
59
|
-
* a 2xx response has been reached and the underlying circuit has broken. A
|
|
60
|
-
* more granular version of `onBreak`.
|
|
32
|
+
* Listens for when any of the RPC services retry the request too many times
|
|
33
|
+
* in a row.
|
|
61
34
|
*
|
|
62
|
-
* @param listener - The callback to be called.
|
|
63
|
-
* @returns
|
|
64
|
-
* the callback.
|
|
35
|
+
* @param listener - The callback to be called when the retry occurs.
|
|
36
|
+
* @returns What {@link RpcService.onBreak} returns.
|
|
65
37
|
*/
|
|
66
|
-
|
|
67
|
-
primaryEndpointUrl: string;
|
|
68
|
-
}>): {
|
|
38
|
+
onBreak(listener: Parameters<RpcService['onBreak']>[0]): {
|
|
69
39
|
dispose(): void;
|
|
70
40
|
};
|
|
71
41
|
/**
|
|
72
|
-
*
|
|
73
|
-
* all requests to RPC services in this chain have responded successfully in a
|
|
74
|
-
* timely fashion, and then one of the two conditions apply:
|
|
42
|
+
* Listens for when any of the RPC services send a slow request.
|
|
75
43
|
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* 2. When a RPC service responds successfully, but the request takes longer
|
|
79
|
-
* than a set number of seconds to complete.
|
|
80
|
-
*
|
|
81
|
-
* Note that the callback will be called even if there are local connectivity
|
|
82
|
-
* issues which prevent requests from being initiated. This is intentional.
|
|
83
|
-
*
|
|
84
|
-
* Also note this callback will only be called if the RPC service chain as a
|
|
85
|
-
* whole is in a "degraded" state, and will then only be called once (e.g., it
|
|
86
|
-
* will not be called if a failover service falls into a degraded state, then
|
|
87
|
-
* the primary comes back online, but it is slow). Use `onServiceDegraded` if
|
|
88
|
-
* you'd like a lower level of granularity.
|
|
89
|
-
*
|
|
90
|
-
* @param listener - The callback to be called.
|
|
91
|
-
* @returns An object with a `dispose` method which can be used to unregister
|
|
92
|
-
* the callback.
|
|
44
|
+
* @param listener - The callback to be called when the retry occurs.
|
|
45
|
+
* @returns What {@link RpcService.onRetry} returns.
|
|
93
46
|
*/
|
|
94
|
-
onDegraded(listener:
|
|
95
|
-
primaryEndpointUrl: string;
|
|
96
|
-
}>): import("cockatiel").IDisposable;
|
|
97
|
-
/**
|
|
98
|
-
* Calls the provided callback each time one of the two conditions apply:
|
|
99
|
-
*
|
|
100
|
-
* 1. When a retriable error is encountered making a request to an RPC
|
|
101
|
-
* service, and the request is retried until a set maximum is reached.
|
|
102
|
-
* 2. When a RPC service responds successfully, but the request takes longer
|
|
103
|
-
* than a set number of seconds to complete.
|
|
104
|
-
*
|
|
105
|
-
* Note that the callback will be called even if there are local connectivity
|
|
106
|
-
* issues which prevent requests from being initiated. This is intentional.
|
|
107
|
-
*
|
|
108
|
-
* This is a more granular version of `onDegraded`. The callback will be
|
|
109
|
-
* called for each slow request to an RPC service. It may also be called again
|
|
110
|
-
* if a failover service falls into a degraded state, then the primary comes
|
|
111
|
-
* back online, but it is slow.
|
|
112
|
-
*
|
|
113
|
-
* @param listener - The callback to be called.
|
|
114
|
-
* @returns An object with a `dispose` method which can be used to unregister
|
|
115
|
-
* the callback.
|
|
116
|
-
*/
|
|
117
|
-
onServiceDegraded(listener: CockatielEventToEventListenerWithData<RpcService['onDegraded'], {
|
|
118
|
-
primaryEndpointUrl: string;
|
|
119
|
-
}>): {
|
|
47
|
+
onDegraded(listener: Parameters<RpcService['onDegraded']>[0]): {
|
|
120
48
|
dispose(): void;
|
|
121
49
|
};
|
|
122
50
|
/**
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
* 1. The first time that a 2xx request is made to any of the RPC services in
|
|
126
|
-
* this chain.
|
|
127
|
-
* 2. When requests to any the failover RPC services in this chain were
|
|
128
|
-
* failing such that they were degraded or their underyling circuits broke,
|
|
129
|
-
* but the first request to the primary succeeds again.
|
|
130
|
-
*
|
|
131
|
-
* Note this callback will only be called if the RPC service chain as a whole
|
|
132
|
-
* is in an "available" state.
|
|
133
|
-
*
|
|
134
|
-
* @param listener - The callback to be called.
|
|
135
|
-
* @returns An object with a `dispose` method which can be used to unregister
|
|
136
|
-
* the callback.
|
|
137
|
-
*/
|
|
138
|
-
onAvailable(listener: CockatielEventToEventListenerWithData<RpcService['onAvailable'], {
|
|
139
|
-
primaryEndpointUrl: string;
|
|
140
|
-
}>): import("cockatiel").IDisposable;
|
|
141
|
-
/**
|
|
142
|
-
* Uses the RPC services in the chain to make a request, using each service
|
|
143
|
-
* after the first as a fallback to the previous one as necessary.
|
|
51
|
+
* Makes a request to the first RPC service in the chain. If this service is
|
|
52
|
+
* down, then the request is forwarded to the next service in the chain, etc.
|
|
144
53
|
*
|
|
145
54
|
* This overload is specifically designed for `eth_getBlockByNumber`, which
|
|
146
55
|
* can return a `result` of `null` despite an expected `Result` being
|
|
@@ -160,8 +69,8 @@ export declare class RpcServiceChain {
|
|
|
160
69
|
method: 'eth_getBlockByNumber';
|
|
161
70
|
}, fetchOptions?: FetchOptions): Promise<JsonRpcResponse<Result> | JsonRpcResponse<null>>;
|
|
162
71
|
/**
|
|
163
|
-
*
|
|
164
|
-
*
|
|
72
|
+
* Makes a request to the first RPC service in the chain. If this service is
|
|
73
|
+
* down, then the request is forwarded to the next service in the chain, etc.
|
|
165
74
|
*
|
|
166
75
|
* This overload is designed for all RPC methods except for
|
|
167
76
|
* `eth_getBlockByNumber`, which are expected to return a `result` of the
|
|
@@ -179,5 +88,4 @@ export declare class RpcServiceChain {
|
|
|
179
88
|
*/
|
|
180
89
|
request<Params extends JsonRpcParams, Result extends Json>(jsonRpcRequest: Readonly<JsonRpcRequest<Params>>, fetchOptions?: FetchOptions): Promise<JsonRpcResponse<Result>>;
|
|
181
90
|
}
|
|
182
|
-
export {};
|
|
183
91
|
//# sourceMappingURL=rpc-service-chain.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-service-chain.d.cts","sourceRoot":"","sources":["../../src/rpc-service/rpc-service-chain.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rpc-service-chain.d.cts","sourceRoot":"","sources":["../../src/rpc-service/rpc-service-chain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,aAAa,EACb,cAAc,EACd,eAAe,EAChB,wBAAwB;AAEzB,OAAO,EAAE,UAAU,EAAE,0BAAsB;AAC3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,0BAAsB;AACvD,OAAO,KAAK,EAAE,qBAAqB,EAAE,sCAAkC;AACvE,OAAO,KAAK,EAAE,YAAY,EAAE,qBAAiB;AAE7C;;;;;GAKG;AACH,qBAAa,eAAgB,YAAW,qBAAqB;;IAG3D;;;;;;OAMG;gBAED,wBAAwB,EAAE,IAAI,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,EAAE;IAKxE;;;;;OAKG;IACH,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;;;IAYtD;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;;;IAYtD;;;;;OAKG;IACH,UAAU,CAAC,QAAQ,EAAE,UAAU,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;;;IAY5D;;;;;;;;;;;;;;;;;OAiBG;IACG,OAAO,CAAC,MAAM,SAAS,aAAa,EAAE,MAAM,SAAS,IAAI,EAC7D,cAAc,EAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,GAAG;QACjD,MAAM,EAAE,sBAAsB,CAAC;KAChC,EACD,YAAY,CAAC,EAAE,YAAY,GAC1B,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IAE3D;;;;;;;;;;;;;;;;;OAiBG;IACG,OAAO,CAAC,MAAM,SAAS,aAAa,EAAE,MAAM,SAAS,IAAI,EAC7D,cAAc,EAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,EAChD,YAAY,CAAC,EAAE,YAAY,GAC1B,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;CAiCpC"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { Json, JsonRpcParams, JsonRpcRequest, JsonRpcResponse } from "@metamask/utils";
|
|
2
2
|
import { RpcService } from "./rpc-service.mjs";
|
|
3
3
|
import type { RpcServiceOptions } from "./rpc-service.mjs";
|
|
4
|
-
import type {
|
|
5
|
-
type
|
|
4
|
+
import type { RpcServiceRequestable } from "./rpc-service-requestable.mjs";
|
|
5
|
+
import type { FetchOptions } from "./shared.mjs";
|
|
6
6
|
/**
|
|
7
|
-
* This class constructs
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* This class constructs a chain of RpcService objects which represent a
|
|
8
|
+
* particular network. The first object in the chain is intended to be the
|
|
9
|
+
* primary way of reaching the network and the remaining objects are used as
|
|
10
|
+
* failovers.
|
|
11
11
|
*/
|
|
12
|
-
export declare class RpcServiceChain {
|
|
12
|
+
export declare class RpcServiceChain implements RpcServiceRequestable {
|
|
13
13
|
#private;
|
|
14
14
|
/**
|
|
15
15
|
* Constructs a new RpcServiceChain object.
|
|
@@ -18,129 +18,38 @@ export declare class RpcServiceChain {
|
|
|
18
18
|
* that you want to construct. Each object in this array is the same as
|
|
19
19
|
* {@link RpcServiceOptions}.
|
|
20
20
|
*/
|
|
21
|
-
constructor(rpcServiceConfigurations: [
|
|
22
|
-
RpcServiceConfiguration,
|
|
23
|
-
...RpcServiceConfiguration[]
|
|
24
|
-
]);
|
|
21
|
+
constructor(rpcServiceConfigurations: Omit<RpcServiceOptions, 'failoverService'>[]);
|
|
25
22
|
/**
|
|
26
|
-
*
|
|
23
|
+
* Listens for when any of the RPC services retry a request.
|
|
27
24
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* @param listener - The callback to be called.
|
|
31
|
-
* @returns An object with a `dispose` method which can be used to unregister
|
|
32
|
-
* the event listener.
|
|
25
|
+
* @param listener - The callback to be called when the retry occurs.
|
|
26
|
+
* @returns What {@link RpcService.onRetry} returns.
|
|
33
27
|
*/
|
|
34
|
-
|
|
35
|
-
primaryEndpointUrl: string;
|
|
36
|
-
}>): {
|
|
28
|
+
onRetry(listener: Parameters<RpcService['onRetry']>[0]): {
|
|
37
29
|
dispose(): void;
|
|
38
30
|
};
|
|
39
31
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* RPC services in the chain, and all services' underlying circuits have
|
|
43
|
-
* broken.
|
|
44
|
-
*
|
|
45
|
-
* The callback will not be called if a service's circuit breaks but its
|
|
46
|
-
* failover does not. Use `onServiceBreak` if you'd like a lower level of
|
|
47
|
-
* granularity.
|
|
48
|
-
*
|
|
49
|
-
* @param listener - The callback to be called.
|
|
50
|
-
* @returns An object with a `dispose` method which can be used to unregister
|
|
51
|
-
* the callback.
|
|
52
|
-
*/
|
|
53
|
-
onBreak(listener: CockatielEventToEventListenerWithData<RpcService['onBreak'], {
|
|
54
|
-
primaryEndpointUrl: string;
|
|
55
|
-
}>): import("cockatiel").IDisposable;
|
|
56
|
-
/**
|
|
57
|
-
* Calls the provided callback each time when, for *any* of the RPC services
|
|
58
|
-
* in this chain, the maximum number of failed consecutive attempts to receive
|
|
59
|
-
* a 2xx response has been reached and the underlying circuit has broken. A
|
|
60
|
-
* more granular version of `onBreak`.
|
|
32
|
+
* Listens for when any of the RPC services retry the request too many times
|
|
33
|
+
* in a row.
|
|
61
34
|
*
|
|
62
|
-
* @param listener - The callback to be called.
|
|
63
|
-
* @returns
|
|
64
|
-
* the callback.
|
|
35
|
+
* @param listener - The callback to be called when the retry occurs.
|
|
36
|
+
* @returns What {@link RpcService.onBreak} returns.
|
|
65
37
|
*/
|
|
66
|
-
|
|
67
|
-
primaryEndpointUrl: string;
|
|
68
|
-
}>): {
|
|
38
|
+
onBreak(listener: Parameters<RpcService['onBreak']>[0]): {
|
|
69
39
|
dispose(): void;
|
|
70
40
|
};
|
|
71
41
|
/**
|
|
72
|
-
*
|
|
73
|
-
* all requests to RPC services in this chain have responded successfully in a
|
|
74
|
-
* timely fashion, and then one of the two conditions apply:
|
|
42
|
+
* Listens for when any of the RPC services send a slow request.
|
|
75
43
|
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* 2. When a RPC service responds successfully, but the request takes longer
|
|
79
|
-
* than a set number of seconds to complete.
|
|
80
|
-
*
|
|
81
|
-
* Note that the callback will be called even if there are local connectivity
|
|
82
|
-
* issues which prevent requests from being initiated. This is intentional.
|
|
83
|
-
*
|
|
84
|
-
* Also note this callback will only be called if the RPC service chain as a
|
|
85
|
-
* whole is in a "degraded" state, and will then only be called once (e.g., it
|
|
86
|
-
* will not be called if a failover service falls into a degraded state, then
|
|
87
|
-
* the primary comes back online, but it is slow). Use `onServiceDegraded` if
|
|
88
|
-
* you'd like a lower level of granularity.
|
|
89
|
-
*
|
|
90
|
-
* @param listener - The callback to be called.
|
|
91
|
-
* @returns An object with a `dispose` method which can be used to unregister
|
|
92
|
-
* the callback.
|
|
44
|
+
* @param listener - The callback to be called when the retry occurs.
|
|
45
|
+
* @returns What {@link RpcService.onRetry} returns.
|
|
93
46
|
*/
|
|
94
|
-
onDegraded(listener:
|
|
95
|
-
primaryEndpointUrl: string;
|
|
96
|
-
}>): import("cockatiel").IDisposable;
|
|
97
|
-
/**
|
|
98
|
-
* Calls the provided callback each time one of the two conditions apply:
|
|
99
|
-
*
|
|
100
|
-
* 1. When a retriable error is encountered making a request to an RPC
|
|
101
|
-
* service, and the request is retried until a set maximum is reached.
|
|
102
|
-
* 2. When a RPC service responds successfully, but the request takes longer
|
|
103
|
-
* than a set number of seconds to complete.
|
|
104
|
-
*
|
|
105
|
-
* Note that the callback will be called even if there are local connectivity
|
|
106
|
-
* issues which prevent requests from being initiated. This is intentional.
|
|
107
|
-
*
|
|
108
|
-
* This is a more granular version of `onDegraded`. The callback will be
|
|
109
|
-
* called for each slow request to an RPC service. It may also be called again
|
|
110
|
-
* if a failover service falls into a degraded state, then the primary comes
|
|
111
|
-
* back online, but it is slow.
|
|
112
|
-
*
|
|
113
|
-
* @param listener - The callback to be called.
|
|
114
|
-
* @returns An object with a `dispose` method which can be used to unregister
|
|
115
|
-
* the callback.
|
|
116
|
-
*/
|
|
117
|
-
onServiceDegraded(listener: CockatielEventToEventListenerWithData<RpcService['onDegraded'], {
|
|
118
|
-
primaryEndpointUrl: string;
|
|
119
|
-
}>): {
|
|
47
|
+
onDegraded(listener: Parameters<RpcService['onDegraded']>[0]): {
|
|
120
48
|
dispose(): void;
|
|
121
49
|
};
|
|
122
50
|
/**
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
* 1. The first time that a 2xx request is made to any of the RPC services in
|
|
126
|
-
* this chain.
|
|
127
|
-
* 2. When requests to any the failover RPC services in this chain were
|
|
128
|
-
* failing such that they were degraded or their underyling circuits broke,
|
|
129
|
-
* but the first request to the primary succeeds again.
|
|
130
|
-
*
|
|
131
|
-
* Note this callback will only be called if the RPC service chain as a whole
|
|
132
|
-
* is in an "available" state.
|
|
133
|
-
*
|
|
134
|
-
* @param listener - The callback to be called.
|
|
135
|
-
* @returns An object with a `dispose` method which can be used to unregister
|
|
136
|
-
* the callback.
|
|
137
|
-
*/
|
|
138
|
-
onAvailable(listener: CockatielEventToEventListenerWithData<RpcService['onAvailable'], {
|
|
139
|
-
primaryEndpointUrl: string;
|
|
140
|
-
}>): import("cockatiel").IDisposable;
|
|
141
|
-
/**
|
|
142
|
-
* Uses the RPC services in the chain to make a request, using each service
|
|
143
|
-
* after the first as a fallback to the previous one as necessary.
|
|
51
|
+
* Makes a request to the first RPC service in the chain. If this service is
|
|
52
|
+
* down, then the request is forwarded to the next service in the chain, etc.
|
|
144
53
|
*
|
|
145
54
|
* This overload is specifically designed for `eth_getBlockByNumber`, which
|
|
146
55
|
* can return a `result` of `null` despite an expected `Result` being
|
|
@@ -160,8 +69,8 @@ export declare class RpcServiceChain {
|
|
|
160
69
|
method: 'eth_getBlockByNumber';
|
|
161
70
|
}, fetchOptions?: FetchOptions): Promise<JsonRpcResponse<Result> | JsonRpcResponse<null>>;
|
|
162
71
|
/**
|
|
163
|
-
*
|
|
164
|
-
*
|
|
72
|
+
* Makes a request to the first RPC service in the chain. If this service is
|
|
73
|
+
* down, then the request is forwarded to the next service in the chain, etc.
|
|
165
74
|
*
|
|
166
75
|
* This overload is designed for all RPC methods except for
|
|
167
76
|
* `eth_getBlockByNumber`, which are expected to return a `result` of the
|
|
@@ -179,5 +88,4 @@ export declare class RpcServiceChain {
|
|
|
179
88
|
*/
|
|
180
89
|
request<Params extends JsonRpcParams, Result extends Json>(jsonRpcRequest: Readonly<JsonRpcRequest<Params>>, fetchOptions?: FetchOptions): Promise<JsonRpcResponse<Result>>;
|
|
181
90
|
}
|
|
182
|
-
export {};
|
|
183
91
|
//# sourceMappingURL=rpc-service-chain.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-service-chain.d.mts","sourceRoot":"","sources":["../../src/rpc-service/rpc-service-chain.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rpc-service-chain.d.mts","sourceRoot":"","sources":["../../src/rpc-service/rpc-service-chain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,aAAa,EACb,cAAc,EACd,eAAe,EAChB,wBAAwB;AAEzB,OAAO,EAAE,UAAU,EAAE,0BAAsB;AAC3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,0BAAsB;AACvD,OAAO,KAAK,EAAE,qBAAqB,EAAE,sCAAkC;AACvE,OAAO,KAAK,EAAE,YAAY,EAAE,qBAAiB;AAE7C;;;;;GAKG;AACH,qBAAa,eAAgB,YAAW,qBAAqB;;IAG3D;;;;;;OAMG;gBAED,wBAAwB,EAAE,IAAI,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,EAAE;IAKxE;;;;;OAKG;IACH,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;;;IAYtD;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;;;IAYtD;;;;;OAKG;IACH,UAAU,CAAC,QAAQ,EAAE,UAAU,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;;;IAY5D;;;;;;;;;;;;;;;;;OAiBG;IACG,OAAO,CAAC,MAAM,SAAS,aAAa,EAAE,MAAM,SAAS,IAAI,EAC7D,cAAc,EAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,GAAG;QACjD,MAAM,EAAE,sBAAsB,CAAC;KAChC,EACD,YAAY,CAAC,EAAE,YAAY,GAC1B,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IAE3D;;;;;;;;;;;;;;;;;OAiBG;IACG,OAAO,CAAC,MAAM,SAAS,aAAa,EAAE,MAAM,SAAS,IAAI,EAC7D,cAAc,EAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,EAChD,YAAY,CAAC,EAAE,YAAY,GAC1B,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;CAiCpC"}
|