Skip to content

Add support for include_duplicates in TransactionGetReceiptQuery #1166

@manishdait

Description

@manishdait

Problem

Currently, the Python SDK implementation of TransactionGetReceiptQuery supports only the following fields:

self.transaction_id: Optional[TransactionId] = transaction_id
self.include_children:bool = False
self._frozen: bool = False

However, it does not expose support for requesting duplicate transaction receipts, which are already supported at the protocol level (Protobuff) and in other SDKs (e.g., JavaScript).

Expected Behavior:

The query should allow user to optionally request receipts for duplicate transaction. Similar as implemented for child receipt in PR #1114.

Eg:

query = (
    TransactionGetReceiptQuery()
    .set_transaction_id(tx_id)
    .set_include_duplicates(True) #True/False
)

Solution

  • Add support for an include_duplicates field to TransactionGetReceiptQuery class.
  • Create a setter method set_include_duplicates(bool).
  • Update TransactionReceipt class to include the duplicates field.
  • Add a function to process the duplicates receipts form the TransactionGetReceiptQuery response
# Suggested to created a single method to process  both children and duplicate receipt
# Example func that convert the child/duplicates receipts to TransactionReceipt list and then return
def _map_receipt_list(self, proto_receipts: List[transaction_receipt_pb2.TransactionReceipt]) -> List["TransactionReceipt"]:
        receipts: List[TransactionReceipt] = []
        for receipt in proto_receipts:
            receipts.append(TransactionReceipt._from_proto(receipt, self.transaction_id))
        
        return receipts
  • Update _make_request() function of TransactionGetReceiptQuery to include_duplicates field while creating the proto
  • Create a example for demonstrating and using these new field
  • Update/Add unit and integration test for the changes

Alternatives

  • Additionally add @property for getting _duplicates from the TransactionReceipt

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestintermediaterequires some knowledge of the codebase with some defined steps to implement or examples

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions