Skip to content

feat(core): add support for tron cancel unstake#289

Merged
somebodyLi merged 1 commit intomainfrom
feat/misc
Apr 14, 2025
Merged

feat(core): add support for tron cancel unstake#289
somebodyLi merged 1 commit intomainfrom
feat/misc

Conversation

@somebodyLi
Copy link
Copy Markdown
Contributor

@somebodyLi somebodyLi commented Apr 14, 2025

  1. increase the size of qr code decode buffer

Summary by CodeRabbit

  • New Features
    • Introduced a new option to cancel all unfreeze operations in Tron transactions with an updated confirmation process.
    • Enhanced QR code scanning to support larger codes and include improved error recovery for a smoother experience.
    • Streamlined the asset freeze interface so that additional transaction details are shown only when relevant, resulting in a cleaner display.

1. increase the size of qr code decode buffer
@somebodyLi somebodyLi requested a review from a team as a code owner April 14, 2025 10:41
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 14, 2025

Walkthrough

This pull request introduces a new Tron contract type to cancel all unfreeze operations. It adds the TronCancelAllUnfreezeV2Contract definition to protocol messages and updates serialization and transaction signing logic to handle this option. A new UI confirmation function is implemented, and the asset freeze interface logic is streamlined. Additionally, the QR code scanning functionality is improved by increasing the buffer size and adding error handling.

Changes

File(s) Change Summary
common/protob/messages-tron.proto, core/src/apps/tron/{serialize.py,sign_tx.py}, core/src/trezor/messages.py, python/src/trezorlib/messages.py Adds new TronCancelAllUnfreezeV2Contract and corresponding fields/branches to protocol definitions, serialization, and transaction signing.
core/src/apps/tron/layout.py, core/src/trezor/lvglui/scrs/template.py Introduces a new confirmation function and streamlines UI container creation for Tron transactions.
core/embed/.../modtrezorio-camera.h, core/src/trezor/qr.py Increases QR code buffer size and wraps the scanning call with error handling.

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 53d859a and cc528e1.

📒 Files selected for processing (9)
  • common/protob/messages-tron.proto (2 hunks)
  • core/embed/extmod/modtrezorio/modtrezorio-camera.h (1 hunks)
  • core/src/apps/tron/layout.py (1 hunks)
  • core/src/apps/tron/serialize.py (1 hunks)
  • core/src/apps/tron/sign_tx.py (1 hunks)
  • core/src/trezor/lvglui/scrs/template.py (1 hunks)
  • core/src/trezor/messages.py (3 hunks)
  • core/src/trezor/qr.py (1 hunks)
  • python/src/trezorlib/messages.py (4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (5)
core/src/apps/tron/layout.py (2)
core/src/trezor/wire/__init__.py (1)
  • Context (236-386)
core/src/trezor/ui/layouts/lvgl/__init__.py (1)
  • confirm_tron_unfreeze (2274-2299)
core/src/trezor/qr.py (1)
core/src/trezor/lvglui/scrs/homescreen.py (1)
  • error_feedback (2211-2217)
core/src/trezor/lvglui/scrs/template.py (2)
core/src/trezor/lvglui/scrs/components/container.py (2)
  • ContainerFlexCol (8-48)
  • add_dummy (44-48)
core/src/trezor/lvglui/scrs/components/listitem.py (2)
  • CardHeader (193-226)
  • DisplayItem (109-163)
python/src/trezorlib/messages.py (2)
python/src/trezorlib/protobuf.py (2)
  • Field (148-179)
  • MessageType (189-249)
core/src/trezor/messages.py (1)
  • TronCancelAllUnfreezeV2Contract (9483-9487)
core/src/trezor/messages.py (2)
python/src/trezorlib/messages.py (2)
  • TronCancelAllUnfreezeV2Contract (11722-11723)
  • MessageType (31-451)
core/src/trezor/enums/__init__.py (1)
  • MessageType (23-443)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Defs check
  • GitHub Check: Style check
  • GitHub Check: Gen check
🔇 Additional comments (14)
python/src/trezorlib/messages.py (4)

11502-11502: Field added to TronContract

New field for cancel_all_unfreeze_v2_contract looks good.


11522-11522: Parameter added to constructor

Parameter matches the new field.


11538-11538: Initialization in constructor

Properly initializes the new field.


11722-11724: New contract class definition

Empty message class for the new contract type looks correct.

core/embed/extmod/modtrezorio/modtrezorio-camera.h (1)

35-35: Buffer size increase looks good.

Doubling the QR code buffer from 512 to 1024 bytes will allow handling larger QR codes, which is necessary for more complex transaction data.

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

238-245: New confirmation function for cancel unstake.

The function implementation properly integrates with the existing confirmation UI system and provides clear context to users.

core/src/trezor/qr.py (1)

217-224: Good error handling addition.

Added try-except block prevents scanning loop crashes and provides user feedback on errors.

common/protob/messages-tron.proto (2)

108-109: New contract type definition looks correct.

Empty message structure matches other similar contract definitions in the file.


130-130: Contract integration properly implemented.

Field number (59) follows the sequential numbering pattern of other contract types.

core/src/apps/tron/sign_tx.py (1)

182-186: LGTM - Added support for cancel_all_unfreeze_v2_contract.

The code follows existing patterns and is correctly implemented.

core/src/apps/tron/serialize.py (1)

217-221: LGTM - Added serialization for cancel_all_unfreeze_v2_contract.

The code correctly implements serialization for the new contract type with proper contract type ID (59).

core/src/trezor/messages.py (2)

9483-9488: New class added correctly for TronCancelAllUnfreezeV2Contract.


9289-9289: Changes to TronContract support the new operation.

New field and constructor parameter added properly for cancel_all_unfreeze_v2_contract.

Also applies to: 9308-9308

core/src/trezor/lvglui/scrs/template.py (1)

4323-4363: Good refactoring for UI initialization logic.

The code now efficiently checks for any parameter presence before creating the UI container, rather than using separate checks. This streamlines the flow and makes maintenance easier.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@somebodyLi somebodyLi enabled auto-merge (squash) April 14, 2025 10:47
@somebodyLi somebodyLi merged commit ceac15b into main Apr 14, 2025
7 checks passed
@somebodyLi somebodyLi deleted the feat/misc branch April 14, 2025 13:18
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.

3 participants