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

Add TransactionId argument to TransactionReceipt::fromProtobuf() #512

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
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
Loading