@atomiqlabs/chain-evm 1.0.0-dev.82 → 1.0.0-dev.83
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/providers/JsonRpcProviderWithRetries.js +4 -0
- package/dist/evm/providers/WebSocketProviderWithRetries.js +4 -0
- package/dist/utils/Utils.d.ts +2 -0
- package/dist/utils/Utils.js +18 -1
- package/package.json +1 -1
- package/src/evm/providers/JsonRpcProviderWithRetries.ts +8 -1
- package/src/evm/providers/WebSocketProviderWithRetries.ts +8 -1
- package/src/utils/Utils.ts +19 -0
|
@@ -16,6 +16,10 @@ class JsonRpcProviderWithRetries extends ethers_1.JsonRpcProvider {
|
|
|
16
16
|
return (0, Utils_1.tryWithRetries)(() => super.send(method, params), this.retryPolicy, e => {
|
|
17
17
|
if (e.code != null && typeof (e.code) === "string")
|
|
18
18
|
return Utils_1.allowedEthersErrorCodes.has(e.code);
|
|
19
|
+
if (e.error?.code != null && typeof (e.error.code) === "number")
|
|
20
|
+
return Utils_1.allowedEthersErrorNumbers.has(e.error.code);
|
|
21
|
+
if (e.error?.message != null && typeof (e.error.message) === "string")
|
|
22
|
+
return Utils_1.allowedEthersErrorMessages.has(e.error.message);
|
|
19
23
|
return false;
|
|
20
24
|
});
|
|
21
25
|
}
|
|
@@ -12,6 +12,10 @@ class WebSocketProviderWithRetries extends ReconnectingWebSocketProvider_1.Recon
|
|
|
12
12
|
return (0, Utils_1.tryWithRetries)(() => super.send(method, params), this.retryPolicy, e => {
|
|
13
13
|
if (e.code != null && typeof (e.code) === "string")
|
|
14
14
|
return Utils_1.allowedEthersErrorCodes.has(e.code);
|
|
15
|
+
if (e.error?.code != null && typeof (e.error.code) === "number")
|
|
16
|
+
return Utils_1.allowedEthersErrorNumbers.has(e.error.code);
|
|
17
|
+
if (e.error?.message != null && typeof (e.error.message) === "string")
|
|
18
|
+
return Utils_1.allowedEthersErrorMessages.has(e.error.message);
|
|
15
19
|
return false;
|
|
16
20
|
});
|
|
17
21
|
}
|
package/dist/utils/Utils.d.ts
CHANGED
|
@@ -15,3 +15,5 @@ export declare function tryWithRetries<T>(func: () => Promise<T>, retryPolicy?:
|
|
|
15
15
|
export declare function uint32ReverseEndianness(value: number): number;
|
|
16
16
|
export declare function bigIntMax(a: bigint, b: bigint): bigint;
|
|
17
17
|
export declare const allowedEthersErrorCodes: Set<string>;
|
|
18
|
+
export declare const allowedEthersErrorNumbers: Set<number>;
|
|
19
|
+
export declare const allowedEthersErrorMessages: Set<string>;
|
package/dist/utils/Utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.allowedEthersErrorCodes = exports.bigIntMax = exports.uint32ReverseEndianness = exports.tryWithRetries = exports.getLogger = exports.onceAsync = exports.timeoutPromise = void 0;
|
|
3
|
+
exports.allowedEthersErrorMessages = exports.allowedEthersErrorNumbers = exports.allowedEthersErrorCodes = exports.bigIntMax = exports.uint32ReverseEndianness = exports.tryWithRetries = exports.getLogger = exports.onceAsync = exports.timeoutPromise = void 0;
|
|
4
4
|
function timeoutPromise(timeoutMillis, abortSignal) {
|
|
5
5
|
return new Promise((resolve, reject) => {
|
|
6
6
|
const timeout = setTimeout(resolve, timeoutMillis);
|
|
@@ -79,3 +79,20 @@ exports.allowedEthersErrorCodes = new Set([
|
|
|
79
79
|
"INVALID_ARGUMENT", "MISSING_ARGUMENT", "UNEXPECTED_ARGUMENT", "VALUE_MISMATCH",
|
|
80
80
|
"CALL_EXCEPTION", "NONCE_EXPIRED", "REPLACEMENT_UNDERPRICED", "TRANSACTION_REPLACED", "UNCONFIGURED_NAME", "OFFCHAIN_FAULT", "ACTION_REJECTED"
|
|
81
81
|
]);
|
|
82
|
+
exports.allowedEthersErrorNumbers = new Set([
|
|
83
|
+
-32700,
|
|
84
|
+
-32600,
|
|
85
|
+
-32601,
|
|
86
|
+
// -32602, //Invalid params
|
|
87
|
+
// -32603, //Internal error
|
|
88
|
+
-32000,
|
|
89
|
+
// -32001, //Resource not found
|
|
90
|
+
// -32002, //Resource unavailable
|
|
91
|
+
// -32003, //Transaction rejected
|
|
92
|
+
-32004,
|
|
93
|
+
// -32005, //Limit exceeded
|
|
94
|
+
-32006 //JSON-RPC version not supported
|
|
95
|
+
]);
|
|
96
|
+
exports.allowedEthersErrorMessages = new Set([
|
|
97
|
+
"already known"
|
|
98
|
+
]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import {JsonRpcProvider, JsonRpcApiProviderOptions, makeError, JsonRpcPayload, JsonRpcResult} from "ethers";
|
|
2
2
|
import {Networkish, FetchRequest} from "ethers";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
allowedEthersErrorCodes,
|
|
5
|
+
allowedEthersErrorMessages,
|
|
6
|
+
allowedEthersErrorNumbers,
|
|
7
|
+
tryWithRetries
|
|
8
|
+
} from "../../utils/Utils";
|
|
4
9
|
|
|
5
10
|
export class JsonRpcProviderWithRetries extends JsonRpcProvider {
|
|
6
11
|
|
|
@@ -20,6 +25,8 @@ export class JsonRpcProviderWithRetries extends JsonRpcProvider {
|
|
|
20
25
|
send(method: string, params: Array<any> | Record<string, any>): Promise<any> {
|
|
21
26
|
return tryWithRetries(() => super.send(method, params), this.retryPolicy, e => {
|
|
22
27
|
if(e.code!=null && typeof(e.code)==="string") return allowedEthersErrorCodes.has(e.code);
|
|
28
|
+
if(e.error?.code!=null && typeof(e.error.code)==="number") return allowedEthersErrorNumbers.has(e.error.code);
|
|
29
|
+
if(e.error?.message!=null && typeof(e.error.message)==="string") return allowedEthersErrorMessages.has(e.error.message);
|
|
23
30
|
return false;
|
|
24
31
|
});
|
|
25
32
|
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import {JsonRpcApiProviderOptions} from "ethers";
|
|
2
2
|
import type {Networkish} from "ethers";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
allowedEthersErrorCodes,
|
|
5
|
+
allowedEthersErrorMessages,
|
|
6
|
+
allowedEthersErrorNumbers,
|
|
7
|
+
tryWithRetries
|
|
8
|
+
} from "../../utils/Utils";
|
|
4
9
|
import {ReconnectingWebSocketProvider} from "./ReconnectingWebSocketProvider";
|
|
5
10
|
import type {WebSocketLike} from "ethers/lib.esm";
|
|
6
11
|
|
|
@@ -21,6 +26,8 @@ export class WebSocketProviderWithRetries extends ReconnectingWebSocketProvider
|
|
|
21
26
|
send(method: string, params: Array<any> | Record<string, any>): Promise<any> {
|
|
22
27
|
return tryWithRetries(() => super.send(method, params), this.retryPolicy, e => {
|
|
23
28
|
if(e.code!=null && typeof(e.code)==="string") return allowedEthersErrorCodes.has(e.code);
|
|
29
|
+
if(e.error?.code!=null && typeof(e.error.code)==="number") return allowedEthersErrorNumbers.has(e.error.code);
|
|
30
|
+
if(e.error?.message!=null && typeof(e.error.message)==="string") return allowedEthersErrorMessages.has(e.error.message);
|
|
24
31
|
return false;
|
|
25
32
|
});
|
|
26
33
|
}
|
package/src/utils/Utils.ts
CHANGED
|
@@ -90,3 +90,22 @@ export const allowedEthersErrorCodes: Set<string> = new Set([
|
|
|
90
90
|
"INVALID_ARGUMENT", "MISSING_ARGUMENT", "UNEXPECTED_ARGUMENT", "VALUE_MISMATCH",
|
|
91
91
|
"CALL_EXCEPTION", "NONCE_EXPIRED", "REPLACEMENT_UNDERPRICED", "TRANSACTION_REPLACED", "UNCONFIGURED_NAME", "OFFCHAIN_FAULT", "ACTION_REJECTED"
|
|
92
92
|
]);
|
|
93
|
+
|
|
94
|
+
export const allowedEthersErrorNumbers: Set<number> = new Set([
|
|
95
|
+
-32700, //Invalid JSON
|
|
96
|
+
-32600, //Invalid request
|
|
97
|
+
-32601, //Method not found
|
|
98
|
+
// -32602, //Invalid params
|
|
99
|
+
// -32603, //Internal error
|
|
100
|
+
-32000, //Invalid input
|
|
101
|
+
// -32001, //Resource not found
|
|
102
|
+
// -32002, //Resource unavailable
|
|
103
|
+
// -32003, //Transaction rejected
|
|
104
|
+
-32004, //Method not supported
|
|
105
|
+
// -32005, //Limit exceeded
|
|
106
|
+
-32006 //JSON-RPC version not supported
|
|
107
|
+
]);
|
|
108
|
+
|
|
109
|
+
export const allowedEthersErrorMessages: Set<string> = new Set([
|
|
110
|
+
"already known"
|
|
111
|
+
]);
|