Skip to content

Commit 3a4b7f3

Browse files
committed
WIP
1 parent e37d8e7 commit 3a4b7f3

7 files changed

Lines changed: 60 additions & 25 deletions

File tree

core/src/apps/ethereum/clear_signing.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,7 @@ async def _handle_approve(
709709
definitions.network,
710710
token,
711711
address_bytes,
712+
msg.value,
712713
is_revoke,
713714
bool(msg.chunkify),
714715
)
@@ -765,11 +766,12 @@ async def _handle_transfer(
765766
else:
766767
await require_confirm_tx(
767768
recipient_addr,
768-
value,
769+
arg1_raw_value,
769770
address_bytes,
770771
msg.address_n,
771772
maximum_fee,
772773
fee_items,
774+
definitions.network,
773775
token,
774776
is_send=True,
775777
chunkify=bool(msg.chunkify),

core/src/apps/ethereum/layout.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ async def require_confirm_approve(
4242
network: EthereumNetworkInfo,
4343
token: EthereumTokenInfo,
4444
token_address: AnyBytes,
45+
tx_value: AnyBytes,
4546
is_revoke: bool,
4647
chunkify: bool,
4748
) -> None:
@@ -91,11 +92,12 @@ async def require_confirm_clear_signing(
9192

9293
async def require_confirm_tx(
9394
recipient: str | None,
94-
total_amount: str,
95+
tx_value: int,
9596
address_bytes: bytes,
9697
address_n: list[int],
9798
maximum_fee: str,
9899
fee_info_items: Iterable[StrPropertyType],
100+
network: EthereumNetworkInfo,
99101
token: EthereumTokenInfo | None,
100102
is_send: bool,
101103
chunkify: bool,
@@ -123,11 +125,13 @@ async def require_confirm_tx(
123125

124126
await confirm_ethereum_tx(
125127
recipient,
126-
total_amount,
128+
tx_value,
127129
account,
128130
account_path,
129131
maximum_fee,
130132
fee_info_items,
133+
network,
134+
token,
131135
is_send,
132136
chunkify=chunkify,
133137
)

core/src/apps/ethereum/sign_tx.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ async def confirm_tx_data(
221221
from trezor.ui.layouts import confirm_value
222222

223223
from . import clear_signing, staking, yielding
224-
from .helpers import format_ethereum_amount
225224
from .layout import require_confirm_payment_request, require_confirm_tx
226225

227226
# local_cache_attribute
@@ -304,11 +303,12 @@ async def confirm_tx_data(
304303

305304
return confirm_data_chunk, require_confirm_tx(
306305
recipient_str,
307-
format_ethereum_amount(value, token, network),
306+
value,
308307
address_bytes,
309308
msg.address_n,
310309
maximum_fee,
311310
fee_items,
311+
network,
312312
token,
313313
is_send=(data_length == 0 and tx_type != _EIP_7702_TX_TYPE),
314314
chunkify=bool(msg.chunkify),

core/src/trezor/ui/layouts/bolt/__init__.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from buffer_types import AnyBytes, StrOrBytes
1313
from typing import Awaitable, Iterable, NoReturn, Sequence
1414

15-
from trezor.messages import StellarAsset
15+
from trezor.messages import EthereumNetworkInfo, EthereumTokenInfo, StellarAsset
1616

1717
from ..common import ExceptionType, PropertyType, StrPropertyType
1818
from ..slip24 import Refund, Trade
@@ -1070,16 +1070,20 @@ def confirm_ethereum_unknown_contract_warning(
10701070

10711071
async def confirm_ethereum_tx(
10721072
recipient: str | None,
1073-
total_amount: str,
1073+
tx_value: int,
10741074
account: str | None,
10751075
account_path: str | None,
10761076
maximum_fee: str,
10771077
fee_info_items: Iterable[StrPropertyType],
1078+
network: EthereumNetworkInfo,
1079+
token: EthereumTokenInfo | None,
10781080
is_send: bool,
10791081
br_name: str = "confirm_ethereum_tx",
10801082
br_code: ButtonRequestType = ButtonRequestType.SignTx,
10811083
chunkify: bool = False,
10821084
) -> None:
1085+
from apps.ethereum.helpers import format_ethereum_amount
1086+
10831087
from ..properties import with_colon
10841088

10851089
if is_send:
@@ -1110,8 +1114,10 @@ async def confirm_ethereum_tx(
11101114

11111115
extra_items = with_colon(fee_info_items)
11121116

1117+
amount_str = format_ethereum_amount(tx_value, token, network)
1118+
11131119
total_layout = trezorui_api.confirm_summary(
1114-
amount=total_amount,
1120+
amount=amount_str,
11151121
amount_label=f"{TR.words__amount}:",
11161122
fee=maximum_fee,
11171123
fee_label=f"{TR.send__maximum_fee}:",

core/src/trezor/ui/layouts/caesar/__init__.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from buffer_types import AnyBytes, StrOrBytes
1212
from typing import Awaitable, Callable, Iterable, NoReturn, Sequence
1313

14-
from trezor.messages import StellarAsset
14+
from trezor.messages import EthereumNetworkInfo, EthereumTokenInfo, StellarAsset
1515

1616
from ..common import ExceptionType, PropertyType, StrPropertyType
1717
from ..menu import Details
@@ -1525,20 +1525,26 @@ def confirm_cardano_tx(
15251525

15261526
async def confirm_ethereum_tx(
15271527
recipient: str | None,
1528-
total_amount: str,
1528+
tx_value: int,
15291529
_account: str | None,
15301530
_account_path: str | None,
15311531
maximum_fee: str,
15321532
fee_info_items: Iterable[StrPropertyType],
1533+
network: EthereumNetworkInfo,
1534+
token: EthereumTokenInfo | None,
15331535
is_send: bool,
15341536
br_name: str = "confirm_ethereum_tx",
15351537
br_code: ButtonRequestType = ButtonRequestType.SignTx,
15361538
chunkify: bool = False,
15371539
) -> None:
1540+
from apps.ethereum.helpers import format_ethereum_amount
1541+
15381542
from ..properties import with_colon
15391543

1544+
amount_str = format_ethereum_amount(tx_value, token, network)
1545+
15401546
summary_layout = trezorui_api.confirm_summary(
1541-
amount=total_amount,
1547+
amount=amount_str,
15421548
amount_label=with_colon(TR.words__amount),
15431549
fee=maximum_fee,
15441550
fee_label=with_colon(TR.send__maximum_fee),

core/src/trezor/ui/layouts/delizia/__init__.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from buffer_types import AnyBytes, StrOrBytes
1818
from typing import Any, Awaitable, Coroutine, Iterable, NoReturn, Sequence, TypeVar
1919

20-
from trezor.messages import StellarAsset
20+
from trezor.messages import EthereumNetworkInfo, EthereumTokenInfo, StellarAsset
2121

2222
from ..common import ExceptionType, PropertyType, StrPropertyType
2323
from ..menu import Details
@@ -1071,16 +1071,22 @@ def confirm_ethereum_unknown_contract_warning(
10711071

10721072
async def confirm_ethereum_tx(
10731073
recipient: str | None,
1074-
total_amount: str,
1074+
tx_value: int,
10751075
account: str | None,
10761076
account_path: str | None,
10771077
maximum_fee: str,
10781078
fee_info_items: Iterable[StrPropertyType],
1079+
network: EthereumNetworkInfo,
1080+
token: EthereumTokenInfo | None,
10791081
is_send: bool,
10801082
br_name: str = "confirm_ethereum_tx",
10811083
br_code: ButtonRequestType = ButtonRequestType.SignTx,
10821084
chunkify: bool = False,
10831085
) -> None:
1086+
from apps.ethereum.helpers import format_ethereum_amount
1087+
1088+
amount_str = format_ethereum_amount(tx_value, token, network)
1089+
10841090
await confirm_linear_flow(
10851091
lambda: confirm_value(
10861092
TR.words__address,
@@ -1099,14 +1105,19 @@ async def confirm_ethereum_tx(
10991105
account, account_path, TR.send__send_from
11001106
),
11011107
),
1102-
lambda: confirm_total(
1103-
total_amount,
1104-
maximum_fee,
1105-
title=None,
1106-
total_label=TR.words__amount,
1107-
fee_label=TR.send__maximum_fee,
1108-
fee_items=fee_info_items,
1109-
back_button=True,
1108+
lambda: interact(
1109+
trezorui_api.confirm_summary(
1110+
amount=amount_str,
1111+
amount_label=TR.words__amount,
1112+
fee=maximum_fee,
1113+
fee_label=TR.send__maximum_fee,
1114+
title=TR.words__title_summary,
1115+
extra_items=fee_info_items,
1116+
extra_title=TR.confirm_total__title_fee,
1117+
back_button=True,
1118+
),
1119+
br_name,
1120+
br_code,
11101121
),
11111122
)
11121123

core/src/trezor/ui/layouts/eckhart/__init__.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from buffer_types import AnyBytes, StrOrBytes
1818
from typing import Any, Awaitable, Coroutine, Iterable, NoReturn, Sequence, TypeVar
1919

20-
from trezor.messages import StellarAsset
20+
from trezor.messages import EthereumNetworkInfo, EthereumTokenInfo, StellarAsset
2121
from trezor.ui.layouts.menu import Details
2222

2323
from ..common import ExceptionType, PropertyType, StrPropertyType
@@ -904,7 +904,7 @@ def confirm_properties(
904904

905905

906906
def confirm_total(
907-
total_amount: str | None,
907+
total_amount: str,
908908
fee_amount: str,
909909
title: str | None = None,
910910
total_label: str | None = None,
@@ -1068,18 +1068,22 @@ def confirm_solana_unknown_token_warning() -> Awaitable[None]:
10681068

10691069
async def confirm_ethereum_tx(
10701070
recipient: str | None,
1071-
total_amount: str,
1071+
tx_value: int,
10721072
account: str | None,
10731073
account_path: str | None,
10741074
maximum_fee: str,
10751075
fee_info_items: Iterable[StrPropertyType],
1076+
network: EthereumNetworkInfo,
1077+
token: EthereumTokenInfo | None,
10761078
is_send: bool,
10771079
br_name: str = "confirm_total",
10781080
br_code: ButtonRequestType = ButtonRequestType.SignTx,
10791081
chunkify: bool = False,
10801082
) -> None:
10811083
from trezor.ui.layouts.menu import Menu, interact_with_menu
10821084

1085+
from apps.ethereum.helpers import format_ethereum_amount
1086+
10831087
subtitle = (
10841088
None
10851089
if not is_send and recipient is None
@@ -1100,6 +1104,8 @@ async def confirm_ethereum_tx(
11001104
else:
11011105
menu_items = []
11021106

1107+
amount_str = format_ethereum_amount(tx_value, token, network)
1108+
11031109
await confirm_linear_flow(
11041110
lambda: interact_with_menu(
11051111
trezorui_api.confirm_value(
@@ -1120,7 +1126,7 @@ async def confirm_ethereum_tx(
11201126
),
11211127
lambda: interact(
11221128
trezorui_api.confirm_summary(
1123-
amount=total_amount,
1129+
amount=amount_str,
11241130
amount_label=TR.words__amount,
11251131
fee=maximum_fee,
11261132
fee_label=TR.send__maximum_fee,

0 commit comments

Comments
 (0)