@tetherto/wdk-wallet-evm 1.0.0-beta.26 → 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.26",
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": [
@@ -33,7 +33,7 @@
33
33
  "@noble/hashes": "1.8.0",
34
34
  "@noble/secp256k1": "2.2.3",
35
35
  "@tetherto/wdk-failover-provider": "1.0.0-beta.2",
36
- "@tetherto/wdk-wallet": "1.0.0-beta.25",
36
+ "@tetherto/wdk-wallet": "1.0.0-beta.26",
37
37
  "bare-node-runtime": "^1.5.2",
38
38
  "bip39": "3.1.0",
39
39
  "ethers": "6.17.0",
@@ -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,
@@ -108,7 +108,7 @@ export default class WalletAccountReadOnlyEvm extends WalletAccountReadOnly {
108
108
  * @param {Omit<EvmWalletConfig, 'transferMaxFee' | 'transactionMaxFee'>} [config] - The configuration object.
109
109
  */
110
110
  constructor (address, config = { }) {
111
- super(address)
111
+ super(address, config)
112
112
 
113
113
  /**
114
114
  * The read-only wallet account configuration.
@@ -234,7 +234,11 @@ export default class WalletManagerEvm extends WalletManager {
234
234
  }
235
235
 
236
236
  /**
237
- * Disposes all the wallet accounts, erasing their private keys from the memory.
237
+ * Disposes the wallet accounts, erasing their private keys from memory, and the default
238
+ * signer if the manager created it from a seed. Signers you supplied are never disposed, so
239
+ * an account created directly on one with getAccount(signerName) keeps its key. The seed you
240
+ * passed in is never wiped (a seed phrase string stays in memory until it is garbage
241
+ * collected).
238
242
  */
239
243
  dispose () {
240
244
  if (this._shouldWipeDefaultSignerOnDisposal) {
@@ -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.
@@ -115,10 +115,11 @@ export default class WalletManagerEvm extends WalletManager<ISignerEvm> {
115
115
  */
116
116
  getFeeRates(): Promise<FeeRates>;
117
117
  /**
118
- * Disposes all the wallet accounts, erasing their private keys from the memory. If the
119
- * manager was created from a seed, the internally created default signer is wiped too;
120
- * a default signer supplied at construction is left untouched, as are signers registered
121
- * via {@link addSigner}.
118
+ * Disposes the wallet accounts, erasing their private keys from memory, and the default
119
+ * signer if the manager created it from a seed. Signers you supplied are never disposed, so
120
+ * an account created directly on one with getAccount(signerName) keeps its key. The seed
121
+ * you passed in is never wiped (a seed phrase string stays in memory until it is garbage
122
+ * collected).
122
123
  */
123
124
  dispose(): void;
124
125
  }