From 41eeef6241e7f292544037030e9c2b4779662bdd Mon Sep 17 00:00:00 2001 From: Oliver Date: Sun, 20 Oct 2024 23:08:41 +0200 Subject: [PATCH] fix: use next available nonce for tx (#61) Depends on #60 Closes #39 --- crates/wallet/src/lib.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/crates/wallet/src/lib.rs b/crates/wallet/src/lib.rs index 3086561..c39839a 100644 --- a/crates/wallet/src/lib.rs +++ b/crates/wallet/src/lib.rs @@ -29,7 +29,7 @@ use jsonrpsee::{ use metrics::Counter; use metrics_derive::Metrics; use reth_primitives::{revm_primitives::Bytecode, BlockId}; -use reth_rpc_eth_api::helpers::{EthCall, EthState, EthTransactions, FullEthApi, LoadFee}; +use reth_rpc_eth_api::helpers::{EthCall, EthTransactions, FullEthApi, LoadFee, LoadState}; use reth_storage_api::{StateProvider, StateProviderFactory}; use serde::{Deserialize, Serialize}; use std::sync::Arc; @@ -273,17 +273,16 @@ where let _permit = self.inner.permit.lock().await; // set nonce - let tx_count = EthState::transaction_count( + let next_nonce = LoadState::next_available_nonce( &self.inner.eth_api, NetworkWallet::::default_signer_address(&self.inner.wallet), - Some(BlockId::pending()), ) .await .map_err(|err| { self.inner.metrics.invalid_send_transaction_calls.increment(1); err.into() })?; - request.nonce = Some(tx_count.to()); + request.nonce = Some(next_nonce); // set chain id request.chain_id = Some(self.chain_id());