@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.
@@ -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.getBlockNumber().catch(e => {
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, WebSocketProvider } from "ethers";
2
- import type { Networkish, WebSocketCreator, WebSocketLike } from "ethers";
3
- export declare class WebSocketProviderWithRetries extends WebSocketProvider {
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 | WebSocketLike | WebSocketCreator, network?: Networkish, options?: JsonRpcApiProviderOptions & {
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
- class WebSocketProviderWithRetries extends ethers_1.WebSocketProvider {
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atomiqlabs/chain-evm",
3
- "version": "1.0.0-dev.56",
3
+ "version": "1.0.0-dev.58",
4
4
  "description": "EVM specific base implementation",
5
5
  "main": "./dist/index.js",
6
6
  "types:": "./dist/index.d.ts",
@@ -29,7 +29,7 @@ export class ReconnectingWebSocketProvider extends SocketProvider {
29
29
  this._start();
30
30
 
31
31
  this.pingInterval = setInterval(() => {
32
- this.getBlockNumber().catch(e => {
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, WebSocketProvider} from "ethers";
2
- import type {Networkish, WebSocketCreator, WebSocketLike} from "ethers";
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 WebSocketProvider {
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 | WebSocketLike | WebSocketCreator, network?: Networkish, options?: JsonRpcApiProviderOptions & {
13
+ constructor(url: string, network?: Networkish, options?: JsonRpcApiProviderOptions & {
13
14
  maxRetries?: number, delay?: number, exponential?: boolean
14
15
  }) {
15
16
  super(url, network, options);