From 45639eeacfb0634563bbda0f62e52b8014682e8a Mon Sep 17 00:00:00 2001 From: grdddj Date: Wed, 23 Aug 2023 10:45:59 +0200 Subject: [PATCH] chore(core): change error screens according to design [no changelog] --- core/src/apps/common/request_pin.py | 5 +---- core/src/trezor/ui/layouts/tr/__init__.py | 13 ++++--------- core/src/trezor/ui/layouts/tt_v2/__init__.py | 2 +- tests/click_tests/common.py | 9 +++++++-- tests/click_tests/test_pin.py | 2 +- 5 files changed, 14 insertions(+), 17 deletions(-) diff --git a/core/src/apps/common/request_pin.py b/core/src/apps/common/request_pin.py index be2b3b4ab7..fb9ab15194 100644 --- a/core/src/apps/common/request_pin.py +++ b/core/src/apps/common/request_pin.py @@ -3,6 +3,7 @@ from typing import Any, NoReturn import storage.cache as storage_cache from trezor import config, utils, wire +from trezor.ui.layouts import show_error_and_raise async def _request_sd_salt( @@ -125,8 +126,6 @@ async def verify_user_pin( async def error_pin_invalid() -> NoReturn: - from trezor.ui.layouts import show_error_and_raise - await show_error_and_raise( "warning_wrong_pin", "The PIN you have entered is not valid.", @@ -137,8 +136,6 @@ async def error_pin_invalid() -> NoReturn: async def error_pin_matches_wipe_code() -> NoReturn: - from trezor.ui.layouts import show_error_and_raise - await show_error_and_raise( "warning_invalid_new_pin", "The new PIN must be different from your wipe code.", diff --git a/core/src/trezor/ui/layouts/tr/__init__.py b/core/src/trezor/ui/layouts/tr/__init__.py index 59dc992f5b..5e5a02e98e 100644 --- a/core/src/trezor/ui/layouts/tr/__init__.py +++ b/core/src/trezor/ui/layouts/tr/__init__.py @@ -580,21 +580,16 @@ async def _show_modal( async def show_error_and_raise( br_type: str, content: str, - header: str = "Error", subheader: str | None = None, - button: str = "Close", - red: bool = False, # unused on TR + button: str = "TRY AGAIN", exc: ExceptionType = ActionCancelled, ) -> NoReturn: - await _show_modal( + await show_warning( br_type, - header, - subheader, + subheader or "", content, - button_confirm=None, - button_cancel=button, + button=button, br_code=BR_TYPE_OTHER, - exc=exc, ) raise exc diff --git a/core/src/trezor/ui/layouts/tt_v2/__init__.py b/core/src/trezor/ui/layouts/tt_v2/__init__.py index 562442d513..fbf515f396 100644 --- a/core/src/trezor/ui/layouts/tt_v2/__init__.py +++ b/core/src/trezor/ui/layouts/tt_v2/__init__.py @@ -491,7 +491,7 @@ async def show_error_and_raise( br_type: str, content: str, subheader: str | None = None, - button: str = "CLOSE", + button: str = "TRY AGAIN", exc: ExceptionType = ActionCancelled, ) -> NoReturn: await interact( diff --git a/tests/click_tests/common.py b/tests/click_tests/common.py index e34103c040..4765a88355 100644 --- a/tests/click_tests/common.py +++ b/tests/click_tests/common.py @@ -51,11 +51,16 @@ def go_next(debug: "DebugLink", wait: bool = False) -> "LayoutContent" | None: raise RuntimeError("Unknown model") -def go_back(debug: "DebugLink", wait: bool = False) -> "LayoutContent" | None: +def go_back( + debug: "DebugLink", wait: bool = False, r_middle: bool = False +) -> "LayoutContent" | None: if debug.model == "T": return debug.click(buttons.CANCEL, wait=wait) # type: ignore elif debug.model == "R": - return debug.press_left(wait=wait) # type: ignore + if r_middle: + return debug.press_middle(wait=wait) # type: ignore + else: + return debug.press_left(wait=wait) # type: ignore else: raise RuntimeError("Unknown model") diff --git a/tests/click_tests/test_pin.py b/tests/click_tests/test_pin.py index 2c048677c0..ca6f99fa46 100644 --- a/tests/click_tests/test_pin.py +++ b/tests/click_tests/test_pin.py @@ -311,4 +311,4 @@ def test_pin_same_as_wipe_code(device_handler: "BackgroundDeviceHandler"): _enter_two_times(debug, "1", "1") with PIN_INVALID, prepare(device_handler, Situation.PIN_SETUP) as debug: _enter_two_times(debug, "1", "1") - go_back(debug) + go_back(debug, r_middle=True)