Skip to content

Commit

Permalink
fix: use next available nonce for tx
Browse files Browse the repository at this point in the history
Closes #39
  • Loading branch information
onbjerg committed Oct 20, 2024
1 parent 2f82401 commit 113d45b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions crates/wallet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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::<Ethereum>::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.to());

// set chain id
request.chain_id = Some(self.chain_id());
Expand Down

0 comments on commit 113d45b

Please sign in to comment.