Skip to content

Commit

Permalink
Add TransactionId argument to TransactionReceipt::fromProtobuf() (#…
Browse files Browse the repository at this point in the history
…512)

Signed-off-by: Rob Walworth <[email protected]>
  • Loading branch information
rwalworth authored Oct 3, 2023
1 parent f6d3ade commit 5d9fb9a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions sdk/main/include/TransactionReceipt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion sdk/main/src/TransactionReceipt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion sdk/main/src/TransactionReceiptQuery.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

//-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5d9fb9a

Please sign in to comment.