diff --git a/packages/fuels-accounts/src/provider.rs b/packages/fuels-accounts/src/provider.rs index f0474ad74c..347d678c45 100644 --- a/packages/fuels-accounts/src/provider.rs +++ b/packages/fuels-accounts/src/provider.rs @@ -186,14 +186,17 @@ impl Provider { } /// Sends a transaction to the underlying Provider's client. - pub async fn send_transaction_and_await_commit(&self, tx: T) -> Result { - let tx_id = self.send_transaction(tx.clone()).await?; - self.client.await_transaction_commit(&tx_id).await?; - + pub async fn send_transaction_and_await_commit( + &self, + mut tx: T, + ) -> Result { + self.prepare_transaction_for_sending(&mut tx).await?; + let tx_id = tx.id(self.chain_id()); + let _tx_status = self.client.submit_and_await_commit(&tx.into()).await?; Ok(tx_id) } - pub async fn send_transaction(&self, mut tx: T) -> Result { + async fn prepare_transaction_for_sending(&self, tx: &mut T) -> Result<()> { tx.precompute(&self.chain_id())?; let chain_info = self.chain_info().await?; @@ -207,7 +210,11 @@ impl Provider { } self.validate_transaction(tx.clone()).await?; + Ok(()) + } + pub async fn send_transaction(&self, mut tx: T) -> Result { + self.prepare_transaction_for_sending(&mut tx).await?; Ok(self.client.submit(&tx.into()).await?) } diff --git a/packages/fuels-accounts/src/provider/retryable_client.rs b/packages/fuels-accounts/src/provider/retryable_client.rs index 89db3c1e30..78c95a13b3 100644 --- a/packages/fuels-accounts/src/provider/retryable_client.rs +++ b/packages/fuels-accounts/src/provider/retryable_client.rs @@ -61,8 +61,8 @@ impl RetryableClient { self.our_retry(|| self.client.chain_info()).await } - pub async fn await_transaction_commit(&self, id: &TxId) -> io::Result { - self.our_retry(|| self.client.await_transaction_commit(id)) + pub async fn submit_and_await_commit(&self, tx: &Transaction) -> io::Result { + self.our_retry(|| self.client.submit_and_await_commit(tx)) .await }