1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-17 21:22:10 +00:00

fix(core/ethereum): implement hold-to-confirm for eip1559 transactions

This commit is contained in:
matejcik 2022-02-07 15:08:24 +01:00 committed by matejcik
parent 48d7f71ccc
commit a1c62098e9
4 changed files with 24 additions and 13 deletions

View File

@ -0,0 +1 @@
EIP-1559 transaction correctly show final Hold to Confirm screen.

View File

@ -12,6 +12,7 @@ from trezor.ui.layouts import (
confirm_blob,
confirm_output,
confirm_text,
confirm_total,
should_show_more,
)
from trezor.ui.layouts.tt.altcoin import confirm_total_ethereum
@ -63,7 +64,13 @@ def require_confirm_fee(
async def require_confirm_eip1559_fee(
ctx: Context, max_priority_fee: int, max_gas_fee: int, gas_limit: int, chain_id: int
ctx: Context,
spending: int,
max_priority_fee: int,
max_gas_fee: int,
gas_limit: int,
chain_id: int,
token: tokens.TokenInfo | None = None,
) -> None:
await confirm_amount(
ctx,
@ -77,11 +84,12 @@ async def require_confirm_eip1559_fee(
description="Priority fee per gas",
amount=format_ethereum_amount(max_priority_fee, None, chain_id),
)
await confirm_amount(
await confirm_total(
ctx,
title="Confirm fee",
description="Maximum fee",
amount=format_ethereum_amount(max_gas_fee * gas_limit, None, chain_id),
total_amount=format_ethereum_amount(spending, token, chain_id),
fee_amount=format_ethereum_amount(max_gas_fee * gas_limit, None, chain_id),
total_label="Amount sent:\n",
fee_label="\nMaximum fee:\n",
)

View File

@ -70,10 +70,12 @@ async def sign_tx_eip1559(
await require_confirm_eip1559_fee(
ctx,
value,
int.from_bytes(msg.max_priority_fee, "big"),
int.from_bytes(msg.max_gas_fee, "big"),
int.from_bytes(msg.gas_limit, "big"),
msg.chain_id,
token,
)
data = bytearray()

View File

@ -668,14 +668,14 @@
"ethereum-test_signtx.py::test_signtx_data_pagination[input_flow_go_back]": "e0304501e6dd76d08052edd3ef518e4873f2029e8351bc1fb5ed5ba2a99e740a",
"ethereum-test_signtx.py::test_signtx_data_pagination[input_flow_scroll_down]": "f707da6726a2ebad6888af490eed2a1441147c795a8b72fb805fd0d3a8b071f9",
"ethereum-test_signtx.py::test_signtx_data_pagination[input_flow_skip]": "5d73d7f8366f4abd3eaf3e666f140ee0fcc0aca4f35483a6be27d96e2b64fd27",
"ethereum-test_signtx.py::test_signtx_eip1559[data_1]": "bf7fe1457c4fd99e74b8b9a2090321edfb20bdf68713505d92dd011f44d88184",
"ethereum-test_signtx.py::test_signtx_eip1559[data_2_bigdata]": "05cc77497ca4934f5472f4b8807208f54c734d1252e0eb186937a79e5ecec38b",
"ethereum-test_signtx.py::test_signtx_eip1559[known_erc20]": "fd068a40fb0d4729c49316122711d36a92b09c04f60eed6d1fa5ecee57ae6f7a",
"ethereum-test_signtx.py::test_signtx_eip1559[large_chainid]": "c8152a3f28ea1985d7c14844b3d8218a4a76e78fe0526e30c1d479f2cf200694",
"ethereum-test_signtx.py::test_signtx_eip1559[nodata]": "55faae526aa63bc536114c70f29d5e12a6e973c565ae4247c439b755b589d0df",
"ethereum-test_signtx.py::test_signtx_eip1559[unknown_erc20]": "6797940ee749fdf11a049eb1fccc7e2d6b34a907e4be26dbd8b9b442ce539ad1",
"ethereum-test_signtx.py::test_signtx_eip1559_access_list": "ceaf212625bb0d8696e3a46e5348639563bf2eb9c70865595dae118480b38d33",
"ethereum-test_signtx.py::test_signtx_eip1559_access_list_larger": "ceaf212625bb0d8696e3a46e5348639563bf2eb9c70865595dae118480b38d33",
"ethereum-test_signtx.py::test_signtx_eip1559[data_1]": "fcff42ade9344444b345d8f0a707dc57ed7a06a7a208d77aeb2186da4bbb9dca",
"ethereum-test_signtx.py::test_signtx_eip1559[data_2_bigdata]": "983a67f3fc48f03872593ee7b743272efa5c9906c07bd4411285b95813654233",
"ethereum-test_signtx.py::test_signtx_eip1559[known_erc20]": "a1a6350a0aabe1035e40fed9d8e28f9b9dc737d52814427c64ef00640d3752c7",
"ethereum-test_signtx.py::test_signtx_eip1559[large_chainid]": "a8a8aa0cea41f7534dd6c7953574a28dc923e2414cddde6c2dae2c6af8539c6d",
"ethereum-test_signtx.py::test_signtx_eip1559[nodata]": "5b103f4bf0ed90c0dd6ef8a33cdfa59edfd50e2441dbb4aa3dfec9dc6ba2d4c6",
"ethereum-test_signtx.py::test_signtx_eip1559[unknown_erc20]": "5064a9b5a10d47770358942af1bfe517a0f9f9b568994d791ad6d2d8c9e21a82",
"ethereum-test_signtx.py::test_signtx_eip1559_access_list": "c2b8fd24103c444473af2611f10f2e458a933b13fe49dfc0fdbb617fa762aa8c",
"ethereum-test_signtx.py::test_signtx_eip1559_access_list_larger": "c2b8fd24103c444473af2611f10f2e458a933b13fe49dfc0fdbb617fa762aa8c",
"misc-test_msg_cipherkeyvalue.py::test_decrypt": "4d8563e8130e51628290f0acbced7c294457c4501f7767b00ff3dd1bddc809da",
"misc-test_msg_cipherkeyvalue.py::test_decrypt_badlen": "c09de07fbbf1e047442180e2facb5482d06a1a428891b875b7dd93c9e4704ae1",
"misc-test_msg_cipherkeyvalue.py::test_encrypt": "871df86a7553681c5f17ec6759204f9b0727cc16c4868f227a4b364146fd9293",