Skip to content

feat: Add support for include_children to TransactionRecordQuery#1959

Open
AntonioCeppellini wants to merge 5 commits intohiero-ledger:mainfrom
AntonioCeppellini:1512-add-support-for-include_children-in-TransactionRecordQuery
Open

feat: Add support for include_children to TransactionRecordQuery#1959
AntonioCeppellini wants to merge 5 commits intohiero-ledger:mainfrom
AntonioCeppellini:1512-add-support-for-include_children-in-TransactionRecordQuery

Conversation

@AntonioCeppellini
Copy link
Member

…class(1512)

Description:
This PR adds support for include_children to the TransactionRecordQuery class.

Related issue(s):

Fixes #1512

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

…class(1512)

Signed-off-by: Antonio Ceppellini <antonio.ceppellini@gmail.com>
@codecov
Copy link

codecov bot commented Mar 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1959   +/-   ##
=======================================
  Coverage   93.53%   93.54%           
=======================================
  Files         141      141           
  Lines        9146     9160   +14     
=======================================
+ Hits         8555     8569   +14     
  Misses        591      591           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: ceceece5-b0f2-4ff8-b862-4f62d781f01c

📥 Commits

Reviewing files that changed from the base of the PR and between 727684c and ee4d78e.

📒 Files selected for processing (1)
  • CHANGELOG.md

Walkthrough

Added support for requesting child transaction records via a new include_children flag on TransactionRecordQuery. TransactionRecord now exposes a children list that is populated when child records are returned and mapped.

Changes

Cohort / File(s) Summary
Query Implementation
src/hiero_sdk_python/query/transaction_record_query.py
Add include_children: bool ctor param and set_include_children() setter; propagate include_child_records into protobuf request; map child_transaction_records in execute() and pass mapped children to TransactionRecord._from_proto.
Record Structure
src/hiero_sdk_python/transaction/transaction_record.py
Add public children: list[TransactionRecord] field (default empty list); extend _from_proto() to accept children; include children count in __repr__.
Examples & Changelog
CHANGELOG.md, examples/query/transaction_record_query_with_children.py
Add changelog entry and new example demonstrating submitting a transfer that produces child records and querying parent with include_children=True.
Unit Tests
tests/unit/transaction_record_query_test.py, tests/unit/transaction_record_test.py
Add tests for include_children ctor, setter validation, protobuf include_child_records propagation, execute() mapping/population of result.children; update TransactionRecord tests to validate children initialization and per-instance isolation.
Integration Tests
tests/integration/transaction_record_query_e2e_test.py
Add helper to submit alias auto-create transfer and an end-to-end test asserting child records are returned and parsed when include_children=True.
Misc / Manifest
manifest_file, ...
Minor manifest/changelog/example additions to reflect the new example and API extension.

Sequence Diagram

sequenceDiagram
    participant Client as Client
    participant Query as TransactionRecordQuery
    participant Server as Server
    participant Record as TransactionRecord

    Client->>Query: set_include_children(True)
    Query->>Query: store include_children=True
    Client->>Query: execute(client)
    Query->>Query: _make_request(include_child_records=True)
    Query->>Server: TransactionGetRecord request
    Server-->>Query: Response (parent + child_transaction_records)
    Query->>Query: _map_record_list(child_transaction_records)
    loop for each child_proto
        Query->>Record: _from_proto(child_proto)
        Record-->>Query: child TransactionRecord
    end
    Query->>Record: _from_proto(parent_proto, children=[...])
    Record-->>Query: parent TransactionRecord (children populated)
    Query-->>Client: return TransactionRecord with children
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding include_children support to TransactionRecordQuery, which is the primary objective of this PR.
Description check ✅ Passed The description is directly related to the changeset, mentioning the addition of include_children support to TransactionRecordQuery and referencing the linked issue #1512.
Linked Issues check ✅ Passed The PR implementation comprehensively addresses all coding objectives from issue #1512: adds include_children field and setter to TransactionRecordQuery, updates proto request construction, extends TransactionRecord with children field, implements child record mapping, updates _make_request and _execute methods, and includes example and tests.
Out of Scope Changes check ✅ Passed All changes align with the objectives in issue #1512. The modifications to TransactionRecordQuery, TransactionRecord, test files, example files, and CHANGELOG are all directly within scope of adding include_children support.
Docstring Coverage ✅ Passed Docstring coverage is 90.48% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 56b4e967-30f7-4291-b046-3623cc0d86fb

📥 Commits

Reviewing files that changed from the base of the PR and between 8fa3dda and 906a82d.

📒 Files selected for processing (7)
  • CHANGELOG.md
  • examples/query/transaction_record_query_with_children.py
  • src/hiero_sdk_python/query/transaction_record_query.py
  • src/hiero_sdk_python/transaction/transaction_record.py
  • tests/integration/transaction_record_query_e2e_test.py
  • tests/unit/transaction_record_query_test.py
  • tests/unit/transaction_record_test.py

CHANGELOG.md Outdated

### Added
- Added CodeRabbit review instructions in `.coderabbit.yaml` for account module `src/hiero_sdk_python/account/`.
- Add support for `include_children` to TransactionRecordQuery (#1512)(https://github.com/hiero-ledger/hiero-sdk-python/issues/1512)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Consider simplifying the issue reference format.

The entry uses both (#1512) and the full URL (https://github.com/hiero-ledger/hiero-sdk-python/issues/1512), which is redundant since GitHub automatically links #1512 to the issue. For consistency with other entries (e.g., lines 134, 224), consider using just the short form:

-- Add support for `include_children` to TransactionRecordQuery (`#1512`)(https://github.com/hiero-ledger/hiero-sdk-python/issues/1512)
+- Add support for `include_children` to TransactionRecordQuery (`#1512`)

That said, the content accurately describes the feature being added.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- Add support for `include_children` to TransactionRecordQuery (#1512)(https://github.com/hiero-ledger/hiero-sdk-python/issues/1512)
- Add support for `include_children` to TransactionRecordQuery (`#1512`)

@github-actions
Copy link

Hi, this is WorkflowBot.
Your pull request cannot be merged as it is not passing all our workflow checks.
Please click on each check to review the logs and resolve issues so all checks pass.
To help you:

@AntonioCeppellini AntonioCeppellini marked this pull request as draft March 11, 2026 12:36
…class(1512)

Signed-off-by: Antonio Ceppellini <antonio.ceppellini@gmail.com>
@AntonioCeppellini AntonioCeppellini marked this pull request as ready for review March 11, 2026 13:47
…class(1512)

Signed-off-by: Antonio Ceppellini <antonio.ceppellini@gmail.com>
f"prng_bytes={self.prng_bytes}, "
f"duplicates_count={len(self.duplicates)})")
f"duplicates_count={len(self.duplicates)}, "
f"children={self.children})")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should keep it len(self.children) to keep consistent with the duplicate records

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you @manishdait :D

…class(1512)

Signed-off-by: Antonio Ceppellini <antonio.ceppellini@gmail.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9d0e6d1c-a777-4919-92f8-0b40778ccfad

📥 Commits

Reviewing files that changed from the base of the PR and between 906a82d and 727684c.

📒 Files selected for processing (7)
  • CHANGELOG.md
  • examples/query/transaction_record_query_with_children.py
  • src/hiero_sdk_python/query/transaction_record_query.py
  • src/hiero_sdk_python/transaction/transaction_record.py
  • tests/integration/transaction_record_query_e2e_test.py
  • tests/unit/transaction_record_query_test.py
  • tests/unit/transaction_record_test.py

Comment on lines +34 to +37
)
receipt = transaction.execute(client)

return transaction.transaction_id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Add receipt status validation before returning transaction_id.

The function doesn't verify receipt.status == ResponseCode.SUCCESS before returning, which could mask failures.

🛡️ Add status check
         receipt = transaction.execute(client)
 
+        if receipt.status != ResponseCode.SUCCESS:
+            print(f"Transfer failed with status: {ResponseCode(receipt.status).name}")
+            sys.exit(1)
+
         return transaction.transaction_id

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for include_children to the TransactionRecordQuery class

2 participants