diff --git a/core/src/apps/cardano/layout.py b/core/src/apps/cardano/layout.py index 39da0f3710..450eefb676 100644 --- a/core/src/apps/cardano/layout.py +++ b/core/src/apps/cardano/layout.py @@ -9,6 +9,7 @@ from trezor.enums import ( ) from trezor.strings import format_amount from trezor.ui import layouts +from trezor.ui.layouts import confirm_metadata, confirm_properties from apps.common.paths import address_n_to_str @@ -21,9 +22,6 @@ from .helpers.utils import ( format_stake_pool_id, ) -confirm_metadata = layouts.confirm_metadata # global_import_cache -confirm_properties = layouts.confirm_properties # global_import_cache - if TYPE_CHECKING: from typing import Literal diff --git a/core/src/apps/common/passphrase.py b/core/src/apps/common/passphrase.py index 8ebeed5b04..44ba512b1c 100644 --- a/core/src/apps/common/passphrase.py +++ b/core/src/apps/common/passphrase.py @@ -7,6 +7,7 @@ from trezor.wire import DataError if TYPE_CHECKING: from trezor.wire import Context + _MAX_PASSPHRASE_LEN = const(50) diff --git a/core/src/apps/debug/__init__.py b/core/src/apps/debug/__init__.py index 2759335ebf..eded456425 100644 --- a/core/src/apps/debug/__init__.py +++ b/core/src/apps/debug/__init__.py @@ -122,9 +122,11 @@ if __debug__: if debuglink_decision_chan.putters: log.warning(__name__, "DebugLinkDecision queue is not empty") + x = msg.x # local_cache_attribute y = msg.y # local_cache_attribute + # TT click on specific coordinates, with possible hold if x is not None and y is not None: evt_down = io.TOUCH_START, x, y evt_up = io.TOUCH_END, x, y @@ -133,6 +135,7 @@ if __debug__: loop.schedule(touch_hold(x, y, msg.hold_ms)) else: loop.synthetic_events.append((io.TOUCH, evt_up)) + # Something more general else: debuglink_decision_chan.publish(msg) diff --git a/core/src/apps/homescreen/res/bg.toif b/core/src/apps/homescreen/res/bg.toif deleted file mode 100644 index bfd515f39e..0000000000 Binary files a/core/src/apps/homescreen/res/bg.toif and /dev/null differ diff --git a/core/src/boot.py b/core/src/boot.py index e9a668939e..2fb0104d06 100644 --- a/core/src/boot.py +++ b/core/src/boot.py @@ -26,8 +26,8 @@ _WELCOME_SCREEN_MS = 1200 # how long do we want to show welcome screen (minimum def enforce_welcome_screen_duration() -> None: """Make sure we will show the welcome screen for appropriate amount of time.""" - # Not wasting the time in debug builds (saves time during emulator debugging) - if __debug__: + # Not wasting the time in emulator debug builds (debugging and development) + if __debug__ and utils.EMULATOR: return while utime.ticks_ms() - welcome_screen_start_ms < _WELCOME_SCREEN_MS: utime.sleep_ms(100) diff --git a/core/src/trezor/ui/layouts/common.py b/core/src/trezor/ui/layouts/common.py index 478134ea78..dd721981e4 100644 --- a/core/src/trezor/ui/layouts/common.py +++ b/core/src/trezor/ui/layouts/common.py @@ -38,6 +38,7 @@ async def interact( br_code: ButtonRequestType = ButtonRequestType.Other, ) -> Any: if hasattr(layout, "page_count") and layout.page_count() > 1: # type: ignore [Cannot access member "page_count" for type "LayoutType"] + # We know for certain how many pages the layout will have await button_request(ctx, br_type, br_code, pages=layout.page_count()) # type: ignore [Cannot access member "page_count" for type "LayoutType"] return await ctx.wait(layout) else: diff --git a/core/src/trezor/ui/layouts/tt_v2/__init__.py b/core/src/trezor/ui/layouts/tt_v2/__init__.py index 58783bcecf..bacd9ed3e0 100644 --- a/core/src/trezor/ui/layouts/tt_v2/__init__.py +++ b/core/src/trezor/ui/layouts/tt_v2/__init__.py @@ -131,7 +131,6 @@ class RustLayout(ui.Layout): touch = loop.wait(io.TOUCH) self._first_paint() - # self.layout.bounds() while True: # Using `yield` instead of `await` to avoid allocations. event, x, y = yield touch @@ -142,7 +141,6 @@ class RustLayout(ui.Layout): if msg is not None: raise ui.Result(msg) self._paint() - # self.layout.bounds() def handle_timers(self) -> loop.Task: # type: ignore [awaitable-is-generator] while True: @@ -357,12 +355,12 @@ async def show_address( xpubs: Sequence[str] = (), ) -> None: send_button_request = True + title = ( + "RECEIVE ADDRESS\n(MULTISIG)" + if multisig_index is not None + else "RECEIVE ADDRESS" + ) while True: - title = ( - "RECEIVE ADDRESS\n(MULTISIG)" - if multisig_index is not None - else "RECEIVE ADDRESS" - ) layout = RustLayout( trezorui2.confirm_address( title=title, @@ -388,7 +386,7 @@ async def show_address( # User pressed corner button or swiped left, go to address details. elif result is INFO: - def xpub_title(i: int): + def xpub_title(i: int) -> str: result = f"MULTISIG XPUB #{i + 1}\n" result += "(YOURS)" if i == multisig_index else "(COSIGNER)" return result @@ -775,7 +773,7 @@ def confirm_value( value: str, description: str, br_type: str, - br_code: ButtonRequestType = ButtonRequestType.Other, + br_code: ButtonRequestType = BR_TYPE_OTHER, *, verb: str | None = None, subtitle: str | None = None, @@ -1021,7 +1019,7 @@ async def confirm_coinjoin( ) ), "coinjoin_final", - ButtonRequestType.Other, + BR_TYPE_OTHER, ) ) @@ -1036,7 +1034,7 @@ async def confirm_sign_identity( data=identity, description=challenge_visual + "\n" if challenge_visual else "", br_type="sign_identity", - br_code=ButtonRequestType.Other, + br_code=BR_TYPE_OTHER, ) @@ -1056,7 +1054,7 @@ async def confirm_signverify( title, address, "Confirm address:", - br_code=ButtonRequestType.Other, + br_code=BR_TYPE_OTHER, ) await confirm_blob( @@ -1065,7 +1063,7 @@ async def confirm_signverify( title, message, "Confirm message:", - br_code=ButtonRequestType.Other, + br_code=BR_TYPE_OTHER, ) @@ -1139,9 +1137,8 @@ async def request_pin_on_device( wrong_pin=wrong_pin, ) ) - while True: - result = await ctx.wait(dialog) - if result is CANCELLED: - raise PinCancelled - assert isinstance(result, str) - return result + result = await ctx.wait(dialog) + if result is CANCELLED: + raise PinCancelled + assert isinstance(result, str) + return result diff --git a/core/src/trezor/ui/layouts/tt_v2/reset.py b/core/src/trezor/ui/layouts/tt_v2/reset.py index ec45ba1bc5..93e8203de1 100644 --- a/core/src/trezor/ui/layouts/tt_v2/reset.py +++ b/core/src/trezor/ui/layouts/tt_v2/reset.py @@ -9,7 +9,7 @@ from ..common import interact from . import RustLayout if TYPE_CHECKING: - from typing import Callable, Sequence, List + from typing import Callable, Sequence from trezor.enums import BackupType from trezor.wire import GenericContext @@ -17,8 +17,8 @@ if TYPE_CHECKING: CONFIRMED = trezorui2.CONFIRMED # global_import_cache -def _split_share_into_pages(share_words: Sequence[str], per_page: int = 4) -> List[str]: - pages = [] +def _split_share_into_pages(share_words: Sequence[str], per_page: int = 4) -> list[str]: + pages: list[str] = [] current = "" for i, word in enumerate(share_words): diff --git a/core/src/trezor/wire/__init__.py b/core/src/trezor/wire/__init__.py index 607c605578..30d336917f 100644 --- a/core/src/trezor/wire/__init__.py +++ b/core/src/trezor/wire/__init__.py @@ -466,7 +466,13 @@ def failure(exc: BaseException) -> Failure: elif isinstance(exc, InvalidSessionError): return Failure(code=FailureType.InvalidSession, message="Invalid session") else: - return Failure(code=FailureType.FirmwareError, message="Firmware error") + # NOTE: when receiving generic `FirmwareError` on non-debug build, + # change the `if __debug__` to `if True` to get the full error message. + if __debug__: + message = f"Firmware error - {exc}" + else: + message = "Firmware error" + return Failure(code=FailureType.FirmwareError, message=message) def unexpected_message() -> Failure: