Repository navigation
feat(tokens): add _from_protobuf support for token supply transactions - #2729
anchit-goel wants to merge 9 commits into
Conversation
Signed-off-by: anchit-goel <anchitgoel5@gmail.com>
b8ab87d to
02b2e8a
Compare
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughMint, burn, and wipe transactions now restore transaction-specific fields from protobuf data. Tests cover fungible and NFT restoration, absent fields, and byte-identical serialization after deserialization. ChangesToken supply transaction deserialization
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Severity of issue fixed: Medium Merge Risk: 🔵 Low · up to
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository: hiero-ledger/hiero-sdk-python/.coderabbit.yaml
- Review profile: ASSERTIVE
- Plan: Advanced
- Run ID:
7c0a4b63-907f-4056-994c-ea4b951a49c2
📒 Files selected for processing (6)
src/hiero_sdk_python/tokens/token_burn_transaction.pysrc/hiero_sdk_python/tokens/token_mint_transaction.pysrc/hiero_sdk_python/tokens/token_wipe_transaction.pytests/unit/token_burn_transaction_test.pytests/unit/token_mint_transaction_test.pytests/unit/token_wipe_transaction_test.py
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
| def _get_method(self, channel: _Channel) -> _Method: | ||
| return _Method(transaction_func=channel.token.mintToken, query_func=None) | ||
|
|
||
| @classmethod |
| def _get_method(self, channel: _Channel) -> _Method: | ||
| return _Method(transaction_func=channel.token.wipeTokenAccount, query_func=None) | ||
|
|
||
| def _from_proto(self, proto: TokenWipeAccountTransactionBody) -> TokenWipeTransaction: |
There was a problem hiding this comment.
this method should not be remove
| """ | ||
| return _Method(transaction_func=channel.token.burnToken, query_func=None) | ||
|
|
||
| def _from_proto(self, proto: TokenBurnTransactionBody) -> TokenBurnTransaction: |
There was a problem hiding this comment.
this method should not be remove
Signed-off-by: anchit-goel <anchitgoel5@gmail.com>
|
kindly review. |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository: hiero-ledger/hiero-sdk-python/.coderabbit.yaml
- Review profile: ASSERTIVE
- Plan: Advanced
- Run ID:
17979d4c-f12c-4cdb-a3e9-ffb5b44c6c5d
📒 Files selected for processing: 6
src/hiero_sdk_python/tokens/token_burn_transaction.pysrc/hiero_sdk_python/tokens/token_mint_transaction.pysrc/hiero_sdk_python/tokens/token_wipe_transaction.pytests/unit/token_burn_transaction_test.pytests/unit/token_mint_transaction_test.pytests/unit/token_wipe_transaction_test.py
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
Signed-off-by: anchit-goel <anchitgoel5@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository: hiero-ledger/hiero-sdk-python/.coderabbit.yaml
- Review profile: ASSERTIVE
- Plan: Advanced
- Run ID:
467c9ddd-3f0e-4520-b160-9881285f19c6
📒 Files selected for processing: 3
src/hiero_sdk_python/tokens/token_burn_transaction.pysrc/hiero_sdk_python/tokens/token_mint_transaction.pysrc/hiero_sdk_python/tokens/token_wipe_transaction.py
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
| transaction.serial = list(token_wipe_body.serialNumbers) | ||
| transaction.amount = None | ||
| else: | ||
| transaction.amount = token_wipe_body.amount |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
set -e
printf '%s\n' '--- diff ---'
git diff --no-ext-diff --unified=80 7260ea7290637399c6ac181ed893a567144d96eb 498055eae945a04fe589feec142586e3f53a7a38 -- src/hiero_sdk_python/tokens/token_wipe_transaction.py tests/unit/token_wipe_transaction_test.py
printf '%s\n' '--- current source ---'
nl -ba src/hiero_sdk_python/tokens/token_wipe_transaction.py | sed -n '1,270p'
printf '%s\n' '--- relevant tests ---'
rg -n -F --glob 'tests/**/*.py' -e 'TokenWipeTransaction' -e 'amount' -e 'serial' tests/unit/token_wipe_transaction_test.py || true
printf '%s\n' '--- proto field declaration ---'
rg -n -F --glob '*.py' -e 'class TokenWipeAccountTransactionBody' -e 'amount' src/hiero_sdk_python/hapi | head -80 || trueRepository: hiero-ledger/hiero-sdk-python
Length of output: 31814
🏁 Script executed:
set -e
printf '%s\n' '--- generated token-wipe module ---'
find . -path '*token_wipe_account_pb2.py' -print
printf '%s\n' '--- transaction deserialization ---'
rg -n -F -- 'def from_bytes' src/hiero_sdk_python/transaction src/hiero_sdk_python/tokens
rg -n -F -- '_from_protobuf(' src/hiero_sdk_python/transaction/transaction.py
nl -ba src/hiero_sdk_python/transaction/transaction.py | sed -n '240,360p'
printf '%s\n' '--- amount fixture definitions ---'
rg -n -F -- 'def amount' tests conftest.py src || true
rg -n -F -- 'amount =' tests/conftest.py tests || trueRepository: hiero-ledger/hiero-sdk-python
Length of output: 31137
Define and test the ambiguous zero-amount policy.
TokenWipeTransaction.amount defaults to None, but _from_protobuf assigns token_wipe_body.amount whenever serialNumbers is empty. A body with neither value therefore restores amount as 0. The protobuf amount field is a plain uint64, and the schema also permits amount = 0, so the wire value cannot distinguish an omitted amount from an explicit zero.
Define the public restoration policy for this ambiguous case. Add tests for the selected policy and document the wire-level limitation before changing this assignment. Do not apply a blanket or None conversion, because that would lose explicit zero amounts.
Source: Path instructions
Signed-off-by: anchit-goel <anchitgoel5@gmail.com>
|
Hello, this is the OfficeHourBot. This is a reminder that the Hiero Python SDK Office Hours will begin in approximately 3 hours and 56 minutes (14:00 UTC). This session provides an opportunity to ask questions regarding this Pull Request. Details:
Disclaimer: This is an automated reminder. Please verify the schedule here for any changes. From, |
Description:
Add
_from_protobufinverse-serialization support forTokenMintTransaction,TokenBurnTransaction, andTokenWipeTransactionso thatTransaction.from_bytes()restores type-specific fields accurately with byte-for-byte fidelity.@classmethod _from_protobuftoTokenMintTransaction, restoringtoken_id,amount, andmetadata@classmethod _from_protobuftoTokenBurnTransaction, restoringtoken_id,amount, andserials@classmethod _from_protobuftoTokenWipeTransaction, restoringtoken_id,account_id,amount, andserial_from_protoinstance methods fromTokenBurnTransactionandTokenWipeTransactionrestored.to_bytes() == original_bytes)test_burn_transaction_from_prototestRelated issue(s):
Fixes #2617
Notes for reviewer:
_from_protobufmethod cleanly falls back acrosssuper()._from_protobuf(transaction_body, ...)argument signatures to support both 1-arg and 3-arg callers.pytest tests/unit/token_mint_transaction_test.py tests/unit/token_burn_transaction_test.py tests/unit/token_wipe_transaction_test.py # 44 passed in 0.35sChecklist