@atomiqlabs/chain-evm 1.0.0-dev.56 → 1.0.0-dev.58
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.js +5 -1
- package/dist/evm/WebSocketProviderWithRetries.d.ts +5 -4
- package/dist/evm/WebSocketProviderWithRetries.js +2 -2
- package/package.json +1 -1
- package/src/evm/ReconnectingWebSocketProvider.ts +5 -1
- package/src/evm/WebSocketProviderWithRetries.ts +5 -4
|
@@ -17,7 +17,7 @@ class ReconnectingWebSocketProvider extends SocketProvider_1.SocketProvider {
|
|
|
17
17
|
this._connected();
|
|
18
18
|
this._start();
|
|
19
19
|
this.pingInterval = setInterval(() => {
|
|
20
|
-
this.
|
|
20
|
+
this._send({ method: "eth_blockNumber", params: [], id: 1000000000, jsonrpc: "2.0" }).catch(e => {
|
|
21
21
|
//Error
|
|
22
22
|
if (e.code === "NETWORK_ERROR") {
|
|
23
23
|
console.error("Websocket ping error: ", e);
|
|
@@ -46,6 +46,10 @@ class ReconnectingWebSocketProvider extends SocketProvider_1.SocketProvider {
|
|
|
46
46
|
return;
|
|
47
47
|
if (this.websocket == null)
|
|
48
48
|
return;
|
|
49
|
+
this.websocket.onclose = null;
|
|
50
|
+
this.websocket.onerror = null;
|
|
51
|
+
this.websocket.onmessage = null;
|
|
52
|
+
this.websocket.onopen = null;
|
|
49
53
|
this.websocket = null;
|
|
50
54
|
if (this.pingInterval != null)
|
|
51
55
|
clearInterval(this.pingInterval);
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { JsonRpcApiProviderOptions
|
|
2
|
-
import type { Networkish
|
|
3
|
-
|
|
1
|
+
import { JsonRpcApiProviderOptions } from "ethers";
|
|
2
|
+
import type { Networkish } from "ethers";
|
|
3
|
+
import { ReconnectingWebSocketProvider } from "./ReconnectingWebSocketProvider";
|
|
4
|
+
export declare class WebSocketProviderWithRetries extends ReconnectingWebSocketProvider {
|
|
4
5
|
readonly retryPolicy?: {
|
|
5
6
|
maxRetries?: number;
|
|
6
7
|
delay?: number;
|
|
7
8
|
exponential?: boolean;
|
|
8
9
|
};
|
|
9
|
-
constructor(url: string
|
|
10
|
+
constructor(url: string, network?: Networkish, options?: JsonRpcApiProviderOptions & {
|
|
10
11
|
maxRetries?: number;
|
|
11
12
|
delay?: number;
|
|
12
13
|
exponential?: boolean;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WebSocketProviderWithRetries = void 0;
|
|
4
|
-
const ethers_1 = require("ethers");
|
|
5
4
|
const Utils_1 = require("../utils/Utils");
|
|
6
|
-
|
|
5
|
+
const ReconnectingWebSocketProvider_1 = require("./ReconnectingWebSocketProvider");
|
|
6
|
+
class WebSocketProviderWithRetries extends ReconnectingWebSocketProvider_1.ReconnectingWebSocketProvider {
|
|
7
7
|
constructor(url, network, options) {
|
|
8
8
|
super(url, network, options);
|
|
9
9
|
this.retryPolicy = options;
|
package/package.json
CHANGED
|
@@ -29,7 +29,7 @@ export class ReconnectingWebSocketProvider extends SocketProvider {
|
|
|
29
29
|
this._start();
|
|
30
30
|
|
|
31
31
|
this.pingInterval = setInterval(() => {
|
|
32
|
-
this.
|
|
32
|
+
this._send({method: "eth_blockNumber", params: [], id: 1_000_000_000, jsonrpc: "2.0"}).catch(e => {
|
|
33
33
|
//Error
|
|
34
34
|
if(e.code==="NETWORK_ERROR") {
|
|
35
35
|
console.error("Websocket ping error: ", e);
|
|
@@ -60,6 +60,10 @@ export class ReconnectingWebSocketProvider extends SocketProvider {
|
|
|
60
60
|
private disconnectedAndScheduleReconnect() {
|
|
61
61
|
if(this.destroyed) return;
|
|
62
62
|
if(this.websocket==null) return;
|
|
63
|
+
this.websocket.onclose = null;
|
|
64
|
+
this.websocket.onerror = null;
|
|
65
|
+
this.websocket.onmessage = null;
|
|
66
|
+
this.websocket.onopen = null;
|
|
63
67
|
this.websocket = null;
|
|
64
68
|
if(this.pingInterval!=null) clearInterval(this.pingInterval);
|
|
65
69
|
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import {JsonRpcApiProviderOptions
|
|
2
|
-
import type {Networkish
|
|
1
|
+
import {JsonRpcApiProviderOptions} from "ethers";
|
|
2
|
+
import type {Networkish} from "ethers";
|
|
3
3
|
import {tryWithRetries} from "../utils/Utils";
|
|
4
|
+
import {ReconnectingWebSocketProvider} from "./ReconnectingWebSocketProvider";
|
|
4
5
|
|
|
5
6
|
|
|
6
|
-
export class WebSocketProviderWithRetries extends
|
|
7
|
+
export class WebSocketProviderWithRetries extends ReconnectingWebSocketProvider {
|
|
7
8
|
|
|
8
9
|
readonly retryPolicy?: {
|
|
9
10
|
maxRetries?: number, delay?: number, exponential?: boolean
|
|
10
11
|
};
|
|
11
12
|
|
|
12
|
-
constructor(url: string
|
|
13
|
+
constructor(url: string, network?: Networkish, options?: JsonRpcApiProviderOptions & {
|
|
13
14
|
maxRetries?: number, delay?: number, exponential?: boolean
|
|
14
15
|
}) {
|
|
15
16
|
super(url, network, options);
|