From c54077a71489c46f2161533454bb0a2e1c8cff3d Mon Sep 17 00:00:00 2001 From: Martin Milata Date: Mon, 17 May 2021 15:25:14 +0200 Subject: [PATCH] fix(core): imports needed for T1 startup Now debug build booted on wiped T1 connects to USB and shows square in top right corner. --- core/.changelog.d/24.fixed | 1 + core/src/apps/common/request_pin.py | 6 ++-- core/src/trezor/ui/layouts/t1.py | 44 +++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 core/.changelog.d/24.fixed diff --git a/core/.changelog.d/24.fixed b/core/.changelog.d/24.fixed new file mode 100644 index 000000000..4679500c4 --- /dev/null +++ b/core/.changelog.d/24.fixed @@ -0,0 +1 @@ +Import errors on T1 startup. diff --git a/core/src/apps/common/request_pin.py b/core/src/apps/common/request_pin.py index da17b91d4..debfd5826 100644 --- a/core/src/apps/common/request_pin.py +++ b/core/src/apps/common/request_pin.py @@ -4,8 +4,6 @@ import storage.cache import storage.sd_salt from trezor import config, ui, wire from trezor.messages import ButtonRequestType -from trezor.ui.components.tt.pin import CANCELLED, PinDialog -from trezor.ui.components.tt.text import Text from trezor.ui.popup import Popup from . import button_request @@ -26,6 +24,8 @@ async def request_pin( attempts_remaining: int | None = None, allow_cancel: bool = True, ) -> str: + from trezor.ui.components.tt.pin import CANCELLED, PinDialog + await button_request(ctx, code=ButtonRequestType.PinEntry) if attempts_remaining is None: @@ -55,6 +55,8 @@ async def request_pin_confirm(ctx: wire.Context, *args: Any, **kwargs: Any) -> s async def pin_mismatch() -> None: + from trezor.ui.components.tt.text import Text + text = Text("PIN mismatch", ui.ICON_WRONG, ui.RED) text.normal("The PINs you entered", "do not match.") text.normal("") diff --git a/core/src/trezor/ui/layouts/t1.py b/core/src/trezor/ui/layouts/t1.py index e69de29bb..3c82e555f 100644 --- a/core/src/trezor/ui/layouts/t1.py +++ b/core/src/trezor/ui/layouts/t1.py @@ -0,0 +1,44 @@ +from trezor import ui, wire +from trezor.messages import ButtonRequestType + +if False: + from typing import NoReturn, Type, Union + + from trezor.messages.ButtonRequest import EnumTypeButtonRequestType + + ExceptionType = Union[BaseException, Type[BaseException]] + + +async def confirm_action( + ctx: wire.GenericContext, + br_type: str, + title: str, + action: str | None = None, + description: str | None = None, + description_param: str | None = None, + description_param_font: int = ui.BOLD, + verb: str | bytes | None = "OK", + verb_cancel: str | bytes | None = "X", + hold: bool = False, + hold_danger: bool = False, + icon: str | None = None, + icon_color: int | None = None, + reverse: bool = False, + larger_vspace: bool = False, + exc: ExceptionType = wire.ActionCancelled, + br_code: EnumTypeButtonRequestType = ButtonRequestType.Other, +) -> None: + raise NotImplementedError + + +async def show_error_and_raise( + ctx: wire.GenericContext, + br_type: str, + content: str, + header: str = "Error", + subheader: str | None = None, + button: str = "Close", + red: bool = False, + exc: ExceptionType = wire.ActionCancelled, +) -> NoReturn: + raise NotImplementedError