From c68db093e77b5c6d53fab827fa6570e35fabf4b0 Mon Sep 17 00:00:00 2001 From: green Date: Wed, 16 Aug 2023 14:28:22 +0100 Subject: [PATCH 1/3] Implemented `submit_and_await_commit_with_receipts` method --- crates/client/src/client.rs | 12 ++++++++++++ crates/fuel-core/src/database/block.rs | 3 +-- tests/tests/contract.rs | 13 ++++++------- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/crates/client/src/client.rs b/crates/client/src/client.rs index 49bca0b47e9..c551121a268 100644 --- a/crates/client/src/client.rs +++ b/crates/client/src/client.rs @@ -411,6 +411,18 @@ impl FuelClient { Ok(status) } + /// Submits transaction, await confirmation and return receipts. + pub async fn submit_and_await_commit_with_receipts( + &self, + tx: &Transaction, + ) -> io::Result<(TransactionStatus, Option>)> { + let tx_id = self.submit(tx).await?; + let status = self.await_transaction_commit(&tx_id).await?; + let receipts = self.receipts(&tx_id).await?; + + Ok((status, receipts)) + } + pub async fn start_session(&self) -> io::Result { let query = schema::StartSession::build(()); diff --git a/crates/fuel-core/src/database/block.rs b/crates/fuel-core/src/database/block.rs index 7afcb1b5979..9ae0ea1cb99 100644 --- a/crates/fuel-core/src/database/block.rs +++ b/crates/fuel-core/src/database/block.rs @@ -42,7 +42,6 @@ use fuel_core_types::{ use itertools::Itertools; use std::{ borrow::{ - Borrow, BorrowMut, Cow, }, @@ -271,7 +270,7 @@ impl Database { .get(commit_block_height)? .ok_or(not_found!(FuelBlockMerkleMetadata))?; - let storage = self.borrow(); + let storage = self; let tree: MerkleTree = MerkleTree::load(storage, commit_merkle_metadata.version) .map_err(|err| StorageError::Other(err.into()))?; diff --git a/tests/tests/contract.rs b/tests/tests/contract.rs index 0b96560ee4c..1c467409afa 100644 --- a/tests/tests/contract.rs +++ b/tests/tests/contract.rs @@ -258,8 +258,6 @@ async fn can_get_message_proof() { vec![], ); - let transaction_id = script.id(&ChainId::default()); - // setup server & client let srv = FuelService::new_node(config).await.unwrap(); let client = FuelClient::from(srv.bound_address); @@ -281,13 +279,14 @@ async fn can_get_message_proof() { .await .expect("Should be able to estimate deploy tx"); // Call the contract. - matches!( - client.submit_and_await_commit(&script).await, - Ok(TransactionStatus::Success { .. }) - ); + let (status, receipts) = client + .submit_and_await_commit_with_receipts(&script) + .await + .unwrap(); + matches!(status, TransactionStatus::Success { .. }); // Get the receipts from the contract call. - let receipts = client.receipts(&transaction_id).await.unwrap().unwrap(); + let receipts = receipts.unwrap(); let logd = receipts .iter() .find(|f| matches!(f, Receipt::LogData { .. })) From 9877f4e11bc409e11d65414825e1566d78b2763b Mon Sep 17 00:00:00 2001 From: green Date: Wed, 16 Aug 2023 14:32:49 +0100 Subject: [PATCH 2/3] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7438f80adb7..8d8a4c30ae7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ Description of the upcoming release here. - [#1263](https://github.com/FuelLabs/fuel-core/pull/1263): Add gas benchmarks for `ED19` and `ECR1` instructions. - [#1286](https://github.com/FuelLabs/fuel-core/pull/1286): Include readable names for test cases where missing. +- [#1304](https://github.com/FuelLabs/fuel-core/pull/1304): Implemented `submit_and_await_commit_with_receipts` method for `FuelClient`. ### Changed From 94c8c75be153e84e1b6182425728ba0d209b3056 Mon Sep 17 00:00:00 2001 From: green Date: Wed, 16 Aug 2023 14:43:15 +0100 Subject: [PATCH 3/3] Make CI happy --- crates/client/src/client.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/client/src/client.rs b/crates/client/src/client.rs index c551121a268..7867a5020fe 100644 --- a/crates/client/src/client.rs +++ b/crates/client/src/client.rs @@ -411,6 +411,7 @@ impl FuelClient { Ok(status) } + #[cfg(feature = "subscriptions")] /// Submits transaction, await confirmation and return receipts. pub async fn submit_and_await_commit_with_receipts( &self,