From ee256d24af8b71f88d314204884a6f3bd965bc1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ioan=20Biz=C4=83u?= Date: Mon, 6 Jan 2025 15:25:40 +0100 Subject: [PATCH 1/2] feat(core): show ETH account info on model T --- core/.changelog.d/3536.added | 1 + core/src/trezor/ui/layouts/bolt/__init__.py | 51 +++++++++++++-------- tests/input_flows_helpers.py | 8 ++++ 3 files changed, 40 insertions(+), 20 deletions(-) create mode 100644 core/.changelog.d/3536.added diff --git a/core/.changelog.d/3536.added b/core/.changelog.d/3536.added new file mode 100644 index 00000000000..a362889bc6e --- /dev/null +++ b/core/.changelog.d/3536.added @@ -0,0 +1 @@ +[T2T1] Added account info for ETH transactions. diff --git a/core/src/trezor/ui/layouts/bolt/__init__.py b/core/src/trezor/ui/layouts/bolt/__init__.py index 0232fa7daff..68172bfa116 100644 --- a/core/src/trezor/ui/layouts/bolt/__init__.py +++ b/core/src/trezor/ui/layouts/bolt/__init__.py @@ -815,8 +815,8 @@ def confirm_ethereum_unknown_contract_warning() -> Awaitable[None]: async def confirm_ethereum_tx( recipient: str | None, total_amount: str, - _account: str | None, - _account_path: str | None, + account: str | None, + account_path: str | None, maximum_fee: str, fee_info_items: Iterable[tuple[str, str]], is_contract_interaction: bool, @@ -824,41 +824,52 @@ async def confirm_ethereum_tx( br_code: ButtonRequestType = ButtonRequestType.SignTx, chunkify: bool = False, ) -> None: - # NOTE: fee_info used so that info button is shown + if not is_contract_interaction: + description = f"{TR.words__recipient}:" + else: + description = f"{TR.ethereum__interaction_contract}:" if recipient else None + + address_layout = trezorui_api.confirm_value( + title=TR.words__address, + description=description, + value=recipient or TR.ethereum__new_contract, + verb=TR.buttons__continue, + verb_cancel=None, + info=True, + chunkify=(chunkify if recipient else False), + ) + + account_info_layout = trezorui_api.show_info_with_cancel( + title=TR.send__send_from, + items=[ + (f"{TR.words__account}:", account or ""), + (f"{TR.address_details__derivation_path}:", account_path or ""), + ], + ) + total_layout = trezorui_api.confirm_summary( amount=total_amount, amount_label=f"{TR.words__amount}:", fee=maximum_fee, fee_label=f"{TR.send__maximum_fee}:", title=TR.words__title_summary, - extra_items=fee_info_items, + extra_items=fee_info_items, # used so that info button is shown extra_title=TR.confirm_total__title_fee, verb_cancel="^", ) - info_layout = trezorui_api.show_info_with_cancel( + + fee_info_layout = trezorui_api.show_info_with_cancel( title=TR.confirm_total__title_fee, items=[(f"{k}:", v) for (k, v) in fee_info_items], ) - if not is_contract_interaction: - description = TR.words__recipient - else: - description = TR.ethereum__interaction_contract if recipient else None - while True: - # Allowing going back and forth between recipient and summary/details - await confirm_blob( - br_name, - TR.words__address, - recipient or TR.ethereum__new_contract, - description=description, - verb=TR.buttons__continue, - chunkify=(chunkify if recipient else False), - ) + await with_info(address_layout, account_info_layout, br_name, br_code) try: - await with_info(total_layout, info_layout, br_name, br_code) + await with_info(total_layout, fee_info_layout, br_name, br_code) except ActionCancelled: + # Allowing going back and forth between recipient and summary continue else: break diff --git a/tests/input_flows_helpers.py b/tests/input_flows_helpers.py index 90e03c16aea..56cc2fe71d0 100644 --- a/tests/input_flows_helpers.py +++ b/tests/input_flows_helpers.py @@ -398,6 +398,14 @@ def _confirm_tx_bolt( if cancel: self.debug.press_no() return + if info: + self.debug.press_info() + assert TR.words__account in self.debug.read_layout().text_content() + assert ( + TR.address_details__derivation_path + in self.debug.read_layout().text_content() + ) + self.debug.press_no() self.debug.press_yes() assert (yield).name == "confirm_ethereum_tx" From e730615d9baec31ca99c68c7c9868e9c2e2e8f4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ioan=20Biz=C4=83u?= Date: Fri, 24 Jan 2025 10:06:52 +0100 Subject: [PATCH 2/2] fix(core/ui): fix back button [no changelog] --- core/src/trezor/ui/layouts/caesar/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/trezor/ui/layouts/caesar/__init__.py b/core/src/trezor/ui/layouts/caesar/__init__.py index b766e233304..4115486f852 100644 --- a/core/src/trezor/ui/layouts/caesar/__init__.py +++ b/core/src/trezor/ui/layouts/caesar/__init__.py @@ -967,6 +967,7 @@ async def confirm_ethereum_tx( fee_label=f"{TR.send__maximum_fee}:", extra_items=[(f"{k}:", v) for (k, v) in fee_info_items], extra_title=TR.confirm_total__title_fee, + verb_cancel="<", ) if not is_contract_interaction: