diff --git a/CHANGELOG.md b/CHANGELOG.md index e7f59edc3f6..d1482cf5459 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ Description of the upcoming release here. - [#1636](https://github.com/FuelLabs/fuel-core/pull/1636): Add more docs to GraphQL DAP API. #### Breaking +- [#1646](https://github.com/FuelLabs/fuel-core/pull/1646): Remove redundant receipts from queries. - [#1639](https://github.com/FuelLabs/fuel-core/pull/1639): Make Merkle metadata, i.e. `SparseMerkleMetadata` and `DenseMerkleMetadata` type version-able enums - [#1632](https://github.com/FuelLabs/fuel-core/pull/1632): Make `Message` type a version-able enum - [#1631](https://github.com/FuelLabs/fuel-core/pull/1631): Modify api endpoint to dry run multiple transactions. diff --git a/bin/e2e-test-client/src/tests/collect_fee.rs b/bin/e2e-test-client/src/tests/collect_fee.rs index 228bbb28b05..a41fbef14a8 100644 --- a/bin/e2e-test-client/src/tests/collect_fee.rs +++ b/bin/e2e-test-client/src/tests/collect_fee.rs @@ -11,19 +11,21 @@ pub async fn collect_fee(ctx: &TestContext) -> Result<(), Failed> { .alice .collect_fee_tx(ctx.config.coinbase_contract_id, AssetId::BASE) .await?; - let (status, receipts) = ctx - .alice - .client - .submit_and_await_commit_with_receipts(&tx) - .await?; + let tx_status = ctx.alice.client.submit_and_await_commit(&tx).await?; if !matches!( - status, + tx_status, fuel_core_client::client::types::TransactionStatus::Success { .. } ) { return Err("collect fee transaction is not successful".into()) } + let receipts = match &tx_status { + fuel_core_client::client::types::TransactionStatus::Success { + receipts, .. + } => Some(receipts), + _ => None, + }; let receipts = receipts.ok_or("collect fee transaction doesn't have receipts")?; if !receipts diff --git a/crates/client/src/client.rs b/crates/client/src/client.rs index e5fcd8eea57..a6b8ab0dbf3 100644 --- a/crates/client/src/client.rs +++ b/crates/client/src/client.rs @@ -447,37 +447,6 @@ impl FuelClient { Ok(status) } - // TODO: Remove this function after the Beta 5 release when we can introduce breaking changes. - // This function is now redundant since `submit_and_await_commit` returns - // receipts for all successful and failed transactions. - #[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>)> { - let tx_id = self.submit(tx).await?; - let status = self.await_transaction_commit(&tx_id).await?; - let receipts = match &status { - TransactionStatus::Submitted { .. } => None, - TransactionStatus::Success { receipts, .. } => Some(receipts.clone()), - TransactionStatus::SqueezedOut { .. } => { - // Note: Returns an error when the transaction has been squeezed - // out instead of returning the `SqueezedOut` status. This is - // done to maintain existing behavior where retrieving receipts - // via `self.receipts(..)` returns an error when the transaction - // cannot be found, such as in the case of a squeeze-out. - Err(io::Error::new( - ErrorKind::NotFound, - format!("transaction {tx_id} not found"), - ))? - } - TransactionStatus::Failure { receipts, .. } => Some(receipts.clone()), - }; - - Ok((status, receipts)) - } - pub async fn start_session(&self) -> io::Result { let query = schema::StartSession::build(()); @@ -698,14 +667,26 @@ impl FuelClient { io::Error::new(ErrorKind::NotFound, format!("transaction {id} not found")) })?; - let receipts = tx - .receipts - .map(|vec| { - let vec: Result, ConversionError> = - vec.into_iter().map(TryInto::::try_into).collect(); - vec - }) - .transpose()?; + let receipts = match tx.status { + Some(status) => match status { + schema::tx::TransactionStatus::SuccessStatus(s) => Some( + s.receipts + .into_iter() + .map(TryInto::::try_into) + .collect::, ConversionError>>(), + ) + .transpose()?, + schema::tx::TransactionStatus::FailureStatus(s) => Some( + s.receipts + .into_iter() + .map(TryInto::::try_into) + .collect::, ConversionError>>(), + ) + .transpose()?, + _ => None, + }, + _ => None, + }; Ok(receipts) } diff --git a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__opaque_transaction_by_id_query_gql_output.snap b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__opaque_transaction_by_id_query_gql_output.snap index df509b70342..800e0242e2b 100644 --- a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__opaque_transaction_by_id_query_gql_output.snap +++ b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__opaque_transaction_by_id_query_gql_output.snap @@ -5,40 +5,6 @@ expression: operation.query query($id: TransactionId!) { transaction(id: $id) { rawPayload - receipts { - param1 - param2 - amount - assetId - gas - digest - contract { - id - } - is - pc - ptr - ra - rb - rc - rd - reason - receiptType - to { - id - } - toAddress - val - len - result - gasUsed - data - sender - recipient - nonce - contractId - subId - } status { __typename ... on SubmittedStatus { diff --git a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__transactions_by_owner_gql_output.snap b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__transactions_by_owner_gql_output.snap index 8bd2c40909a..f2d657ac5ba 100644 --- a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__transactions_by_owner_gql_output.snap +++ b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__transactions_by_owner_gql_output.snap @@ -8,40 +8,6 @@ query($owner: Address!, $after: String, $before: String, $first: Int, $last: Int cursor node { rawPayload - receipts { - param1 - param2 - amount - assetId - gas - digest - contract { - id - } - is - pc - ptr - ra - rb - rc - rd - reason - receiptType - to { - id - } - toAddress - val - len - result - gasUsed - data - sender - recipient - nonce - contractId - subId - } status { __typename ... on SubmittedStatus { diff --git a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__transactions_connection_query_gql_output.snap b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__transactions_connection_query_gql_output.snap index e668a2218b4..5f52e1bb5dc 100644 --- a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__transactions_connection_query_gql_output.snap +++ b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__transactions_connection_query_gql_output.snap @@ -8,40 +8,6 @@ query($after: String, $before: String, $first: Int, $last: Int) { cursor node { rawPayload - receipts { - param1 - param2 - amount - assetId - gas - digest - contract { - id - } - is - pc - ptr - ra - rb - rc - rd - reason - receiptType - to { - id - } - toAddress - val - len - result - gasUsed - data - sender - recipient - nonce - contractId - subId - } status { __typename ... on SubmittedStatus { diff --git a/crates/client/src/client/schema/tx.rs b/crates/client/src/client/schema/tx.rs index c2edf169229..c1e82859940 100644 --- a/crates/client/src/client/schema/tx.rs +++ b/crates/client/src/client/schema/tx.rs @@ -98,8 +98,6 @@ pub struct TransactionEdge { #[cynic(graphql_type = "Transaction", schema_path = "./assets/schema.sdl")] pub struct OpaqueTransaction { pub raw_payload: HexString, - // TODO: Remove now that Success and Failure status includes receipts - pub receipts: Option>, pub status: Option, } diff --git a/tests/tests/contract.rs b/tests/tests/contract.rs index 9511d6ff32b..1698bf15922 100644 --- a/tests/tests/contract.rs +++ b/tests/tests/contract.rs @@ -268,11 +268,13 @@ async fn can_get_message_proof() { .await .expect("Should be able to estimate deploy tx"); // Call the contract. - let (status, receipts) = client - .submit_and_await_commit_with_receipts(&script) - .await - .unwrap(); - matches!(status, TransactionStatus::Success { .. }); + let tx_status = client.submit_and_await_commit(&script).await.unwrap(); + matches!(tx_status, TransactionStatus::Success { .. }); + + let receipts = match tx_status { + TransactionStatus::Success { receipts, .. } => Some(receipts), + _ => None, + }; // Get the receipts from the contract call. let receipts = receipts.unwrap();