-
Notifications
You must be signed in to change notification settings - Fork 6
feat(core): misc features add #286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
1. the passphrase input on device supports edit before commit. 2. mnemonics support edits if make mistake in input process 3. fingerprint unlock error tips in pin input screen
WalkthroughThis pull request refactors control flows and updates function signatures. It introduces error handling for passphrase confirmation and adjusts mnemonic recovery logic with interactive word handling. The changes update network specifications for Neo to “Neo N3” and modify signature methods for SUI messages and transactions. UI components such as buttons, passphrase displays, and pin screens now have additional methods and refined state handling. LVGL layout functions and common sign/verify routines also receive updated type support and streamlined processing. Changes
Tip ⚡💬 Agentic Chat (Pro Plan, General Availability)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (3)
core/src/trezor/lvglui/scrs/recovery_device.py (1)
111-115
: Comment doesn't match code.Comment says "3 columns" but code defines 2 columns.
- # 3 columns + # 2 columnscore/src/trezor/lvglui/scrs/pinscreen.py (1)
259-263
: Empty exception handler should use contextlib.suppress.Use contextlib.suppress for cleaner exception handling:
-def anim_set_x(self, val): - try: - self.fingerprint_prompt.set_x(val) - except Exception: - pass +def anim_set_x(self, val): + from contextlib import suppress + with suppress(Exception): + self.fingerprint_prompt.set_x(val)🧰 Tools
🪛 Ruff (0.8.2)
260-263: Use
contextlib.suppress(Exception)
instead oftry
-except
-pass
Replace with
contextlib.suppress(Exception)
(SIM105)
core/src/trezor/ui/layouts/lvgl/__init__.py (1)
1142-1148
: Missing return type hint for boolean returnFunction now returns a boolean but lacks return type annotation.
-async def require_confirm_passphrase( - ctx: wire.GenericContext, passphrase: str, from_device: bool = False -) -> bool: +async def require_confirm_passphrase( + ctx: wire.GenericContext, passphrase: str, from_device: bool = False +) -> bool:
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (16)
core/src/apps/common/passphrase.py
(1 hunks)core/src/apps/common/signverify.py
(2 hunks)core/src/apps/management/recovery_device/homescreen.py
(3 hunks)core/src/apps/management/recovery_device/layout.py
(1 hunks)core/src/apps/neo/get_address.py
(1 hunks)core/src/apps/neo/helpers.py
(1 hunks)core/src/apps/sui/sign_message.py
(1 hunks)core/src/apps/sui/sign_tx.py
(4 hunks)core/src/trezor/lvglui/scrs/address.py
(1 hunks)core/src/trezor/lvglui/scrs/components/button.py
(1 hunks)core/src/trezor/lvglui/scrs/passphrase.py
(3 hunks)core/src/trezor/lvglui/scrs/pinscreen.py
(3 hunks)core/src/trezor/lvglui/scrs/recovery_device.py
(2 hunks)core/src/trezor/lvglui/scrs/template.py
(4 hunks)core/src/trezor/uart.py
(1 hunks)core/src/trezor/ui/layouts/lvgl/__init__.py
(3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (5)
core/src/trezor/lvglui/scrs/components/button.py (1)
core/src/trezor/lvglui/lv_colors.py (1)
lv_colors
(9-68)
core/src/apps/sui/sign_tx.py (2)
core/src/trezor/utils.py (4)
extend
(473-474)extend
(486-487)extend
(533-534)digest
(460-461)core/src/trezor/ui/layouts/lvgl/__init__.py (1)
confirm_blind_sign_common
(1481-1499)
core/src/apps/management/recovery_device/homescreen.py (2)
core/src/trezor/ui/layouts/lvgl/recovery.py (1)
request_word
(31-42)core/src/apps/management/recovery_device/layout.py (2)
request_mnemonic
(64-103)show_invalid_mnemonic
(156-166)
core/src/trezor/lvglui/scrs/recovery_device.py (4)
core/src/trezor/utils.py (1)
lcd_resume
(167-196)core/src/trezor/lvglui/scrs/common.py (1)
FullSizeWindow
(360-639)core/src/trezor/lvglui/scrs/components/button.py (2)
NormalButton
(14-80)enable_no_bg_mode
(73-80)core/src/trezor/lvglui/scrs/components/container.py (1)
ContainerGrid
(114-146)
core/src/trezor/ui/layouts/lvgl/__init__.py (3)
core/src/trezor/enums/__init__.py (1)
ButtonRequestType
(462-482)core/src/trezor/lvglui/scrs/template.py (1)
PassphraseDisplayConfirm
(2398-2451)core/src/trezor/lvglui/scrs/passphrase.py (1)
PassphraseRequest
(8-47)
🪛 Ruff (0.8.2)
core/src/trezor/lvglui/scrs/pinscreen.py
260-263: Use contextlib.suppress(Exception)
instead of try
-except
-pass
Replace with contextlib.suppress(Exception)
(SIM105)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Gen check
- GitHub Check: Style check
- GitHub Check: Defs check
🔇 Additional comments (43)
core/src/trezor/lvglui/scrs/address.py (1)
321-321
: LGTM: Network name updated to "Neo N3"The network name change maintains consistency with other files.
core/src/apps/neo/helpers.py (1)
48-48
: LGTM: Network name updated to "Neo N3"The return value change is consistent with the codebase updates.
core/src/apps/neo/get_address.py (1)
36-36
: LGTM: Network name updated to "Neo N3"The parameter value change aligns with network naming across the codebase.
core/src/apps/common/passphrase.py (1)
67-68
: LGTM: Good addition of cancel handlingThe check for cancelled passphrase is a needed safeguard.
core/src/apps/sui/sign_tx.py (5)
1-2
: Import needed for gc.collect()Necessary import for memory management.
35-35
: Better performance with extendUsing extend() instead of += improves memory usage.
44-44
: Better performance with extendUsing extend() instead of += improves memory usage.
62-63
: Memory optimizationGood practice to collect garbage before processing chunks.
47-47
:✅ Verification successful
Verify parameter type
Confirm blind_sign_common accepts bytearray directly without bytes() conversion.
🏁 Script executed:
#!/bin/bash grep -r "def confirm_blind_sign_common" --include="*.py" .Length of output: 143
Parameter type verified.
The function incore/src/trezor/ui/layouts/lvgl/__init__.py
accepts a bytearray directly. No conversion is needed.core/src/apps/common/signverify.py (2)
46-48
: Good memory management for large messagesCollecting garbage for large messages prevents memory issues.
53-54
: Garbage collection in exception handlerSmart to free memory when handling decode errors.
core/src/trezor/uart.py (1)
112-118
: Good enhancement to fingerprint failure handling.The code now displays context-sensitive error messages for fingerprint authentication failures directly in the PIN input screen, improving the user feedback experience.
core/src/apps/management/recovery_device/layout.py (1)
156-166
: Improved mnemonic validation flow.The function now takes a list of mnemonic words and returns context-appropriate feedback via the InvalidMnemonic screen, supporting the mnemonic editing feature.
core/src/trezor/lvglui/scrs/passphrase.py (3)
9-9
: Function signature properly updated.The
__init__
method now accepts an optional result parameter with proper type annotation.
22-24
: Good implementation of passphrase editing.Setting the text and cursor position enables the user to edit previously entered passphrases.
38-39
: Variable name improved.Renamed from 'input' to 'input_text' avoiding confusion with Python's built-in function.
core/src/apps/sui/sign_message.py (1)
27-36
: More efficient hashing implementation.The sequential update approach eliminates unnecessary string concatenation while maintaining the same cryptographic result.
core/src/apps/management/recovery_device/homescreen.py (4)
13-13
: Necessary import for new functionality.Import of
request_word
function is needed for the new mnemonic editing feature.
108-108
: Initialize variable before use.Good practice to initialize
words
to None at start.
111-127
: Improved control flow for recovery process.Better structured approach with clearer error handling.
136-156
: New feature: edit individual mnemonic words.This implementation allows users to correct specific words in an invalid mnemonic instead of starting over.
core/src/trezor/lvglui/scrs/recovery_device.py (6)
1-7
: Necessary imports for new UI component.Added imports for LCD control and UI components.
14-14
: Type annotation added.Better code clarity with type hints.
98-123
: New InvalidMnemonic UI class.Implements grid layout for displaying invalid mnemonic words.
124-159
: UI components for word selection.Word display with proper styling and layout.
162-169
: Click handling for word selection.Properly identifies selected word and publishes index.
170-179
: Event handling for cancel button.Handles "Start Over" button action correctly.
core/src/trezor/lvglui/scrs/template.py (4)
608-608
: Horizontal padding added.The button now has proper spacing for better visual appearance.
1296-1296
: Fixed page size for content display.The page size parameter ensures consistent viewing experience.
2399-2414
: Enhanced passphrase workflow with dynamic button text and warning.The new parameter
from_device
controls the cancel button text, showing "Edit" when appropriate. The warning banner alerts users about the risk of forgetting their passphrase.
2418-2418
: Aligned panel with warning banner.Panel alignment adjusted to accommodate the new warning banner.
core/src/trezor/lvglui/scrs/pinscreen.py (8)
181-185
: Subtitle extracted to local variable before use.Improves code readability by making the parameter flow clearer.
197-210
: Improved subtitle styling with dynamic background.Background color now changes based on content, making error messages more visible.
212-214
: Consistent subtitle alignment.Subtitle position now properly calculated relative to title height.
228-239
: Added method to change subtitle dynamically.Centralizes subtitle update logic for consistent appearance.
247-258
: Animation setup for fingerprint prompt.Animation parameters properly configured as instance attributes.
269-271
: Enhanced cleanup in refresh_fingerprint_prompt.Proper attribute deletion and subtitle clearing.
275-292
: Added fingerprint error feedback.Different error messages based on failure type improve user experience.
301-304
: Renamed variable to avoid shadowing built-in.Changed
input
toinput_text
to avoid shadowing Python's built-in function.core/src/trezor/ui/layouts/lvgl/__init__.py (4)
755-755
: Increased function flexibility by accepting bytearray paramThe function now accepts a
bytearray
type for thedata
parameter, expanding its flexibility.
1121-1139
: Added passphrase editing capabilityLoop implementation allows correcting passphrase inputs before commitment, matching PR objectives for improved input editing.
1482-1482
: Extended raw_message param to accept bytearrayFunction now accepts both bytes and bytearray types for the raw_message parameter.
762-765
:❓ Verification inconclusive
Logic change for large data handling
Different prefix behavior based on data size could cause display inconsistency.
🏁 Script executed:
# Check if there are examples of this function being called with large data grep -r "confirm_data" --include="*.py" . | grep -v "__init__.py"Length of output: 2173
Data display inconsistency detected
- Data longer than 1024 bytes omits the "0x" prefix.
- Confirm that all consumers of
confirm_data
handle this formatting appropriately.
Summary by CodeRabbit
New Features
Bug Fixes