Skip to content

Test2#69

Closed
MonaaEid wants to merge 11 commits intomainfrom
TEST2
Closed

Test2#69
MonaaEid wants to merge 11 commits intomainfrom
TEST2

Conversation

@MonaaEid
Copy link
Owner

No description provided.

Added knowledge base and web search configuration to .coderabbit.yaml

Signed-off-by: MontyPokemon <59332150+MonaaEid@users.noreply.github.com>
Add instructions for reviewing consensus-related Python files.

Signed-off-by: MontyPokemon <59332150+MonaaEid@users.noreply.github.com>
Signed-off-by: MontyPokemon <59332150+MonaaEid@users.noreply.github.com>
This module defines the TokenAssociation class, which provides an immutable representation of token-account associations as reported by the Hedera network. It includes methods for converting to and from protobuf representations.

Signed-off-by: MontyPokemon <59332150+MonaaEid@users.noreply.github.com>
Updated the TransactionRecord class to include new attributes and improve documentation. Enhanced type hints and refined the __repr__ method for better readability.

Signed-off-by: MontyPokemon <59332150+MonaaEid@users.noreply.github.com>
@coderabbitai
Copy link

coderabbitai bot commented Feb 25, 2026

Warning

Ignoring CodeRabbit configuration file changes. For security, only the configuration from the base branch is applied for open source repositories.

Walkthrough

Adds a frozen TokenAssociation dataclass with protobuf conversions and substantially refactors TransactionRecord to add many strongly-typed fields, new public attributes, and extended protobuf (de)serialization; also adds Protobuf Schema Alignment review blocks and a knowledge_base flag in .coderabbit.yaml.

Changes

Cohort / File(s) Summary
New TokenAssociation Class
src/hiero_sdk_python/tokens/token_association.py
Adds immutable TokenAssociation(token_id: Optional[TokenId]=None, account_id: Optional[AccountId]=None) dataclass with _from_proto(proto), _to_proto(), and __str__/__repr__. Uses presence checks when mapping nested proto fields.
TransactionRecord Refactor
src/hiero_sdk_python/transaction/transaction_record.py
Reworks TransactionRecord to richer, strongly-typed public surface: adds consensus_timestamp, parent_consensus_timestamp, schedule_ref, assessed_custom_fees, automatic_token_associations, alias, ethereum_hash, evm_address, paid_staking_rewards, contract_create_result, and adjusts existing transfer containers and __repr__. Extends _from_proto/_to_proto` to parse/serialize new types and enforces oneof exclusivity between call and create results.
Repo configuration / review automation
.coderabbit.yaml
Adds knowledge_base.web_search.enabled: true and inserts multiple "Protobuf Schema Alignment Review" instruction blocks targeting src/hiero_sdk_python/**/*.py (and specific subpaths) for automated review guidance and schema checks.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

🚥 Pre-merge checks | ❌ 3

❌ Failed checks (1 warning, 2 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 77.78% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Test2' is vague and does not describe the changeset; it does not convey meaningful information about the actual changes. Replace with a descriptive title that summarizes the primary change, such as 'Add TokenAssociation class and update TransactionRecord with new fields'.
Description check ❓ Inconclusive No pull request description was provided by the author; the description field is empty. Add a description explaining the purpose and scope of the changes, including the new TokenAssociation class and TransactionRecord updates.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch TEST2

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

@github-actions
Copy link

Hi @MonaaEid, this is **LinkBot** 👋

Linking pull requests to issues helps us significantly with reviewing pull requests and keeping the repository healthy.

🚨 This pull request does not have an issue linked.

Please link an issue using the following format:

Fixes #123

📖 Guide:
docs/sdk_developers/how_to_link_issues.md

If no issue exists yet, please create one:
docs/sdk_developers/creating_issues.md

Thanks!

@MonaaEid
Copy link
Owner Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Feb 26, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@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: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/hiero_sdk_python/transaction/transaction_record.py (1)

365-382: ⚠️ Potential issue | 🔴 Critical

Missing mutual-exclusion guard for oneof entropy (prng_number / prng_bytes) in _to_proto.

There is a correct guard for the body oneof (lines 366-370), but the entropy oneof fields prng_number and prng_bytes are both passed directly in the constructor (lines 380-381). If both are non-None, protobuf silently keeps only the last one written, causing silent data loss. Additionally, setting these in the constructor arguments simultaneously is problematic — they should be set conditionally like contractCreateResult.

Proposed fix
+        # Defensive guard for protobuf oneof (entropy)
+        if self.prng_number is not None and self.prng_bytes is not None:
+            raise ValueError(
+                "prng_number and prng_bytes are mutually exclusive "
+                "(protobuf oneof entropy) — only one may be set at a time"
+            )
+
         record_proto = transaction_record_pb2.TransactionRecord(
             transactionHash=self.transaction_hash,
             memo=self.transaction_memo,
             transactionFee=self.transaction_fee,
             receipt=self.receipt._to_proto() if self.receipt else None,
             contractCallResult=(
                 self.call_result._to_proto() if self.call_result else None
             ),
-            prng_number=self.prng_number,
-            prng_bytes=self.prng_bytes,
         )

+        if self.prng_number is not None:
+            record_proto.prng_number = self.prng_number
+        elif self.prng_bytes is not None:
+            record_proto.prng_bytes = self.prng_bytes

As per coding guidelines, "Verify that _to_proto does NOT set more than one field from the same oneof block simultaneously. If it does, a ValueError guard MUST be present before setting those fields."


ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 51aeda8 and fc86c00.

📒 Files selected for processing (2)
  • src/hiero_sdk_python/tokens/token_association.py
  • src/hiero_sdk_python/transaction/transaction_record.py

"""

from dataclasses import dataclass
from typing import Optional
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Style inconsistency: use X | None instead of Optional[X].

The codebase convention uses Python 3.10+ union syntax (X | None). The Optional import and its usages should be replaced for consistency — especially since the sibling file transaction_record.py already uses X | None for all its fields.

Proposed fix
-from typing import Optional
-
 from hiero_sdk_python.account.account_id import AccountId
 from hiero_sdk_python.tokens.token_id import TokenId
 from hiero_sdk_python.hapi.services.basic_types_pb2 import TokenAssociation as TokenAssociationProto
-    token_id: Optional[TokenId] = None
+    token_id: TokenId | None = None
     """The identifier of the token being associated."""

-    account_id: Optional[AccountId] = None
+    account_id: AccountId | None = None
     """The identifier of the account receiving the association."""

As per coding guidelines, "The codebase uses X | None union syntax (Python 3.10+). Flag any use of Optional[X] from typing in newly added or modified code, as it is inconsistent with the established style."

Also applies to: 50-50, 53-53

Comment on lines +46 to 68
transaction_id: The unique identifier of the transaction.
transaction_hash: The raw SHA-384 hash of the signed transaction bytes.
memo: Optional text memo attached to the transaction.
transaction_fee: Total network fee charged (in tinybars).
receipt: Summary of transaction outcome (status, account & file IDs created, etc.).
contract_call_result: Result of a ContractCall transaction (if applicable).
contract_create_result: Result of a ContractCreate transaction (if applicable).
token_transfers: Fungible token movements (token → account → amount).
nft_transfers: Non-fungible token (NFT) movements (token → list of serial transfers).
transfers: HBAR / account balance changes (account → net amount in tinybars).
new_pending_airdrops: Newly created pending airdrop records from this transaction.
prng_number: 32-bit pseudo-random number (if PRNG service was used).
prng_bytes: Variable-length pseudo-random bytes (if PRNG service was used).
consensus_timestamp: A consensus timestamp. (This SHALL be null if the transaction did not reach consensus yet.)
parent_consensus_timestamp: A consensus timestamp for a child record. (This SHALL be the consensus timestamp of a user transaction that spawned an internal child transaction.)
schedule_ref: A schedule reference. (The reference to a schedule ID for the schedule that initiated this transaction, if this transaction record represents a scheduled transaction.)
assessed_custom_fees: A list of all custom fees that were assessed during a CryptoTransfer. (These SHALL be paid if the transaction status resolved to SUCCESS.)
automatic_token_associations: Token associations automatically created.
alias: EVM-style alias bytes (usually for account creation via ECDSA key).
ethereum_hash: 32-byte hash used in Ethereum-compatible transaction format.
evm_address: 20-byte EVM-compatible address (if created or referenced).
paid_staking_rewards: A list of staking rewards paid. (This SHALL be a list of accounts with the corresponding staking rewards paid as a result of this transaction.)
"""
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Docstring attribute names do not match actual field names.

The docstring documents memo (line 48) but the attribute is transaction_memo (line 71). Similarly, it documents contract_call_result (line 51) but the attribute is call_result (line 74). Users relying on the docstring will reference non-existent attributes.

Proposed fix (update docstring to match actual attribute names)
-        memo: Optional text memo attached to the transaction.
+        transaction_memo: Optional text memo attached to the transaction.
         ...
-        contract_call_result: Result of a ContractCall transaction (if applicable).
+        call_result: Result of a ContractCall transaction (if applicable).

Also applies to: 69-74

MonaaEid and others added 3 commits February 26, 2026 02:08
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: MontyPokemon <59332150+MonaaEid@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: MontyPokemon <59332150+MonaaEid@users.noreply.github.com>
Signed-off-by: MontyPokemon <59332150+MonaaEid@users.noreply.github.com>
Repository owner deleted a comment from coderabbitai bot Feb 26, 2026
Signed-off-by: MontyPokemon <59332150+MonaaEid@users.noreply.github.com>
Repository owner deleted a comment from coderabbitai bot Feb 26, 2026
@MonaaEid
Copy link
Owner Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Feb 26, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/hiero_sdk_python/transaction/transaction_record.py (1)

373-390: ⚠️ Potential issue | 🟠 Major

Add a guard for oneof entropy before serializing PRNG fields.

Proto field: prng_bytes (19), prng_number (20)
Issue type: oneof violation
Both fields are currently set in the constructor without validation. If both prng_number and prng_bytes are non-None, protobuf's oneof semantics will silently overwrite one field with the other.

🛡️ Proposed fix
         # Defensive guard for protobuf oneof
         if self.call_result is not None and self.contract_create_result is not None:
             raise ValueError(
                 "call_result and contract_create_result are mutually exclusive "
                 "(protobuf oneof) — only one may be set at a time"
             )
+
+        if self.prng_number is not None and self.prng_bytes is not None:
+            raise ValueError(
+                "prng_number and prng_bytes are mutually exclusive "
+                "(protobuf oneof) — only one may be set at a time"
+            )
 
         record_proto = transaction_record_pb2.TransactionRecord(
             transactionHash=self.transaction_hash,
             memo=self.transaction_memo,
             transactionFee=self.transaction_fee,
             receipt=self.receipt._to_proto() if self.receipt else None,
             contractCallResult=(
                 self.call_result._to_proto() if self.call_result else None
             ),
-            prng_number=self.prng_number,
-            prng_bytes=self.prng_bytes,
         )
+
+        if self.prng_number is not None:
+            record_proto.prng_number = self.prng_number
+        elif self.prng_bytes is not None:
+            record_proto.prng_bytes = self.prng_bytes
♻️ Duplicate comments (1)
src/hiero_sdk_python/transaction/transaction_record.py (1)

45-53: ⚠️ Potential issue | 🟡 Minor

Docstring still references stale attribute names.

memo / contract_call_result in the docstring do not match actual dataclass fields transaction_memo / call_result, which can mislead users of the public API docs.

📝 Proposed fix
-        memo: Optional text memo attached to the transaction.
+        transaction_memo: Optional text memo attached to the transaction.
...
-        contract_call_result: Result of a ContractCall transaction (if applicable).
+        call_result: Result of a ContractCall transaction (if applicable).

Also applies to: 69-75


ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fc86c00 and 0a6b29d.

📒 Files selected for processing (2)
  • src/hiero_sdk_python/tokens/token_association.py
  • src/hiero_sdk_python/transaction/transaction_record.py

@github-actions
Copy link

Hi, this is MergeConflictBot.
Your pull request cannot be merged because it contains merge conflicts.

Please resolve these conflicts locally and push the changes.

Quick Fix for CHANGELOG.md Conflicts

If your conflict is only in CHANGELOG.md, you can resolve it easily using the GitHub web editor:

  1. Click on the "Resolve conflicts" button in the PR
  2. Accept both changes (keep both changelog entries)
  3. Click "Mark as resolved"
  4. Commit the merge

For all other merge conflicts, please read:

Thank you for contributing!

@github-actions
Copy link

github-actions bot commented Mar 2, 2026

Hi there! I'm the LinkedIssueBot.
This pull request has been automatically closed due to the following reason(s):

Thank you,
From Python SDK team

@github-actions github-actions bot closed this Mar 2, 2026
@MonaaEid MonaaEid reopened this Mar 3, 2026
Added instructions for reviewing Python files in the account directory, including review priorities and architectural invariants.

Signed-off-by: MontyPokemon <59332150+MonaaEid@users.noreply.github.com>
Copy link

@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: 1


ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0a6b29d and 0a93137.

📒 Files selected for processing (2)
  • .coderabbit.yaml
  • src/hiero_sdk_python/tokens/token_association.py

Comment on lines +21 to +23
knowledge_base: # Enable knowledge base access for up-to-date information
web_search: # Enable web search for up-to-date information
enabled: true
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

knowledge_base is incorrectly nested under reviews: — move to root level.

According to the CodeRabbit configuration schema, knowledge_base is a top-level property (sibling to reviews), not a child of reviews. The reviews object has additionalProperties: false, so this nested placement will either be ignored or cause validation errors.

🐛 Proposed fix — move to root level
 reviews:
   profile: "assertive"
   high_level_summary: false
   # ... other review settings ...
   enable_prompt_for_ai_agents: false
-  knowledge_base:
-    web_search:
-      enabled: true

+knowledge_base:
+  web_search:
+    enabled: true

   # TOKEN REVIEW INSTRUCTIONS
   token_review_instructions: &token_review_instructions |

Place knowledge_base: at the same indentation level as reviews: and chat:.

@github-actions
Copy link

github-actions bot commented Mar 4, 2026

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:

@github-actions
Copy link

github-actions bot commented Mar 5, 2026

Hi there! I'm the LinkedIssueBot.
This pull request has been automatically closed due to the following reason(s):

Thank you,
From Python SDK team

@github-actions github-actions bot closed this Mar 5, 2026
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.

1 participant