diff --git a/CHANGELOG.md b/CHANGELOG.md index 89d77a99f37..980399b75bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Changed - [2378](https://github.com/FuelLabs/fuel-core/pull/2378): Use cached hash of the topic instead of calculating it on each publishing gossip message. +#### Breaking +- [2389](https://github.com/FuelLabs/fuel-core/pull/2258): Updated the `messageProof` GraphQL schema to return a non-nullable `MessageProof`. + ## [Version 0.40.0] ### Added diff --git a/crates/client/assets/schema.sdl b/crates/client/assets/schema.sdl index b9048362caa..54db4ec0995 100644 --- a/crates/client/assets/schema.sdl +++ b/crates/client/assets/schema.sdl @@ -980,7 +980,7 @@ type Query { """ owner: Address, first: Int, after: String, last: Int, before: String ): MessageConnection! - messageProof(transactionId: TransactionId!, nonce: Nonce!, commitBlockId: BlockId, commitBlockHeight: U32): MessageProof + messageProof(transactionId: TransactionId!, nonce: Nonce!, commitBlockId: BlockId, commitBlockHeight: U32): MessageProof! messageStatus(nonce: Nonce!): MessageStatus! relayedTransactionStatus( """ diff --git a/crates/client/src/client.rs b/crates/client/src/client.rs index 65789f6c9c3..1743f631547 100644 --- a/crates/client/src/client.rs +++ b/crates/client/src/client.rs @@ -1141,7 +1141,7 @@ impl FuelClient { nonce: &Nonce, commit_block_id: Option<&BlockId>, commit_block_height: Option, - ) -> io::Result> { + ) -> io::Result { let transaction_id: TransactionId = (*transaction_id).into(); let nonce: schema::Nonce = (*nonce).into(); let commit_block_id: Option = @@ -1153,14 +1153,7 @@ impl FuelClient { commit_block_id, commit_block_height, }); - - let proof = self - .query(query) - .await? - .message_proof - .map(TryInto::try_into) - .transpose()?; - + let proof = self.query(query).await?.message_proof.try_into()?; Ok(proof) } diff --git a/crates/client/src/client/schema/message.rs b/crates/client/src/client/schema/message.rs index 7c47ead200a..7f4e39829d9 100644 --- a/crates/client/src/client/schema/message.rs +++ b/crates/client/src/client/schema/message.rs @@ -114,7 +114,7 @@ pub struct MessageProofQuery { commitBlockId: $commit_block_id, commitBlockHeight: $commit_block_height )] - pub message_proof: Option, + pub message_proof: MessageProof, } #[derive(cynic::QueryFragment, Clone, Debug)] diff --git a/crates/fuel-core/src/schema/message.rs b/crates/fuel-core/src/schema/message.rs index 4d9e5048bd2..95e3f421589 100644 --- a/crates/fuel-core/src/schema/message.rs +++ b/crates/fuel-core/src/schema/message.rs @@ -136,7 +136,7 @@ impl MessageQuery { nonce: Nonce, commit_block_id: Option, commit_block_height: Option, - ) -> async_graphql::Result> { + ) -> async_graphql::Result { let query = ctx.read_view()?; let height = match (commit_block_id, commit_block_height) { (Some(commit_block_id), None) => { @@ -157,7 +157,7 @@ impl MessageQuery { height, )?; - Ok(Some(MessageProof(proof))) + Ok(MessageProof(proof)) } #[graphql(complexity = "query_costs().storage_read + child_complexity")] diff --git a/tests/tests/messages.rs b/tests/tests/messages.rs index bee948105ea..26eceac59b9 100644 --- a/tests/tests/messages.rs +++ b/tests/tests/messages.rs @@ -485,7 +485,6 @@ async fn can_get_message_proof() { let result = client .message_proof(&transaction_id, nonce, None, Some(last_height)) .await - .unwrap() .unwrap(); // 1. Generate the message id (message fields) diff --git a/tests/tests/regenesis.rs b/tests/tests/regenesis.rs index 3ba03d27366..6e92f3dad40 100644 --- a/tests/tests/regenesis.rs +++ b/tests/tests/regenesis.rs @@ -401,8 +401,7 @@ async fn test_regenesis_message_proofs_are_preserved() -> anyhow::Result<()> { .client .message_proof(&tx_id, nonce, None, Some((message_block_height + 1).into())) .await - .expect("Unable to get message proof") - .expect("Message proof not found"); + .expect("Unable to get message proof"); let prev_root = proof.commit_block_header.prev_root; let block_proof_index = proof.block_proof.proof_index; let block_proof_set: Vec<_> = proof @@ -460,8 +459,7 @@ async fn test_regenesis_message_proofs_are_preserved() -> anyhow::Result<()> { .client .message_proof(&tx_id, nonce, None, Some(block_height.into())) .await - .expect("Unable to get message proof") - .expect("Message proof not found"); + .expect("Unable to get message proof"); let prev_root = proof.commit_block_header.prev_root; let block_proof_set: Vec<_> = proof .block_proof