@atomiqlabs/chain-evm 1.0.0-dev.42 → 1.0.0-dev.44
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/JsonRpcProviderWithRetries.d.ts +15 -0
- package/dist/evm/JsonRpcProviderWithRetries.js +19 -0
- package/dist/evm/chain/modules/EVMTransactions.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
- package/src/evm/JsonRpcProviderWithRetries.ts +26 -0
- package/src/evm/chain/modules/EVMTransactions.ts +1 -1
- package/src/index.ts +2 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { JsonRpcProvider, JsonRpcApiProviderOptions } from "ethers";
|
|
2
|
+
import type { Networkish, FetchRequest } from "ethers";
|
|
3
|
+
export declare class JsonRpcProviderWithRetries extends JsonRpcProvider {
|
|
4
|
+
readonly retryPolicy?: {
|
|
5
|
+
maxRetries?: number;
|
|
6
|
+
delay?: number;
|
|
7
|
+
exponential?: boolean;
|
|
8
|
+
};
|
|
9
|
+
constructor(url?: string | FetchRequest, network?: Networkish, options?: JsonRpcApiProviderOptions & {
|
|
10
|
+
maxRetries?: number;
|
|
11
|
+
delay?: number;
|
|
12
|
+
exponential?: boolean;
|
|
13
|
+
});
|
|
14
|
+
send(method: string, params: Array<any> | Record<string, any>): Promise<any>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JsonRpcProviderWithRetries = void 0;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
const Utils_1 = require("../utils/Utils");
|
|
6
|
+
class JsonRpcProviderWithRetries extends ethers_1.JsonRpcProvider {
|
|
7
|
+
constructor(url, network, options) {
|
|
8
|
+
super(url, network, options);
|
|
9
|
+
this.retryPolicy = options;
|
|
10
|
+
}
|
|
11
|
+
send(method, params) {
|
|
12
|
+
return (0, Utils_1.tryWithRetries)(() => super.send(method, params), this.retryPolicy, e => {
|
|
13
|
+
if (e?.error?.code != null)
|
|
14
|
+
return false; //Error returned by the RPC
|
|
15
|
+
return true;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.JsonRpcProviderWithRetries = JsonRpcProviderWithRetries;
|
|
@@ -198,7 +198,7 @@ class EVMTransactions extends EVMModule_1.EVMModule {
|
|
|
198
198
|
this.root.config.safeBlockTag === "latest" ? Promise.resolve(null) : this.provider.getBlock(this.root.config.safeBlockTag).then(res => res.number),
|
|
199
199
|
this.provider.getTransactionReceipt(txId)
|
|
200
200
|
]);
|
|
201
|
-
if (txReceipt == null || (safeBlockNumber != null && txReceipt.blockNumber
|
|
201
|
+
if (txReceipt == null || (safeBlockNumber != null && txReceipt.blockNumber > safeBlockNumber))
|
|
202
202
|
return "pending";
|
|
203
203
|
if (txReceipt.status === 0)
|
|
204
204
|
return "reverted";
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -54,3 +54,4 @@ __exportStar(require("./chains/citrea/CitreaChainType"), exports);
|
|
|
54
54
|
__exportStar(require("./chains/citrea/CitreaFees"), exports);
|
|
55
55
|
__exportStar(require("./chains/botanix/BotanixInitializer"), exports);
|
|
56
56
|
__exportStar(require("./chains/botanix/BotanixChainType"), exports);
|
|
57
|
+
__exportStar(require("./evm/JsonRpcProviderWithRetries"), exports);
|
package/package.json
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {JsonRpcProvider, JsonRpcApiProviderOptions} from "ethers";
|
|
2
|
+
import type {Networkish, FetchRequest} from "ethers";
|
|
3
|
+
import {tryWithRetries} from "../utils/Utils";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export class JsonRpcProviderWithRetries extends JsonRpcProvider {
|
|
7
|
+
|
|
8
|
+
readonly retryPolicy?: {
|
|
9
|
+
maxRetries?: number, delay?: number, exponential?: boolean
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
constructor(url?: string | FetchRequest, network?: Networkish, options?: JsonRpcApiProviderOptions & {
|
|
13
|
+
maxRetries?: number, delay?: number, exponential?: boolean
|
|
14
|
+
}) {
|
|
15
|
+
super(url, network, options);
|
|
16
|
+
this.retryPolicy = options;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
send(method: string, params: Array<any> | Record<string, any>): Promise<any> {
|
|
20
|
+
return tryWithRetries(() => super.send(method, params), this.retryPolicy, e => {
|
|
21
|
+
if(e?.error?.code!=null) return false; //Error returned by the RPC
|
|
22
|
+
return true;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
}
|
|
@@ -222,7 +222,7 @@ export class EVMTransactions extends EVMModule<any> {
|
|
|
222
222
|
this.provider.getTransactionReceipt(txId)
|
|
223
223
|
]);
|
|
224
224
|
|
|
225
|
-
if(txReceipt==null || (safeBlockNumber!=null && txReceipt.blockNumber
|
|
225
|
+
if(txReceipt==null || (safeBlockNumber!=null && txReceipt.blockNumber > safeBlockNumber)) return "pending";
|
|
226
226
|
if(txReceipt.status===0) return "reverted";
|
|
227
227
|
return "success";
|
|
228
228
|
}
|