Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented submit_and_await_commit_with_receipts method #1304

Merged
merged 3 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 13 additions & 0 deletions crates/client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,19 @@ impl FuelClient {
Ok(status)
}

#[cfg(feature = "subscriptions")]
/// Submits transaction, await confirmation and return receipts.
pub async fn submit_and_await_commit_with_receipts(
&self,
tx: &Transaction,
) -> io::Result<(TransactionStatus, Option<Vec<Receipt>>)> {
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<String> {
let query = schema::StartSession::build(());

Expand Down
3 changes: 1 addition & 2 deletions crates/fuel-core/src/database/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ use fuel_core_types::{
use itertools::Itertools;
use std::{
borrow::{
Borrow,
BorrowMut,
Cow,
},
Expand Down Expand Up @@ -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<FuelBlockMerkleData, _> =
MerkleTree::load(storage, commit_merkle_metadata.version)
.map_err(|err| StorageError::Other(err.into()))?;
Expand Down
13 changes: 6 additions & 7 deletions tests/tests/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 { .. }))
Expand Down
Loading