From 7abacb3ff7d16d9a9a06e6eca0dc957171e8936c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ioan=20Biz=C4=83u?= Date: Mon, 18 Nov 2024 13:58:02 +0100 Subject: [PATCH] fixup! fixup! refactor(core): drop confirm_blob_with_optional_pagination --- core/src/apps/ethereum/layout.py | 13 +++++-- .../src/trezor/ui/layouts/mercury/__init__.py | 12 ------ core/src/trezor/ui/layouts/tr/__init__.py | 39 +++++++------------ core/src/trezor/ui/layouts/tt/__init__.py | 14 +------ tests/input_flows.py | 4 -- 5 files changed, 26 insertions(+), 56 deletions(-) diff --git a/core/src/apps/ethereum/layout.py b/core/src/apps/ethereum/layout.py index 45b89cd7ab..8cb631859f 100644 --- a/core/src/apps/ethereum/layout.py +++ b/core/src/apps/ethereum/layout.py @@ -176,9 +176,16 @@ def require_confirm_address(address_bytes: bytes) -> Awaitable[None]: def require_confirm_other_data(data: bytes, data_total: int) -> Awaitable[None]: - from trezor.ui.layouts import confirm_other_data - - return confirm_other_data(data, data_total) + return confirm_blob( + "confirm_data", + TR.ethereum__title_input_data, + data, + TR.ethereum__data_size_template.format(data_total), + verb=TR.buttons__confirm, + verb_cancel=TR.send__cancel_sign, + br_code=ButtonRequestType.SignTx, + ask_pagination=True, + ) async def confirm_typed_data_final() -> None: diff --git a/core/src/trezor/ui/layouts/mercury/__init__.py b/core/src/trezor/ui/layouts/mercury/__init__.py index c4456fd149..b03947c419 100644 --- a/core/src/trezor/ui/layouts/mercury/__init__.py +++ b/core/src/trezor/ui/layouts/mercury/__init__.py @@ -715,18 +715,6 @@ def _confirm_summary( if not utils.BITCOIN_ONLY: - def confirm_other_data(data: bytes, data_total: int) -> Awaitable[None]: - return confirm_blob( - "confirm_data", - TR.ethereum__title_input_data, - data, - TR.ethereum__data_size_template.format(data_total), - verb=TR.buttons__confirm, - verb_cancel=TR.send__cancel_sign, - br_code=ButtonRequestType.SignTx, - ask_pagination=True, - ) - def confirm_ethereum_unknown_contract_warning() -> Awaitable[None]: return raise_if_not_confirmed( trezorui2.flow_warning_hi_prio( diff --git a/core/src/trezor/ui/layouts/tr/__init__.py b/core/src/trezor/ui/layouts/tr/__init__.py index a9b1bbc4e8..4c42c012df 100644 --- a/core/src/trezor/ui/layouts/tr/__init__.py +++ b/core/src/trezor/ui/layouts/tr/__init__.py @@ -559,7 +559,7 @@ def confirm_blob( text_mono: bool = True, subtitle: str | None = None, verb: str | None = None, - verb_cancel: str | None = "", # icon + verb_cancel: str | None = None, # icon info: bool = True, hold: bool = False, br_code: ButtonRequestType = BR_CODE_OTHER, @@ -573,7 +573,7 @@ def confirm_blob( description=description, data=data, verb=verb, - verb_cancel=verb_cancel, + verb_cancel=None, hold=hold, chunkify=chunkify, ) @@ -581,7 +581,7 @@ def confirm_blob( if ask_pagination and layout.page_count() > 1: assert not hold return _confirm_ask_pagination( - br_name, title, data, description or "", verb_cancel, br_code + br_name, title, data, description or "", br_code ) else: return raise_if_not_confirmed(layout, br_name, br_code) @@ -592,7 +592,6 @@ async def _confirm_ask_pagination( title: str, data: bytes | str, description: str, - verb_cancel: str | None, br_code: ButtonRequestType, ) -> None: # TODO: make should_show_more/confirm_more accept bytes directly @@ -611,7 +610,7 @@ async def _confirm_ask_pagination( if not await should_show_more( title, para=[(ui.NORMAL, description), (ui.MONO, data)], - verb_cancel=verb_cancel, + verb_cancel=None, br_name=br_name, br_code=br_code, ): @@ -805,19 +804,6 @@ def confirm_total( if not utils.BITCOIN_ONLY: - - def confirm_other_data(data: bytes, data_total: int) -> Awaitable[None]: - return confirm_blob( - "confirm_data", - TR.ethereum__title_input_data, - data, - TR.ethereum__data_size_template.format(data_total), - verb=TR.buttons__confirm, - verb_cancel=None, - br_code=ButtonRequestType.SignTx, - ask_pagination=True, - ) - def confirm_ethereum_unknown_contract_warning() -> Awaitable[ui.UiResult]: return show_warning( "unknown_contract_warning", @@ -1116,13 +1102,18 @@ async def confirm_signverify( br_code=BR_CODE_OTHER, ) try: - await confirm_blob( + await raise_if_not_confirmed( + trezorui2.confirm_blob( + title=TR.sign_message__confirm_message, + description=None, + data=message, + verb=None, + verb_cancel="^", + hold=False, + chunkify=chunkify, + ), br_name, - TR.sign_message__confirm_message, - message, - verb_cancel="^", - br_code=BR_CODE_OTHER, - ask_pagination=True, + BR_CODE_OTHER, ) except ActionCancelled: continue diff --git a/core/src/trezor/ui/layouts/tt/__init__.py b/core/src/trezor/ui/layouts/tt/__init__.py index 7bc6e5bf20..3440445523 100644 --- a/core/src/trezor/ui/layouts/tt/__init__.py +++ b/core/src/trezor/ui/layouts/tt/__init__.py @@ -574,7 +574,7 @@ def confirm_blob( data=data, hold=hold, verb=verb, - verb_cancel=verb_cancel, + verb_cancel=None, chunkify=chunkify, ) @@ -770,18 +770,6 @@ def _confirm_summary( if not utils.BITCOIN_ONLY: - def confirm_other_data(data: bytes, data_total: int) -> Awaitable[None]: - return confirm_blob( - "confirm_data", - TR.ethereum__title_input_data, - data, - TR.ethereum__data_size_template.format(data_total), - verb=TR.buttons__confirm, - verb_cancel=None, - br_code=ButtonRequestType.SignTx, - ask_pagination=True, - ) - def confirm_ethereum_unknown_contract_warning() -> Awaitable[None]: return show_warning( "unknown_contract_warning", diff --git a/tests/input_flows.py b/tests/input_flows.py index 0b543751d3..79dbc56673 100644 --- a/tests/input_flows.py +++ b/tests/input_flows.py @@ -216,10 +216,6 @@ class InputFlowSignMessagePagination(InputFlowBase): yield self.debug.press_yes() - # press info - yield - self.debug.press_right() - # paginate through the whole message br = yield # TODO: try load the message_read the same way as in model T