@tetherto/wdk-wallet-evm 1.0.0-beta.27 → 1.0.0-beta.28

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tetherto/wdk-wallet-evm",
3
- "version": "1.0.0-beta.27",
3
+ "version": "1.0.0-beta.28",
4
4
  "description": "EVM wallet module for WDK (Wallet Development Kit) by Tether.",
5
5
  "homepage": "https://docs.wdk.tether.io/sdk/wallet-modules/wallet-evm/",
6
6
  "keywords": [
@@ -291,6 +291,13 @@ export default class WalletAccountEvm extends WalletAccountReadOnlyEvm {
291
291
  return BigInt(tx.gasLimit) * BigInt(tx.maxFeePerGas ?? tx.gasPrice)
292
292
  }
293
293
 
294
+ /** @private */
295
+ async _getPendingNonce (address) {
296
+ // A raw call, because provider.getTransactionCount goes through the ethers read cache (250ms by default).
297
+ const nonce = await this._provider.send('eth_getTransactionCount', [address, 'pending'])
298
+ return Number(nonce)
299
+ }
300
+
294
301
  /** @private */
295
302
  async _sendPopulated (tx, maxFee, maxFeeExceededErrorMessage) {
296
303
  WalletAccountReadOnlyEvm._validateFeeFields(tx)
@@ -299,8 +306,10 @@ export default class WalletAccountEvm extends WalletAccountReadOnlyEvm {
299
306
 
300
307
  const gasLimit = await this._estimateGas({ from: address, ...tx })
301
308
 
309
+ const nonce = tx.nonce ?? await this._getPendingNonce(address)
310
+
302
311
  const voidSigner = new VoidSigner(address, this._provider)
303
- const populated = await voidSigner.populateTransaction({ ...tx, gasLimit: tx.gasLimit ?? gasLimit })
312
+ const populated = await voidSigner.populateTransaction({ ...tx, nonce, gasLimit: tx.gasLimit ?? gasLimit })
304
313
  const fee = WalletAccountEvm._getMaxFee(populated)
305
314
 
306
315
  this._assertMaxFee(fee, maxFee, maxFeeExceededErrorMessage)
@@ -463,7 +472,7 @@ export default class WalletAccountEvm extends WalletAccountReadOnlyEvm {
463
472
  }
464
473
  if (populated.nonce == null) {
465
474
  const address = await this.getAddress()
466
- populated.nonce = await this._provider.getTransactionCount(address, 'pending')
475
+ populated.nonce = await this._getPendingNonce(address)
467
476
  }
468
477
  }
469
478
  return await this._signer.signAuthorization(populated)
@@ -507,8 +516,7 @@ export default class WalletAccountEvm extends WalletAccountReadOnlyEvm {
507
516
  }
508
517
  }
509
518
 
510
- const nonceHex = await this._provider.send('eth_getTransactionCount', [address, 'pending'])
511
- const nonce = Number(nonceHex)
519
+ const nonce = await this._getPendingNonce(address)
512
520
 
513
521
  const auth = await this.signAuthorization({
514
522
  address: delegateAddress,
@@ -129,6 +129,8 @@ export default class WalletAccountEvm extends WalletAccountReadOnlyEvm implement
129
129
  /** @private */
130
130
  private _assertMaxFee;
131
131
  /** @private */
132
+ private _getPendingNonce;
133
+ /** @private */
132
134
  private _sendPopulated;
133
135
  /**
134
136
  * Quotes the costs of a send transaction operation.