Skip to content

Show ETH account info on model T #4471

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/.changelog.d/3536.added
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[T2T1] Added account info for ETH transactions.
51 changes: 31 additions & 20 deletions core/src/trezor/ui/layouts/bolt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -815,50 +815,61 @@ 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,
br_name: str = "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
Expand Down
2 changes: 2 additions & 0 deletions core/src/trezor/ui/layouts/caesar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -981,6 +982,7 @@ async def confirm_ethereum_tx(
title,
recipient or TR.ethereum__new_contract,
verb=TR.buttons__continue,
br_code=br_code,
chunkify=(chunkify if recipient else False),
)

Expand Down
2 changes: 1 addition & 1 deletion core/src/trezor/ui/layouts/delizia/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ async def confirm_ethereum_tx(
account_path=account_path,
address=None,
address_title=None,
br_code=ButtonRequestType.Other,
br_code=ButtonRequestType.SignTx,
br_name="confirm_output",
summary_items=(
(TR.words__amount, total_amount),
Expand Down
9 changes: 2 additions & 7 deletions tests/device_tests/ethereum/test_signtx.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import pytest

from trezorlib import ethereum, exceptions, messages, models
from trezorlib import ethereum, exceptions, messages
from trezorlib.debuglink import TrezorClientDebugLink as Client
from trezorlib.debuglink import message_filters
from trezorlib.exceptions import TrezorFailure
Expand Down Expand Up @@ -220,15 +220,10 @@ def test_data_streaming(client: Client):
checked in vectorized function above.
"""
with client:
is_t1 = client.model is models.T1B1
client.set_expected_responses(
[
messages.ButtonRequest(code=messages.ButtonRequestType.SignTx),
(is_t1, messages.ButtonRequest(code=messages.ButtonRequestType.SignTx)),
(
not is_t1,
messages.ButtonRequest(code=messages.ButtonRequestType.Other),
),
messages.ButtonRequest(code=messages.ButtonRequestType.SignTx),
messages.ButtonRequest(code=messages.ButtonRequestType.SignTx),
message_filters.EthereumTxRequest(
data_length=1_024,
Expand Down
8 changes: 8 additions & 0 deletions tests/input_flows_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading