You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: Implemet from_protobuf for the token_lifecycle transaction - #2791
Five token transaction classes now restore type-specific fields from protobuf bodies. Supply and token type enums convert protobuf values to SDK members. Unit and integration tests cover deserialization, byte round trips, and execution of reconstructed transactions.
Supply and token type enums convert protobuf values to SDK members. Token creation deserialization restores parameters and keys. Tests cover populated and default values, byte round trips, and execution of reconstructed fungible and non-fungible token creation transactions.
Token update and NFT update deserialization restore fields from protobuf bodies. Unit tests cover populated and absent data and byte round trips. Integration tests execute reconstructed transactions and verify updated token or NFT data.
Token deletion and fee schedule update deserialization restore fields from protobuf bodies. Unit tests cover populated and absent data and byte round trips. Integration tests execute reconstructed transactions and verify token state or fees.
Token lifecycle transactions can now be restored from protobuf bodies. A few edge cases remain: a missing treasury is replaced with a default account, and absent or empty metadata and memo may not round-trip identically. These affect narrow edge cases and test hygiene rather than the main flows, so the change is mergeable with follow-up.
Pre-merge checks: 3 · 1
Failed checks: 1 inconclusive
Check name
Status
Explanation
Resolution
Linked Issues check
[#2616] Requires _from_protobuf for TokenCreate, TokenUpdate, TokenDelete, TokenUpdateNfts, and TokenFeeScheduleUpdate, plus removal of xfail markers in the #2614 round-trip harness. The whole-PR …
Confirm that TokenCreateTransaction.build_transaction_body() emits treasury only when set. If it does not, make the restored treasury None when treasury is absent, and confirm that the round trip keeps to_bytes() byte-identical. Con…
Passed checks: 3 passed
Check name
Status
Explanation
Title check
The title names the main change: adding a _from_protobuf implementation for token lifecycle transactions. The raw summary shows _from_protobuf added to TokenCreate, TokenUpdate, TokenDelete, Token…
Description check
The description states the PR adds the _from_protobuf method for token lifecycle transactions. It links issue #2616 and says tests and docs were done. This matches the changeset, though it gives lit…
Out of Scope Changes check
The change set stays within the issue scope. TokenType._from_proto and SupplyType._from_proto are enum converters that the token create restoration needs. Each _from_protobuf is limited to its t…
Full details: Title check
Explanation
The title names the main change: adding a _from_protobuf implementation for token lifecycle transactions. The raw summary shows _from_protobuf added to TokenCreate, TokenUpdate, TokenDelete, TokenUpdateNfts, and TokenFeeScheduleUpdate transactions, so the title matches the changeset. It is a partial match in scope, since it says 'token_lifecycle' rather than naming the five classes. The title has a typo: 'Implemet' should be 'Implement'.
Full details: Description check
Explanation
The description states the PR adds the _from_protobuf method for token lifecycle transactions. It links issue #2616 and says tests and docs were done. This matches the changeset, though it gives little detail on which transaction classes are covered.
Full details: Out of Scope Changes check
Explanation
The change set stays within the issue scope. TokenType._from_proto and SupplyType._from_proto are enum converters that the token create restoration needs. Each _from_protobuf is limited to its token transaction class. The integration and unit tests cover the new deserialization paths. No unrelated public API signature change is reported. The change summary lists no changes to declarations of exported or public entities.
Full details: Linked Issues check
Explanation
[#2616] Requires _from_protobuf for TokenCreate, TokenUpdate, TokenDelete, TokenUpdateNfts, and TokenFeeScheduleUpdate, plus removal of xfail markers in the #2614 round-trip harness. The whole-PR diff of token_create_transaction.py adds _from_protobuf that calls super()._from_protobuf, restores fields from tokenCreation, and uses HasField for optional keys and fields. The change summary reports equivalent _from_protobuf methods for the other four classes and unit tests for each. Two points remain unresolved. (1) For treasury, the implementation substitutes AccountId(0, 0, 1) when the field is absent. The issue requires unset optional fields to stay None. The build-body logic that decides whether treasury is emitted was not inspected, so it is unknown whether this substitution breaks the round trip or byte-identical to_bytes(). (2) No change to a #2614 round-trip harness file appears in the change summary. Whether #2614 is merged, and whether the xfail markers exist in this repository, was not established.
Resolution
Confirm that TokenCreateTransaction.build_transaction_body() emits treasury only when set. If it does not, make the restored treasury None when treasury is absent, and confirm that the round trip keeps to_bytes() byte-identical. Confirm the state of #2614 and, if the harness is present, remove the xfail markers for the five types or state that the harness is not yet merged.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 6
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
⚠️ Outside diff range comments (2)
Major · Keep absent NFT metadata absent when rebuilding. · token_update_nfts_transaction.py:116
src/hiero_sdk_python/tokens/token_update_nfts_transaction.py:116 Major · Data Integrity & Integration · Quick win
Keep absent NFT metadata absent when rebuilding.
Proto field: metadata#3. Issue type: Asymmetric round-trip.
If the input omits metadata, the new deserializer retains None. This builder still creates a BytesValue message. In the supported protobuf Python implementation, value=None produces an empty wrapper, which becomes present in the parent message. Rebuilding therefore changes “leave metadata unchanged” into “clear metadata.” (raw.githubusercontent.com)
Suggested fix
- metadata=BytesValue(value=self.metadata),+ metadata=BytesValue(value=self.metadata) if self.metadata is not None else None,
As per path instructions, “No silent divergence in semantics.”
Source: Path instructions
Minor · Preserve explicitly empty update wrappers when rebuilding. · token_update_transaction.py:421-422
src/hiero_sdk_python/tokens/token_update_transaction.py:421-422 Minor · Data Integrity & Integration · Quick win
Preserve explicitly empty update wrappers when rebuilding.
Proto fields: memo#13 and metadata#16. Issue type: Asymmetric round-trip.
The new deserializer restores present empty wrappers as "" and b"". These truthiness checks then omit both fields. An unfrozen round trip changes a clearing request into a request that leaves the existing values unchanged. Use is not None to preserve presence. (raw.githubusercontent.com)
Suggested fix
- memo=StringValue(value=self.token_memo) if self.token_memo else None,- metadata=BytesValue(value=self.metadata) if self.metadata else None,+ memo=StringValue(value=self.token_memo) if self.token_memo is not None else None,+ metadata=BytesValue(value=self.metadata) if self.metadata is not None else None,
As per path instructions, “Every field parsed in _from_proto SHOULD also be serialized in _to_proto.”
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
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:
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
execute() can submit restored _transaction_body_bytes without rebuilding the body from copy_tx. The network assertions can therefore pass even if _from_protobuf fails to restore token_id or custom_fees.
Before execution, assert copy_tx.token_id, the fee count, and the restored fee's type, amount, and collector. Keep the network assertions to verify execution separately.
As per path instructions, “Suggest additional assertions that would strengthen correctness.” This also targets the PR's field-for-field restoration objective.
The restored transaction retains the original signed body bytes. Execution can submit those bytes even if _from_protobuf leaves token_id, serial_numbers, or metadata unset. The final metadata assertion does not detect that omission. (raw.githubusercontent.com)
After Line 295, compare those three attributes with nft_id, list(serials), and updated_metadata. Keep the signed execution and network assertions.
As per path instructions, “Suggest additional assertions that would strengthen correctness.”
Source: Path instructions
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
approvedIssue has been approved by team memberlang: pythonUses Python programming languageopen to community reviewPR is open for community review and feedbackqueue:junior-committerPR awaiting initial quality reviewskill: advancedrequires knowledge of multiple areas in the codebase without defined steps to implement or examples
3 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
This PR introduce implementation for the
_from_protobufmethod for the token lifecycle transaction.Related issue(s):
Fixes #2616
Notes for reviewer:
Checklist