From 3b5483d37d432327632957e203e948983981c2e4 Mon Sep 17 00:00:00 2001 From: Eric <5089238+emizzle@users.noreply.github.com> Date: Wed, 16 Oct 2024 20:11:48 +1100 Subject: [PATCH] removes lastSeenNonce Removes lastSeenNonce and updating/decreasing of the nonce, as this is not required if populateTransaction and sendTransaction are async locked. --- ethers/providers/jsonrpc.nim | 2 -- ethers/signer.nim | 20 -------------------- ethers/wallet.nim | 2 -- 3 files changed, 24 deletions(-) diff --git a/ethers/providers/jsonrpc.nim b/ethers/providers/jsonrpc.nim index 63cabdd..b09cf29 100644 --- a/ethers/providers/jsonrpc.nim +++ b/ethers/providers/jsonrpc.nim @@ -260,8 +260,6 @@ method signMessage*(signer: JsonRpcSigner, method sendTransaction*(signer: JsonRpcSigner, transaction: Transaction): Future[TransactionResponse] {.async.} = convertError: - if nonce =? transaction.nonce: - signer.updateNonce(nonce) let client = await signer.provider.client hash = await client.eth_sendTransaction(transaction) diff --git a/ethers/signer.nim b/ethers/signer.nim index 6a22481..fd48aac 100644 --- a/ethers/signer.nim +++ b/ethers/signer.nim @@ -5,7 +5,6 @@ export basics type Signer* = ref object of RootObj - lastSeenNonce: ?UInt256 populateLock: AsyncLock type @@ -75,24 +74,6 @@ template withLock*(signer: Signer, body: untyped) = finally: signer.populateLock.release() - - -method updateNonce*( - signer: Signer, - nonce: UInt256 -) {.base, gcsafe.} = - - without lastSeen =? signer.lastSeenNonce: - signer.lastSeenNonce = some nonce - return - - if nonce > lastSeen: - signer.lastSeenNonce = some nonce - -method decreaseNonce*(signer: Signer) {.base, gcsafe.} = - if lastSeen =? signer.lastSeenNonce and lastSeen > 0: - signer.lastSeenNonce = some lastSeen - 1 - method populateTransaction*(signer: Signer, transaction: Transaction): Future[Transaction] {.base, async.} = @@ -126,7 +107,6 @@ method populateTransaction*(signer: Signer, populated.gasLimit = some(await signer.estimateGas(populated, BlockTag.pending)) except ProviderError, EstimateGasError: let e = getCurrentException() - signer.decreaseNonce() raise e else: diff --git a/ethers/wallet.nim b/ethers/wallet.nim index 85305f6..06074b0 100644 --- a/ethers/wallet.nim +++ b/ethers/wallet.nim @@ -71,6 +71,4 @@ proc signTransaction*(wallet: Wallet, method sendTransaction*(wallet: Wallet, transaction: Transaction): Future[TransactionResponse] {.async.} = let signed = await signTransaction(wallet, transaction) - if nonce =? transaction.nonce: - wallet.updateNonce(nonce) return await provider(wallet).sendTransaction(signed)