@atomiqlabs/chain-evm 1.0.0-dev.58 → 1.0.0-dev.59
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/evm/ReconnectingWebSocketProvider.d.ts +2 -2
- package/dist/evm/ReconnectingWebSocketProvider.js +2 -2
- package/dist/evm/WebSocketProviderWithRetries.d.ts +2 -1
- package/package.json +1 -1
- package/src/evm/ReconnectingWebSocketProvider.ts +4 -4
- package/src/evm/WebSocketProviderWithRetries.ts +2 -1
|
@@ -7,12 +7,12 @@ export declare class ReconnectingWebSocketProvider extends SocketProvider {
|
|
|
7
7
|
pingIntervalSeconds: number;
|
|
8
8
|
pingInterval: any;
|
|
9
9
|
reconnectTimer: any;
|
|
10
|
-
|
|
10
|
+
wsCtor: () => WebSocketLike;
|
|
11
11
|
websocket: null | (WebSocketLike & {
|
|
12
12
|
onclose?: (...args: any[]) => void;
|
|
13
13
|
ping?: () => void;
|
|
14
14
|
});
|
|
15
|
-
constructor(url: string, network?: Networkish, options?: JsonRpcApiProviderOptions);
|
|
15
|
+
constructor(url: string | (() => WebSocketLike), network?: Networkish, options?: JsonRpcApiProviderOptions);
|
|
16
16
|
private connect;
|
|
17
17
|
private disconnectedAndScheduleReconnect;
|
|
18
18
|
_write(message: string): Promise<void>;
|
|
@@ -8,11 +8,11 @@ class ReconnectingWebSocketProvider extends SocketProvider_1.SocketProvider {
|
|
|
8
8
|
this.requestTimeoutSeconds = 10;
|
|
9
9
|
this.reconnectSeconds = 5;
|
|
10
10
|
this.pingIntervalSeconds = 30;
|
|
11
|
-
this.
|
|
11
|
+
this.wsCtor = typeof (url) === "string" ? () => new WebSocket(url) : url;
|
|
12
12
|
this.connect();
|
|
13
13
|
}
|
|
14
14
|
connect() {
|
|
15
|
-
this.websocket =
|
|
15
|
+
this.websocket = this.wsCtor();
|
|
16
16
|
this.websocket.onopen = () => {
|
|
17
17
|
this._connected();
|
|
18
18
|
this._start();
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { JsonRpcApiProviderOptions } from "ethers";
|
|
2
2
|
import type { Networkish } from "ethers";
|
|
3
3
|
import { ReconnectingWebSocketProvider } from "./ReconnectingWebSocketProvider";
|
|
4
|
+
import type { WebSocketLike } from "ethers/lib.esm";
|
|
4
5
|
export declare class WebSocketProviderWithRetries extends ReconnectingWebSocketProvider {
|
|
5
6
|
readonly retryPolicy?: {
|
|
6
7
|
maxRetries?: number;
|
|
7
8
|
delay?: number;
|
|
8
9
|
exponential?: boolean;
|
|
9
10
|
};
|
|
10
|
-
constructor(url: string, network?: Networkish, options?: JsonRpcApiProviderOptions & {
|
|
11
|
+
constructor(url: string | (() => WebSocketLike), network?: Networkish, options?: JsonRpcApiProviderOptions & {
|
|
11
12
|
maxRetries?: number;
|
|
12
13
|
delay?: number;
|
|
13
14
|
exponential?: boolean;
|
package/package.json
CHANGED
|
@@ -12,17 +12,17 @@ export class ReconnectingWebSocketProvider extends SocketProvider {
|
|
|
12
12
|
pingInterval: any;
|
|
13
13
|
reconnectTimer: any;
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
wsCtor: () => WebSocketLike;
|
|
16
16
|
websocket: null | WebSocketLike & {onclose?: (...args: any[]) => void, ping?: () => void};
|
|
17
17
|
|
|
18
|
-
constructor(url: string, network?: Networkish, options?: JsonRpcApiProviderOptions) {
|
|
18
|
+
constructor(url: string | (() => WebSocketLike), network?: Networkish, options?: JsonRpcApiProviderOptions) {
|
|
19
19
|
super(network, options);
|
|
20
|
-
this.
|
|
20
|
+
this.wsCtor = typeof(url)==="string" ? () => new WebSocket(url) : url;
|
|
21
21
|
this.connect();
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
private connect() {
|
|
25
|
-
this.websocket =
|
|
25
|
+
this.websocket = this.wsCtor();
|
|
26
26
|
|
|
27
27
|
this.websocket.onopen = () => {
|
|
28
28
|
this._connected();
|
|
@@ -2,6 +2,7 @@ import {JsonRpcApiProviderOptions} from "ethers";
|
|
|
2
2
|
import type {Networkish} from "ethers";
|
|
3
3
|
import {tryWithRetries} from "../utils/Utils";
|
|
4
4
|
import {ReconnectingWebSocketProvider} from "./ReconnectingWebSocketProvider";
|
|
5
|
+
import type {WebSocketLike} from "ethers/lib.esm";
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
export class WebSocketProviderWithRetries extends ReconnectingWebSocketProvider {
|
|
@@ -10,7 +11,7 @@ export class WebSocketProviderWithRetries extends ReconnectingWebSocketProvider
|
|
|
10
11
|
maxRetries?: number, delay?: number, exponential?: boolean
|
|
11
12
|
};
|
|
12
13
|
|
|
13
|
-
constructor(url: string, network?: Networkish, options?: JsonRpcApiProviderOptions & {
|
|
14
|
+
constructor(url: string | (() => WebSocketLike), network?: Networkish, options?: JsonRpcApiProviderOptions & {
|
|
14
15
|
maxRetries?: number, delay?: number, exponential?: boolean
|
|
15
16
|
}) {
|
|
16
17
|
super(url, network, options);
|