mirror of
https://github.com/logos-storage/nim-ethers.git
synced 2026-01-03 22:23:06 +00:00
removes lastSeenNonce
Removes lastSeenNonce and updating/decreasing of the nonce, as this is not required if populateTransaction and sendTransaction are async locked.
This commit is contained in:
parent
a513d66f9b
commit
3b5483d37d
@ -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)
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user