From 17b98d0d9e3d5b4721013b31cc59e3aa8af9f5d9 Mon Sep 17 00:00:00 2001 From: puzzle-rusher <103149687+puzzle-rusher@users.noreply.github.com> Date: Sat, 5 Jul 2025 01:54:04 +0400 Subject: [PATCH] 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 --- subxt/src/tx/tx_client.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/subxt/src/tx/tx_client.rs b/subxt/src/tx/tx_client.rs index 71848d1901..6c26c35741 100644 --- a/subxt/src/tx/tx_client.rs +++ b/subxt/src/tx/tx_client.rs @@ -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>( 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());