@atomiqlabs/chain-evm 1.0.0-dev.83 → 1.0.0-dev.85
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 +6 -6
- package/dist/evm/providers/WebSocketProviderWithRetries.js +6 -6
- package/dist/evm/wallet/EVMPersistentSigner.js +5 -3
- package/package.json +1 -1
- package/src/evm/providers/JsonRpcProviderWithRetries.ts +3 -3
- package/src/evm/providers/WebSocketProviderWithRetries.ts +3 -3
- package/src/evm/wallet/EVMPersistentSigner.ts +5 -3
|
@@ -14,12 +14,12 @@ class JsonRpcProviderWithRetries extends ethers_1.JsonRpcProvider {
|
|
|
14
14
|
}
|
|
15
15
|
send(method, params) {
|
|
16
16
|
return (0, Utils_1.tryWithRetries)(() => super.send(method, params), this.retryPolicy, e => {
|
|
17
|
-
if (e.code != null && typeof (e.code) === "string")
|
|
18
|
-
return
|
|
19
|
-
if (e.error?.code != null && typeof (e.error.code) === "number")
|
|
20
|
-
return
|
|
21
|
-
if (e.error?.message != null && typeof (e.error.message) === "string")
|
|
22
|
-
return
|
|
17
|
+
if (e.code != null && typeof (e.code) === "string" && Utils_1.allowedEthersErrorCodes.has(e.code))
|
|
18
|
+
return true;
|
|
19
|
+
if (e.error?.code != null && typeof (e.error.code) === "number" && Utils_1.allowedEthersErrorNumbers.has(e.error.code))
|
|
20
|
+
return true;
|
|
21
|
+
if (e.error?.message != null && typeof (e.error.message) === "string" && Utils_1.allowedEthersErrorMessages.has(e.error.message))
|
|
22
|
+
return true;
|
|
23
23
|
return false;
|
|
24
24
|
});
|
|
25
25
|
}
|
|
@@ -10,12 +10,12 @@ class WebSocketProviderWithRetries extends ReconnectingWebSocketProvider_1.Recon
|
|
|
10
10
|
}
|
|
11
11
|
send(method, params) {
|
|
12
12
|
return (0, Utils_1.tryWithRetries)(() => super.send(method, params), this.retryPolicy, e => {
|
|
13
|
-
if (e.code != null && typeof (e.code) === "string")
|
|
14
|
-
return
|
|
15
|
-
if (e.error?.code != null && typeof (e.error.code) === "number")
|
|
16
|
-
return
|
|
17
|
-
if (e.error?.message != null && typeof (e.error.message) === "string")
|
|
18
|
-
return
|
|
13
|
+
if (e.code != null && typeof (e.code) === "string" && Utils_1.allowedEthersErrorCodes.has(e.code))
|
|
14
|
+
return true;
|
|
15
|
+
if (e.error?.code != null && typeof (e.error.code) === "number" && Utils_1.allowedEthersErrorNumbers.has(e.error.code))
|
|
16
|
+
return true;
|
|
17
|
+
if (e.error?.message != null && typeof (e.error.message) === "string" && Utils_1.allowedEthersErrorMessages.has(e.error.message))
|
|
18
|
+
return true;
|
|
19
19
|
return false;
|
|
20
20
|
});
|
|
21
21
|
}
|
|
@@ -105,6 +105,7 @@ class EVMPersistentSigner extends EVMSigner_1.EVMSigner {
|
|
|
105
105
|
return;
|
|
106
106
|
this.logger.error("checkPastTransactions(): Tx re-broadcast error", e);
|
|
107
107
|
});
|
|
108
|
+
data.lastBumped = Date.now();
|
|
108
109
|
continue;
|
|
109
110
|
}
|
|
110
111
|
let newTx = lastTx.clone();
|
|
@@ -176,11 +177,9 @@ class EVMPersistentSigner extends EVMSigner_1.EVMSigner {
|
|
|
176
177
|
if (transaction.nonce != null) {
|
|
177
178
|
if (transaction.nonce !== this.pendingNonce + 1)
|
|
178
179
|
throw new Error("Invalid transaction nonce!");
|
|
179
|
-
this.pendingNonce++;
|
|
180
180
|
}
|
|
181
181
|
else {
|
|
182
|
-
this.pendingNonce
|
|
183
|
-
transaction.nonce = this.pendingNonce;
|
|
182
|
+
transaction.nonce = this.pendingNonce + 1;
|
|
184
183
|
}
|
|
185
184
|
const tx = {};
|
|
186
185
|
for (let key in transaction) {
|
|
@@ -202,6 +201,8 @@ class EVMPersistentSigner extends EVMSigner_1.EVMSigner {
|
|
|
202
201
|
}
|
|
203
202
|
}
|
|
204
203
|
const pendingTxObject = { txs: [signedTx], lastBumped: Date.now(), sending: true };
|
|
204
|
+
this.pendingNonce++;
|
|
205
|
+
this.logger.debug("sendTransaction(): Incrementing pending nonce to: ", this.pendingNonce);
|
|
205
206
|
this.pendingTxs.set(transaction.nonce, pendingTxObject);
|
|
206
207
|
this.save();
|
|
207
208
|
this.chainInterface.Transactions._knownTxSet.add(signedTx.hash);
|
|
@@ -214,6 +215,7 @@ class EVMPersistentSigner extends EVMSigner_1.EVMSigner {
|
|
|
214
215
|
this.chainInterface.Transactions._knownTxSet.delete(signedTx.hash);
|
|
215
216
|
this.pendingTxs.delete(transaction.nonce);
|
|
216
217
|
this.pendingNonce--;
|
|
218
|
+
this.logger.debug("sendTransaction(): Error when broadcasting transaction, reverting pending nonce to: ", this.pendingNonce);
|
|
217
219
|
throw e;
|
|
218
220
|
}
|
|
219
221
|
});
|
package/package.json
CHANGED
|
@@ -24,9 +24,9 @@ export class JsonRpcProviderWithRetries extends JsonRpcProvider {
|
|
|
24
24
|
|
|
25
25
|
send(method: string, params: Array<any> | Record<string, any>): Promise<any> {
|
|
26
26
|
return tryWithRetries(() => super.send(method, params), this.retryPolicy, e => {
|
|
27
|
-
if(e.code!=null && typeof(e.code)==="string"
|
|
28
|
-
if(e.error?.code!=null && typeof(e.error.code)==="number"
|
|
29
|
-
if(e.error?.message!=null && typeof(e.error.message)==="string"
|
|
27
|
+
if(e.code!=null && typeof(e.code)==="string" && allowedEthersErrorCodes.has(e.code)) return true;
|
|
28
|
+
if(e.error?.code!=null && typeof(e.error.code)==="number" && allowedEthersErrorNumbers.has(e.error.code)) return true;
|
|
29
|
+
if(e.error?.message!=null && typeof(e.error.message)==="string" && allowedEthersErrorMessages.has(e.error.message)) return true;
|
|
30
30
|
return false;
|
|
31
31
|
});
|
|
32
32
|
}
|
|
@@ -25,9 +25,9 @@ export class WebSocketProviderWithRetries extends ReconnectingWebSocketProvider
|
|
|
25
25
|
|
|
26
26
|
send(method: string, params: Array<any> | Record<string, any>): Promise<any> {
|
|
27
27
|
return tryWithRetries(() => super.send(method, params), this.retryPolicy, e => {
|
|
28
|
-
if(e.code!=null && typeof(e.code)==="string"
|
|
29
|
-
if(e.error?.code!=null && typeof(e.error.code)==="number"
|
|
30
|
-
if(e.error?.message!=null && typeof(e.error.message)==="string"
|
|
28
|
+
if(e.code!=null && typeof(e.code)==="string" && allowedEthersErrorCodes.has(e.code)) return true;
|
|
29
|
+
if(e.error?.code!=null && typeof(e.error.code)==="number" && allowedEthersErrorNumbers.has(e.error.code)) return true;
|
|
30
|
+
if(e.error?.message!=null && typeof(e.error.message)==="string" && allowedEthersErrorMessages.has(e.error.message)) return true;
|
|
31
31
|
return false;
|
|
32
32
|
});
|
|
33
33
|
}
|
|
@@ -166,6 +166,7 @@ export class EVMPersistentSigner extends EVMSigner {
|
|
|
166
166
|
if(e.code==="NONCE_EXPIRED") return;
|
|
167
167
|
this.logger.error("checkPastTransactions(): Tx re-broadcast error", e)
|
|
168
168
|
});
|
|
169
|
+
data.lastBumped = Date.now();
|
|
169
170
|
continue;
|
|
170
171
|
}
|
|
171
172
|
|
|
@@ -250,10 +251,8 @@ export class EVMPersistentSigner extends EVMSigner {
|
|
|
250
251
|
if(transaction.nonce!=null) {
|
|
251
252
|
if(transaction.nonce !== this.pendingNonce + 1)
|
|
252
253
|
throw new Error("Invalid transaction nonce!");
|
|
253
|
-
this.pendingNonce++;
|
|
254
254
|
} else {
|
|
255
|
-
this.pendingNonce
|
|
256
|
-
transaction.nonce = this.pendingNonce;
|
|
255
|
+
transaction.nonce = this.pendingNonce + 1;
|
|
257
256
|
}
|
|
258
257
|
|
|
259
258
|
const tx: TransactionRequest = {};
|
|
@@ -277,6 +276,8 @@ export class EVMPersistentSigner extends EVMSigner {
|
|
|
277
276
|
}
|
|
278
277
|
|
|
279
278
|
const pendingTxObject = {txs: [signedTx], lastBumped: Date.now(), sending: true};
|
|
279
|
+
this.pendingNonce++;
|
|
280
|
+
this.logger.debug("sendTransaction(): Incrementing pending nonce to: ", this.pendingNonce);
|
|
280
281
|
this.pendingTxs.set(transaction.nonce, pendingTxObject);
|
|
281
282
|
this.save();
|
|
282
283
|
|
|
@@ -290,6 +291,7 @@ export class EVMPersistentSigner extends EVMSigner {
|
|
|
290
291
|
this.chainInterface.Transactions._knownTxSet.delete(signedTx.hash);
|
|
291
292
|
this.pendingTxs.delete(transaction.nonce);
|
|
292
293
|
this.pendingNonce--;
|
|
294
|
+
this.logger.debug("sendTransaction(): Error when broadcasting transaction, reverting pending nonce to: ", this.pendingNonce);
|
|
293
295
|
throw e;
|
|
294
296
|
}
|
|
295
297
|
});
|