Refactor: improve nonce and block injection in extrinsic params (#2032)

* Refactor: improve nonce and block injection in extrinsic params

* remove excess import

---------

Co-authored-by: James Wilson <james@jsdw.me>
This commit is contained in:
puzzle-rusher
2025-07-05 01:54:04 +04:00
committed by GitHub
parent 05c9eafe79
commit 17b98d0d9e
+10 -7
View File
@@ -12,6 +12,7 @@ use crate::{
};
use codec::{Compact, Decode, Encode};
use derive_where::derive_where;
use futures::future::try_join;
use subxt_core::tx::TransactionVersion;
/// A client for working with transactions.
@@ -605,13 +606,15 @@ async fn inject_account_nonce_and_block<T: Config, Client: OnlineClientT<T>>(
use subxt_core::config::transaction_extensions::Params;
let block_ref = client.backend().latest_finalized_block_ref().await?;
let block_header = client
.backend()
.block_header(block_ref.hash())
.await?
.ok_or_else(|| Error::Block(BlockError::not_found(block_ref.hash())))?;
let account_nonce =
crate::blocks::get_account_nonce(client, account_id, block_ref.hash()).await?;
let (block_header, account_nonce) = try_join(
client.backend().block_header(block_ref.hash()),
crate::blocks::get_account_nonce(client, account_id, block_ref.hash()),
)
.await?;
let block_header =
block_header.ok_or_else(|| Error::Block(BlockError::not_found(block_ref.hash())))?;
params.inject_account_nonce(account_nonce);
params.inject_block(block_header.number().into(), block_ref.hash());