diff --git a/core/SConscript.unix b/core/SConscript.unix index 899c2e70f..5b8d19b4e 100644 --- a/core/SConscript.unix +++ b/core/SConscript.unix @@ -517,13 +517,19 @@ if FROZEN: SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/constants/__init__.py')) SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/__init__.py')) SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/common.py')) + SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/reset.py')) + SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/recovery.py')) + if EVERYTHING: + SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/altcoin.py')) + SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/webauthn.py')) if TREZOR_MODEL == 'T' and UI2: - SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/components/tt/*.py')) SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/constants/tt.py')) SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/tt_v2/__init__.py')) - SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/tt/__init__.py')) + SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/tt_v2/reset.py')) + SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/tt_v2/recovery.py')) if EVERYTHING: - SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/tt/webauthn.py')) + SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/tt_v2/altcoin.py')) + SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/tt_v2/webauthn.py')) elif TREZOR_MODEL == 'T': SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/components/tt/*.py')) SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/constants/tt.py')) diff --git a/core/src/all_modules.py b/core/src/all_modules.py index 173baee16..30ef62100 100644 --- a/core/src/all_modules.py +++ b/core/src/all_modules.py @@ -192,8 +192,14 @@ trezor.ui.container import trezor.ui.container trezor.ui.layouts import trezor.ui.layouts +trezor.ui.layouts.altcoin +import trezor.ui.layouts.altcoin trezor.ui.layouts.common import trezor.ui.layouts.common +trezor.ui.layouts.recovery +import trezor.ui.layouts.recovery +trezor.ui.layouts.reset +import trezor.ui.layouts.reset trezor.ui.layouts.t1 import trezor.ui.layouts.t1 trezor.ui.layouts.tt @@ -206,6 +212,12 @@ trezor.ui.layouts.tt.reset import trezor.ui.layouts.tt.reset trezor.ui.layouts.tt_v2 import trezor.ui.layouts.tt_v2 +trezor.ui.layouts.tt_v2.altcoin +import trezor.ui.layouts.tt_v2.altcoin +trezor.ui.layouts.tt_v2.recovery +import trezor.ui.layouts.tt_v2.recovery +trezor.ui.layouts.tt_v2.reset +import trezor.ui.layouts.tt_v2.reset trezor.ui.loader import trezor.ui.loader trezor.ui.popup @@ -438,6 +450,10 @@ if not utils.BITCOIN_ONLY: import trezor.ui.components.tt.webauthn trezor.ui.layouts.tt.webauthn import trezor.ui.layouts.tt.webauthn + trezor.ui.layouts.tt_v2.webauthn + import trezor.ui.layouts.tt_v2.webauthn + trezor.ui.layouts.webauthn + import trezor.ui.layouts.webauthn apps.binance import apps.binance apps.binance.get_address diff --git a/core/src/apps/binance/layout.py b/core/src/apps/binance/layout.py index 03d0ea5e6..eddd545d8 100644 --- a/core/src/apps/binance/layout.py +++ b/core/src/apps/binance/layout.py @@ -9,7 +9,7 @@ from trezor.messages import ( ) from trezor.strings import format_amount from trezor.ui.layouts import confirm_properties -from trezor.ui.layouts.tt.altcoin import confirm_transfer_binance +from trezor.ui.layouts.altcoin import confirm_transfer_binance from . import helpers diff --git a/core/src/apps/bitcoin/sign_tx/layout.py b/core/src/apps/bitcoin/sign_tx/layout.py index d15f7e0be..1c2a0e5b0 100644 --- a/core/src/apps/bitcoin/sign_tx/layout.py +++ b/core/src/apps/bitcoin/sign_tx/layout.py @@ -11,7 +11,7 @@ from .. import addresses from . import omni if not utils.BITCOIN_ONLY: - from trezor.ui.layouts.tt import altcoin + from trezor.ui.layouts import altcoin if TYPE_CHECKING: diff --git a/core/src/apps/ethereum/layout.py b/core/src/apps/ethereum/layout.py index 3635b74c3..5018323cd 100644 --- a/core/src/apps/ethereum/layout.py +++ b/core/src/apps/ethereum/layout.py @@ -15,7 +15,7 @@ from trezor.ui.layouts import ( confirm_total, should_show_more, ) -from trezor.ui.layouts.tt.altcoin import confirm_total_ethereum +from trezor.ui.layouts.altcoin import confirm_total_ethereum from . import networks, tokens from .helpers import address_from_bytes, decode_typed_data, get_type_name diff --git a/core/src/apps/management/recovery_device/layout.py b/core/src/apps/management/recovery_device/layout.py index 335b0903f..cc7da5c8c 100644 --- a/core/src/apps/management/recovery_device/layout.py +++ b/core/src/apps/management/recovery_device/layout.py @@ -5,7 +5,7 @@ from trezor import ui, wire from trezor.enums import ButtonRequestType from trezor.ui.layouts import confirm_action, show_success, show_warning from trezor.ui.layouts.common import button_request -from trezor.ui.layouts.tt.recovery import ( # noqa: F401 +from trezor.ui.layouts.recovery import ( # noqa: F401 continue_recovery, request_word, request_word_count, diff --git a/core/src/apps/management/reset_device/layout.py b/core/src/apps/management/reset_device/layout.py index 0ff39e87d..87c80b0a0 100644 --- a/core/src/apps/management/reset_device/layout.py +++ b/core/src/apps/management/reset_device/layout.py @@ -3,7 +3,7 @@ from typing import Sequence from trezor import ui, utils, wire from trezor.enums import ButtonRequestType from trezor.ui.layouts import confirm_action, confirm_blob, show_success, show_warning -from trezor.ui.layouts.tt.reset import ( # noqa: F401 +from trezor.ui.layouts.reset import ( # noqa: F401 confirm_word, show_share_words, slip39_advanced_prompt_group_threshold, diff --git a/core/src/apps/ripple/layout.py b/core/src/apps/ripple/layout.py index 91015f3b7..430d5b92b 100644 --- a/core/src/apps/ripple/layout.py +++ b/core/src/apps/ripple/layout.py @@ -3,7 +3,7 @@ from typing import TYPE_CHECKING from trezor.enums import ButtonRequestType from trezor.strings import format_amount from trezor.ui.layouts import confirm_metadata -from trezor.ui.layouts.tt.altcoin import confirm_total_ripple +from trezor.ui.layouts.altcoin import confirm_total_ripple from . import helpers diff --git a/core/src/apps/webauthn/add_resident_credential.py b/core/src/apps/webauthn/add_resident_credential.py index 3a5c48852..4ef4d4f58 100644 --- a/core/src/apps/webauthn/add_resident_credential.py +++ b/core/src/apps/webauthn/add_resident_credential.py @@ -3,7 +3,7 @@ from trezor import wire from trezor.messages import Success, WebAuthnAddResidentCredential from trezor.ui.components.common.webauthn import ConfirmInfo from trezor.ui.layouts import show_error_and_raise -from trezor.ui.layouts.tt.webauthn import confirm_webauthn +from trezor.ui.layouts.webauthn import confirm_webauthn from .credential import Fido2Credential from .resident_credentials import store_resident_credential diff --git a/core/src/apps/webauthn/fido2.py b/core/src/apps/webauthn/fido2.py index 88146b49e..3790102de 100644 --- a/core/src/apps/webauthn/fido2.py +++ b/core/src/apps/webauthn/fido2.py @@ -13,7 +13,7 @@ from trezor.crypto.curve import nist256p1 from trezor.ui.components.common.confirm import Pageable from trezor.ui.components.common.webauthn import ConfirmInfo from trezor.ui.layouts import show_popup -from trezor.ui.layouts.tt.webauthn import confirm_webauthn, confirm_webauthn_reset +from trezor.ui.layouts.webauthn import confirm_webauthn, confirm_webauthn_reset from apps.base import set_homescreen from apps.common import cbor diff --git a/core/src/apps/webauthn/remove_resident_credential.py b/core/src/apps/webauthn/remove_resident_credential.py index ab4efd17d..b36e5b0c2 100644 --- a/core/src/apps/webauthn/remove_resident_credential.py +++ b/core/src/apps/webauthn/remove_resident_credential.py @@ -3,7 +3,7 @@ import storage.resident_credentials from trezor import wire from trezor.messages import Success, WebAuthnRemoveResidentCredential from trezor.ui.components.common.webauthn import ConfirmInfo -from trezor.ui.layouts.tt.webauthn import confirm_webauthn +from trezor.ui.layouts.webauthn import confirm_webauthn from .credential import Fido2Credential from .resident_credentials import get_resident_credential diff --git a/core/src/trezor/ui/layouts/__init__.py b/core/src/trezor/ui/layouts/__init__.py index f104a3dd2..527666382 100644 --- a/core/src/trezor/ui/layouts/__init__.py +++ b/core/src/trezor/ui/layouts/__init__.py @@ -3,17 +3,17 @@ from trezor import utils from .common import * # noqa: F401,F403 try: - ui2 = True + UI2 = True import trezorui2 # noqa: F401 except ImportError: - ui2 = False + UI2 = False # NOTE: using any import magic probably causes mypy not to check equivalence of # layout type signatures across models if utils.MODEL == "1": from .t1 import * # noqa: F401,F403 elif utils.MODEL == "T": - if not ui2: + if not UI2: from .tt import * # noqa: F401,F403 else: from .tt_v2 import * # noqa: F401,F403 diff --git a/core/src/trezor/ui/layouts/altcoin.py b/core/src/trezor/ui/layouts/altcoin.py new file mode 100644 index 000000000..0e46ac724 --- /dev/null +++ b/core/src/trezor/ui/layouts/altcoin.py @@ -0,0 +1,6 @@ +from . import UI2 + +if UI2: + from .tt_v2.altcoin import * # noqa: F401,F403 +else: + from .tt.altcoin import * # noqa: F401,F403 diff --git a/core/src/trezor/ui/layouts/common.py b/core/src/trezor/ui/layouts/common.py index 9afc81994..6ce6abd32 100644 --- a/core/src/trezor/ui/layouts/common.py +++ b/core/src/trezor/ui/layouts/common.py @@ -12,13 +12,6 @@ if TYPE_CHECKING: ExceptionType = BaseException | type[BaseException] -if __debug__: - from trezor import utils - - if utils.MODEL == "T": - from ..components.tt.scroll import Paginated - - async def button_request( ctx: wire.GenericContext, br_type: str, @@ -37,6 +30,8 @@ async def interact( br_code: ButtonRequestType = ButtonRequestType.Other, ) -> Any: if layout.__class__.__name__ == "Paginated": + from ..components.tt.scroll import Paginated + assert isinstance(layout, Paginated) return await layout.interact(ctx, code=br_code) else: diff --git a/core/src/trezor/ui/layouts/recovery.py b/core/src/trezor/ui/layouts/recovery.py new file mode 100644 index 000000000..5c4e8673f --- /dev/null +++ b/core/src/trezor/ui/layouts/recovery.py @@ -0,0 +1,6 @@ +from . import UI2 + +if UI2: + from .tt_v2.recovery import * # noqa: F401,F403 +else: + from .tt.recovery import * # noqa: F401,F403 diff --git a/core/src/trezor/ui/layouts/reset.py b/core/src/trezor/ui/layouts/reset.py new file mode 100644 index 000000000..442213309 --- /dev/null +++ b/core/src/trezor/ui/layouts/reset.py @@ -0,0 +1,6 @@ +from . import UI2 + +if UI2: + from .tt_v2.reset import * # noqa: F401,F403 +else: + from .tt.reset import * # noqa: F401,F403 diff --git a/core/src/trezor/ui/layouts/tt_v2/__init__.py b/core/src/trezor/ui/layouts/tt_v2/__init__.py index f851e988e..4b8806334 100644 --- a/core/src/trezor/ui/layouts/tt_v2/__init__.py +++ b/core/src/trezor/ui/layouts/tt_v2/__init__.py @@ -111,7 +111,12 @@ async def confirm_action( async def confirm_reset_device( ctx: wire.GenericContext, prompt: str, recovery: bool = False ) -> None: - raise NotImplementedError + return await confirm_action( + ctx, + "recover_device" if recovery else "setup_device", + "not implemented", + action="not implemented", + ) # TODO cleanup @ redesign @@ -266,6 +271,15 @@ async def confirm_output( raise NotImplementedError +async def confirm_payment_request( + ctx: wire.GenericContext, + recipient_name: str, + amount: str, + memos: list[str], +) -> Any: + raise NotImplementedError + + async def should_show_more( ctx: wire.GenericContext, title: str, @@ -438,7 +452,7 @@ async def show_popup( def draw_simple_text(title: str, description: str = "") -> None: - raise NotImplementedError + log.error(__name__, "draw_simple_text not implemented") async def request_passphrase_on_device(ctx: wire.GenericContext, max_len: int) -> str: @@ -486,23 +500,3 @@ async def request_pin_on_device( raise wire.PinCancelled assert isinstance(result, str) return result - - -async def request_word( - ctx: wire.GenericContext, word_index: int, word_count: int, is_slip39: bool -) -> str: - if is_slip39: - keyboard: Any = _RustLayout( - trezorui2.request_bip39( - prompt=f"Type word {word_index + 1} of {word_count}:" - ) - ) - else: - keyboard = _RustLayout( - trezorui2.request_slip39( - prompt=f"Type word {word_index + 1} of {word_count}:" - ) - ) - - word: str = await ctx.wait(keyboard) - return word diff --git a/core/src/trezor/ui/layouts/tt_v2/altcoin.py b/core/src/trezor/ui/layouts/tt_v2/altcoin.py new file mode 100644 index 000000000..9a2e14e83 --- /dev/null +++ b/core/src/trezor/ui/layouts/tt_v2/altcoin.py @@ -0,0 +1,36 @@ +from typing import TYPE_CHECKING + +from trezor import wire + +if TYPE_CHECKING: + from typing import Sequence + + pass + + +async def confirm_total_ethereum( + ctx: wire.GenericContext, total_amount: str, gas_price: str, fee_max: str +) -> None: + raise NotImplementedError + + +async def confirm_total_ripple( + ctx: wire.GenericContext, + address: str, + amount: str, +) -> None: + raise NotImplementedError + + +async def confirm_transfer_binance( + ctx: wire.GenericContext, inputs_outputs: Sequence[tuple[str, str, str]] +) -> None: + raise NotImplementedError + + +async def confirm_decred_sstx_submission( + ctx: wire.GenericContext, + address: str, + amount: str, +) -> None: + raise NotImplementedError diff --git a/core/src/trezor/ui/layouts/tt_v2/recovery.py b/core/src/trezor/ui/layouts/tt_v2/recovery.py new file mode 100644 index 000000000..9e6e28c73 --- /dev/null +++ b/core/src/trezor/ui/layouts/tt_v2/recovery.py @@ -0,0 +1,61 @@ +from typing import TYPE_CHECKING + +from trezor import wire + +import trezorui2 + +from . import _RustLayout + +if TYPE_CHECKING: + from typing import Iterable, Callable, Any + + pass + + +async def request_word_count(ctx: wire.GenericContext, dry_run: bool) -> int: + raise NotImplementedError + + +async def request_word( + ctx: wire.GenericContext, word_index: int, word_count: int, is_slip39: bool +) -> str: + if is_slip39: + keyboard: Any = _RustLayout( + trezorui2.request_bip39( + prompt=f"Type word {word_index + 1} of {word_count}:" + ) + ) + else: + keyboard = _RustLayout( + trezorui2.request_slip39( + prompt=f"Type word {word_index + 1} of {word_count}:" + ) + ) + + word: str = await ctx.wait(keyboard) + return word + + +async def show_remaining_shares( + ctx: wire.GenericContext, + groups: Iterable[tuple[int, tuple[str, ...]]], # remaining + list 3 words + shares_remaining: list[int], + group_threshold: int, +) -> None: + raise NotImplementedError + + +async def show_group_share_success( + ctx: wire.GenericContext, share_index: int, group_index: int +) -> None: + raise NotImplementedError + + +async def continue_recovery( + ctx: wire.GenericContext, + button_label: str, + text: str, + subtext: str | None, + info_func: Callable | None, +) -> bool: + raise NotImplementedError diff --git a/core/src/trezor/ui/layouts/tt_v2/reset.py b/core/src/trezor/ui/layouts/tt_v2/reset.py new file mode 100644 index 000000000..eec1e1927 --- /dev/null +++ b/core/src/trezor/ui/layouts/tt_v2/reset.py @@ -0,0 +1,55 @@ +from typing import TYPE_CHECKING + +from trezor import wire + +if TYPE_CHECKING: + from trezor.enums import BackupType + from typing import Sequence + + +async def show_share_words( + ctx: wire.GenericContext, + share_words: Sequence[str], + share_index: int | None = None, + group_index: int | None = None, +) -> None: + raise NotImplementedError + + +async def confirm_word( + ctx: wire.GenericContext, + share_index: int | None, + share_words: Sequence[str], + offset: int, + count: int, + group_index: int | None = None, +) -> bool: + raise NotImplementedError + + +async def slip39_show_checklist( + ctx: wire.GenericContext, step: int, backup_type: BackupType +) -> None: + raise NotImplementedError + + +async def slip39_prompt_threshold( + ctx: wire.GenericContext, num_of_shares: int, group_id: int | None = None +) -> int: + raise NotImplementedError + + +async def slip39_prompt_number_of_shares( + ctx: wire.GenericContext, group_id: int | None = None +) -> int: + raise NotImplementedError + + +async def slip39_advanced_prompt_number_of_groups(ctx: wire.GenericContext) -> int: + raise NotImplementedError + + +async def slip39_advanced_prompt_group_threshold( + ctx: wire.GenericContext, num_of_groups: int +) -> int: + raise NotImplementedError diff --git a/core/src/trezor/ui/layouts/tt_v2/webauthn.py b/core/src/trezor/ui/layouts/tt_v2/webauthn.py new file mode 100644 index 000000000..d989403c5 --- /dev/null +++ b/core/src/trezor/ui/layouts/tt_v2/webauthn.py @@ -0,0 +1,20 @@ +from typing import TYPE_CHECKING + +from trezor import wire + +from ...components.common.webauthn import ConfirmInfo + +if TYPE_CHECKING: + Pageable = object + + +async def confirm_webauthn( + ctx: wire.GenericContext | None, + info: ConfirmInfo, + pageable: Pageable | None = None, +) -> bool: + raise NotImplementedError + + +async def confirm_webauthn_reset() -> bool: + raise NotImplementedError diff --git a/core/src/trezor/ui/layouts/webauthn.py b/core/src/trezor/ui/layouts/webauthn.py new file mode 100644 index 000000000..909113792 --- /dev/null +++ b/core/src/trezor/ui/layouts/webauthn.py @@ -0,0 +1,6 @@ +from . import UI2 + +if UI2: + from .tt_v2.webauthn import * # noqa: F401,F403 +else: + from .tt.webauthn import * # noqa: F401,F403