Skip to content

feat(tron): decode WithdrawBalanceContract (claim rewards)#377

Open
prasanna-anchorage wants to merge 1 commit into
mainfrom
tron-add-withdrawbalance-contract
Open

feat(tron): decode WithdrawBalanceContract (claim rewards)#377
prasanna-anchorage wants to merge 1 commit into
mainfrom
tron-add-withdrawbalance-contract

Conversation

@prasanna-anchorage

Copy link
Copy Markdown
Contributor

Summary

Adds full decoding for Tron's WithdrawBalanceContract — the operation that claims accumulated voting / Super Representative rewards into the owner's balance. Previously this contract type fell through to the generic (not fully decoded) catch-all, showing the signer only the raw type.googleapis.com/protocol.WithdrawBalanceContract type URL.

What it decodes

The contract carries only an owner_address; the reward amount is computed on-chain at execution time and is not part of the transaction. The payload now surfaces:

  • Contract Type: WithdrawBalance (Claim Rewards)
  • Owner: <base58 address>

This is distinct from the already-supported WithdrawExpireUnfreeze (claim unfrozen TRX).

Implementation

  • Added WithdrawBalanceContract to the anychain_tron::protocol::balance_contract import group.
  • New match arm in decode_contract(), following the existing WithdrawExpireUnfreeze pattern.

Testing

  • synthetic_withdraw_balance — builds a transaction programmatically and asserts the contract type, owner field, and the absence of amount/resource fields.
  • cargo test -p visualsign-tron — 23 passed
  • cargo clippy -p visualsign-tron --all-targets -- -D warnings — clean
  • cargo fmt applied

🤖 Generated with Claude Code

Add full decoding for WithdrawBalanceContract, the Tron operation that
claims accumulated voting / Super Representative rewards into the owner's
balance. Previously it fell through to the "(not fully decoded)" catch-all.

The contract carries only the owner address; the reward amount is computed
on-chain at execution time, so the payload surfaces the contract type and
owner. Distinct from WithdrawExpireUnfreeze (claim unfrozen TRX).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 17, 2026 21:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds full decoding support for Tron’s WithdrawBalanceContract so VisualSign displays a human-readable contract type and owner address when claiming SR/voting rewards (instead of falling back to the generic “not fully decoded” output).

Changes:

  • Import WithdrawBalanceContract from anychain_tron::protocol::balance_contract.
  • Add a decode_contract() match arm to decode and surface Contract Type + Owner for type.googleapis.com/protocol.WithdrawBalanceContract.
  • Add a synthetic unit test validating the decoded fields and confirming no Amount/Resource fields are emitted.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@prasanna-anchorage prasanna-anchorage added tron chain:tron Tron chain parser and removed tron labels Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chain:tron Tron chain parser

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants