Skip to content

fix(core): tron energy rental tips for token#616

Merged
somebodyLi merged 1 commit into
touchfrom
4.12.0
Dec 5, 2025
Merged

fix(core): tron energy rental tips for token#616
somebodyLi merged 1 commit into
touchfrom
4.12.0

Conversation

@somebodyLi

@somebodyLi somebodyLi commented Dec 5, 2025

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of unknown tokens during TRON transaction confirmations.
  • Refactor

    • Streamlined TRON transaction confirmation flow for better consistency in token information display.

✏️ Tip: You can customize this high-level summary in your review settings.

@somebodyLi somebodyLi requested a review from a team as a code owner December 5, 2025 08:44
@revan-zhang

revan-zhang commented Dec 5, 2025

Copy link
Copy Markdown
Contributor

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@coderabbitai

coderabbitai Bot commented Dec 5, 2025

Copy link
Copy Markdown

Walkthrough

The TRON layout and transaction signing flow refactored confirmation logic. require_confirm_tx now accepts a token parameter instead of banner_text. Unknown token handling moved to a dedicated confirmation function. The require_confirm_trigger_trc20 function removed entirely.

Changes

Cohort / File(s) Change Summary
Confirmation function updates
core/src/apps/tron/layout.py
Modified require_confirm_tx signature: replaced banner_text parameter with token: TokenInfo. Internal logic now computes banner_text based on address/provider matching. Updated amount formatting to use token parameter. Added new require_confirm_unknown_token function for dedicated unknown-token confirmation flow. Removed require_confirm_trigger_trc20 function entirely.
Transaction signing updates
core/src/apps/tron/sign_tx.py
Removed provider-related imports and banner_text handling. Updated TRC20 transfer/approval logic to use local token_addr variable. Added explicit branch to handle unknown tokens with new confirmation prompt. Simplified TRC20 confirmation call signature and parameter order.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Function signature changes: require_confirm_tx parameter swap requires verifying all call sites use the new token parameter correctly
  • Function removal: Confirm require_confirm_trigger_trc20 was deprecated and no orphaned references exist
  • Unknown token logic: Verify the new require_confirm_unknown_token flow integrates properly with TRC20 transfer handling
  • Banner text refactoring: Ensure provider-based banner logic moved correctly from sign_tx to layout

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title mentions 'energy rental tips for token' but the changes focus on restructuring token confirmation flows and updating function signatures, not energy rental features. Revise the title to accurately reflect the main changes: something like 'refactor(core): restructure tron token confirmation flow' or 'refactor(core): update tron token confirmation handling'.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 4.12.0

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between eb7f10f and c2b7a1a.

📒 Files selected for processing (2)
  • core/src/apps/tron/layout.py (1 hunks)
  • core/src/apps/tron/sign_tx.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
core/src/apps/tron/sign_tx.py (3)
core/src/apps/tron/tokens.py (1)
  • token_by_address (20-29)
core/src/apps/tron/address.py (1)
  • _address_base58 (10-11)
core/src/apps/tron/layout.py (2)
  • require_confirm_unknown_token (53-64)
  • require_confirm_tx (31-50)
core/src/apps/tron/layout.py (6)
core/src/apps/tron/tokens.py (1)
  • TokenInfo (9-14)
core/src/apps/tron/providers.py (1)
  • provider_by_address (16-20)
core/src/trezor/ui/layouts/lvgl/__init__.py (2)
  • confirm_output (482-516)
  • confirm_address (678-699)
core/src/apps/ethereum/layout.py (1)
  • require_confirm_unknown_token (158-171)
core/src/apps/conflux/layout.py (1)
  • require_confirm_unknown_token (99-109)
core/src/trezor/wire/__init__.py (1)
  • Context (151-297)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Gen check
  • GitHub Check: Defs check
  • GitHub Check: Style check
🔇 Additional comments (3)
core/src/apps/tron/sign_tx.py (1)

77-89: TRC20 flow and unknown-token confirm look good; please double-check contract address format

The updated TRC20 transfer path is coherent: you derive token, gate on UNKNOWN_TOKEN with a dedicated confirmation, and then pass token through to require_confirm_tx and require_confirm_fee. The positional args match the new require_confirm_tx(ctx, to, value, token) signature.

One thing to verify: is contract.trigger_smart_contract.contract_address already in the final, human-readable form you want to show (e.g., base58 T... string) when you pass it as token_addr into require_confirm_unknown_token and tokens.token_by_address? If it is still raw bytes or a hex blob, you may want to normalize it first so the lookup and the on-device display both use the same canonical format.

core/src/apps/tron/layout.py (2)

31-50: Token-aware require_confirm_tx and energy-rental banner look consistent

The new require_confirm_tx signature and body read cleanly:

  • token plumbs through to format_amount_trx, so TRX and TRC20 now share the same confirmation path.
  • banner_text is local and only set when provider_by_address(to) returns a match, which keeps the energy-rental tip scoped and removes the old banner plumbing from callers.

Assuming all callers pass a normalized Tron address string for to (same format used in provider_by_address), this change should behave as intended for both native and token transfers.


53-64: Unknown-token confirmation matches established UX patterns

require_confirm_unknown_token is a straightforward wrapper and matches the pattern used in other chains: clear “Unknown Token” title, contract address as the main value, “Contract:” description, br_type="unknown_token", and a warning icon.

No functional issues here; it should give users an explicit extra checkpoint before signing unknown TRON tokens.


Comment @coderabbitai help to get the list of available commands and usage tips.

@somebodyLi somebodyLi merged commit da09c43 into touch Dec 5, 2025
14 checks passed
@somebodyLi somebodyLi deleted the 4.12.0 branch December 5, 2025 09:00
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.

4 participants