TRON Phase 2b: Stake 2.0 freeze/unfreeze/withdraw-expire-unfreeze - #22
Merged
Conversation
Adds three preparation tools for TRON Stake 2.0 resource management: freeze TRX for bandwidth or energy (gains voting power), unfreeze (begins the 14-day cooldown), and sweep matured slices back to liquid TRX. Resource names use lowercase on the API surface (matching the staking reader) and are uppercased at the TronGrid edge. Preview-only until the Phase 3 USB HID signer lands; send_transaction still refuses TRON handles. The freeze tool description flags explicitly that rewards require a separate VoteWitness step (queued as Phase 2c). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
prepare_tron_freeze,prepare_tron_unfreeze,prepare_tron_withdraw_expire_unfreeze. Each hits TronGrid's v2 staking endpoints withvisible: true, uppercases thebandwidth/energyresource at the edge, and returns an opaque handle.UnsignedTronTx.actionunion extended additively —freeze,unfreeze,withdraw_expire_unfreeze.send_transactionrefuses TRON handles until the USB HID signer lands.prepare_tron_freeze's description explicitly calls out that freezing alone does not earn rewards — VoteWitness is required and is queued separately as Phase 2c (see follow-up issue).Test plan
npx vitest run— 296/296 pass (11 new tests intest/tron-phase2b-stake-writes.test.tscovering POST body shape, resource uppercasing, preview copy, handle issuance, and TronGrid error passthrough for overshoot/no-mature cases).npm run build— clean tsc.prepare_tron_freezewithresource: "bandwidth"against a real address; inspect the returnedtxIDand cross-check against a direct/wallet/freezebalancev2call.prepare_tron_unfreezewith an overshoot amount; confirm TronGrid'sless than frozen balancesurfaces verbatim.prepare_tron_withdraw_expire_unfreezeon an address with no matured slices; confirmno expire unfreezesurfaces.Follow-ups
prepare_tron_vote— required for freezes to actually accrue rewards.@ledgerhq/hw-app-trx.🤖 Generated with Claude Code