diff --git a/sdk/main/include/TransactionReceipt.h b/sdk/main/include/TransactionReceipt.h index 7eff25978..cb5157600 100644 --- a/sdk/main/include/TransactionReceipt.h +++ b/sdk/main/include/TransactionReceipt.h @@ -52,10 +52,13 @@ class TransactionReceipt /** * Construct a TransactionReceipt object from a TransactionGetReceiptResponse protobuf object. * - * @param proto The TransactionGetReceiptResponse protobuf object from which to construct a TransactionReceipt object. + * @param proto The TransactionGetReceiptResponse protobuf object from which to construct a TransactionReceipt + * object. + * @param transactionId The ID of the transaction to which the constructed TransactionReceipt will correspond. * @return The constructed TransactionReceipt object. */ - [[nodiscard]] static TransactionReceipt fromProtobuf(const proto::TransactionGetReceiptResponse& proto); + [[nodiscard]] static TransactionReceipt fromProtobuf(const proto::TransactionGetReceiptResponse& proto, + const TransactionId& transactionId); /** * Construct a TransactionReceipt object from a TransactionReceipt protobuf object. diff --git a/sdk/main/src/TransactionReceipt.cc b/sdk/main/src/TransactionReceipt.cc index 2f178b2f1..bcd2a92ff 100644 --- a/sdk/main/src/TransactionReceipt.cc +++ b/sdk/main/src/TransactionReceipt.cc @@ -27,9 +27,11 @@ namespace Hedera { //----- -TransactionReceipt TransactionReceipt::fromProtobuf(const proto::TransactionGetReceiptResponse& proto) +TransactionReceipt TransactionReceipt::fromProtobuf(const proto::TransactionGetReceiptResponse& proto, + const TransactionId& transactionId) { TransactionReceipt receipt = TransactionReceipt::fromProtobuf(proto.receipt()); + receipt.mTransactionId = transactionId; for (int i = 0; i < proto.duplicatetransactionreceipts_size(); ++i) { diff --git a/sdk/main/src/TransactionReceiptQuery.cc b/sdk/main/src/TransactionReceiptQuery.cc index 29e43b162..1abc95a3c 100644 --- a/sdk/main/src/TransactionReceiptQuery.cc +++ b/sdk/main/src/TransactionReceiptQuery.cc @@ -53,7 +53,7 @@ TransactionReceiptQuery& TransactionReceiptQuery::setIncludeDuplicates(bool dupl //----- TransactionReceipt TransactionReceiptQuery::mapResponse(const proto::Response& response) const { - return TransactionReceipt::fromProtobuf(response.transactiongetreceipt()); + return TransactionReceipt::fromProtobuf(response.transactiongetreceipt(), mTransactionId.value()); } //----- diff --git a/sdk/tests/integration/TransactionReceiptQueryIntegrationTest.cc b/sdk/tests/integration/TransactionReceiptQueryIntegrationTest.cc index 1861acb46..8bdd1aa24 100644 --- a/sdk/tests/integration/TransactionReceiptQueryIntegrationTest.cc +++ b/sdk/tests/integration/TransactionReceiptQueryIntegrationTest.cc @@ -56,6 +56,7 @@ TEST_F(TransactionReceiptQueryIntegrationTest, CanGetTransactionReceipt) TransactionReceipt txReceipt; EXPECT_NO_THROW( txReceipt = TransactionReceiptQuery().setTransactionId(testTxResponse.getTransactionId()).execute(getTestClient())); + EXPECT_EQ(txReceipt.mTransactionId, testTxResponse.getTransactionId()); // Clean up AccountId accountId;