mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-06-29 11:22:34 +00:00
WIP - improve design of some screens
This commit is contained in:
parent
4a11d41ba8
commit
0800d891e8
@ -92,7 +92,7 @@ test_emu: ## run selected device tests from python-trezor
|
|||||||
$(EMU_TEST) $(PYTEST) $(TESTPATH)/device_tests $(TESTOPTS)
|
$(EMU_TEST) $(PYTEST) $(TESTPATH)/device_tests $(TESTOPTS)
|
||||||
|
|
||||||
test_emu_multicore: ## run device tests using multiple cores
|
test_emu_multicore: ## run device tests using multiple cores
|
||||||
PYTEST_TIMEOUT=100 $(PYTEST) -n auto $(TESTPATH)/device_tests $(TESTOPTS) \
|
PYTEST_TIMEOUT=150 $(PYTEST) -n auto $(TESTPATH)/device_tests $(TESTOPTS) \
|
||||||
--control-emulators --model=core --random-order-seed=$(shell echo $$RANDOM)
|
--control-emulators --model=core --random-order-seed=$(shell echo $$RANDOM)
|
||||||
|
|
||||||
test_emu_monero: ## run selected monero device tests from monero-agent
|
test_emu_monero: ## run selected monero device tests from monero-agent
|
||||||
@ -114,7 +114,7 @@ test_emu_ui: ## run ui integration tests
|
|||||||
--ui=test --ui-check-missing --not-generate-report-after-each-test
|
--ui=test --ui-check-missing --not-generate-report-after-each-test
|
||||||
|
|
||||||
test_emu_ui_multicore: ## run ui integration tests using multiple cores
|
test_emu_ui_multicore: ## run ui integration tests using multiple cores
|
||||||
PYTEST_TIMEOUT=100 $(PYTEST) -n auto $(TESTPATH)/device_tests $(TESTOPTS) \
|
PYTEST_TIMEOUT=150 $(PYTEST) -n auto $(TESTPATH)/device_tests $(TESTOPTS) \
|
||||||
--ui=test --ui-check-missing --not-generate-report-after-each-test \
|
--ui=test --ui-check-missing --not-generate-report-after-each-test \
|
||||||
--control-emulators --model=core --random-order-seed=$(shell echo $$RANDOM)
|
--control-emulators --model=core --random-order-seed=$(shell echo $$RANDOM)
|
||||||
|
|
||||||
|
@ -24,8 +24,7 @@ BR_TYPE_OTHER = ButtonRequestType.Other # global_import_cache
|
|||||||
if __debug__:
|
if __debug__:
|
||||||
trezorui2.disable_animation(bool(DISABLE_ANIMATION))
|
trezorui2.disable_animation(bool(DISABLE_ANIMATION))
|
||||||
|
|
||||||
|
class RustLayoutContent:
|
||||||
class RustLayoutContent:
|
|
||||||
"""Providing shortcuts to the data returned by layouts.
|
"""Providing shortcuts to the data returned by layouts.
|
||||||
|
|
||||||
Used only in debug mode.
|
Used only in debug mode.
|
||||||
@ -112,7 +111,9 @@ class RustLayoutContent:
|
|||||||
def title(self) -> str:
|
def title(self) -> str:
|
||||||
"""Getting text that is displayed as a title."""
|
"""Getting text that is displayed as a title."""
|
||||||
# there could be multiple of those - title and subtitle for example
|
# there could be multiple of those - title and subtitle for example
|
||||||
title_strings = self._get_strings_inside_tag(self.str_content, self.TITLE_TAG)
|
title_strings = self._get_strings_inside_tag(
|
||||||
|
self.str_content, self.TITLE_TAG
|
||||||
|
)
|
||||||
return "\n".join(title_strings)
|
return "\n".join(title_strings)
|
||||||
|
|
||||||
def content(self) -> str:
|
def content(self) -> str:
|
||||||
@ -263,7 +264,7 @@ class RustLayout(ui.Layout):
|
|||||||
self.layout.trace(callback)
|
self.layout.trace(callback)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def _content_obj(self) -> RustLayoutContent:
|
def _content_obj(self) -> RustLayoutContent: # type: ignore [is possibly unbound]
|
||||||
"""Gets object with user-friendly methods on Rust layout content."""
|
"""Gets object with user-friendly methods on Rust layout content."""
|
||||||
return RustLayoutContent(self._read_content_raw())
|
return RustLayoutContent(self._read_content_raw())
|
||||||
|
|
||||||
@ -448,16 +449,16 @@ async def _placeholder_confirm(
|
|||||||
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
||||||
) -> Any:
|
) -> Any:
|
||||||
return await confirm_action(
|
return await confirm_action(
|
||||||
ctx=ctx,
|
ctx,
|
||||||
br_type=br_type,
|
br_type,
|
||||||
br_code=br_code,
|
title.upper(),
|
||||||
title=title.upper(),
|
data,
|
||||||
action=data,
|
description,
|
||||||
description=description,
|
|
||||||
verb=verb,
|
verb=verb,
|
||||||
verb_cancel=verb_cancel,
|
verb_cancel=verb_cancel,
|
||||||
hold=hold,
|
hold=hold,
|
||||||
reverse=True,
|
reverse=True,
|
||||||
|
br_code=br_code,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -861,10 +862,10 @@ async def should_show_more(
|
|||||||
confirm: str | bytes | None = None,
|
confirm: str | bytes | None = None,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
return await get_bool(
|
return await get_bool(
|
||||||
ctx=ctx,
|
ctx,
|
||||||
title=title.upper(),
|
br_type,
|
||||||
data=button_text,
|
title.upper(),
|
||||||
br_type=br_type,
|
button_text,
|
||||||
br_code=br_code,
|
br_code=br_code,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -879,12 +880,13 @@ async def confirm_blob(
|
|||||||
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
||||||
ask_pagination: bool = False,
|
ask_pagination: bool = False,
|
||||||
) -> None:
|
) -> None:
|
||||||
await _placeholder_confirm(
|
await confirm_action(
|
||||||
ctx=ctx,
|
ctx,
|
||||||
br_type=br_type,
|
br_type,
|
||||||
title=title.upper(),
|
title.upper(),
|
||||||
data=str(data),
|
description,
|
||||||
description=description,
|
str(data),
|
||||||
|
hold=hold,
|
||||||
br_code=br_code,
|
br_code=br_code,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -898,11 +900,11 @@ async def confirm_address(
|
|||||||
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
||||||
) -> Awaitable[None]:
|
) -> Awaitable[None]:
|
||||||
return confirm_blob(
|
return confirm_blob(
|
||||||
ctx=ctx,
|
ctx,
|
||||||
br_type=br_type,
|
br_type,
|
||||||
title=title.upper(),
|
title.upper(),
|
||||||
data=address,
|
address,
|
||||||
description=description,
|
description,
|
||||||
br_code=br_code,
|
br_code=br_code,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -916,11 +918,11 @@ async def confirm_text(
|
|||||||
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
||||||
) -> Any:
|
) -> Any:
|
||||||
return await _placeholder_confirm(
|
return await _placeholder_confirm(
|
||||||
ctx=ctx,
|
ctx,
|
||||||
br_type=br_type,
|
br_type,
|
||||||
title=title,
|
title,
|
||||||
data=data,
|
data,
|
||||||
description=description,
|
description,
|
||||||
br_code=br_code,
|
br_code=br_code,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -933,12 +935,12 @@ def confirm_amount(
|
|||||||
br_type: str = "confirm_amount",
|
br_type: str = "confirm_amount",
|
||||||
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
||||||
) -> Awaitable[None]:
|
) -> Awaitable[None]:
|
||||||
return _placeholder_confirm(
|
return confirm_blob(
|
||||||
ctx=ctx,
|
ctx,
|
||||||
br_type=br_type,
|
br_type,
|
||||||
title=title.upper(),
|
title.upper(),
|
||||||
data=amount,
|
amount,
|
||||||
description=description,
|
description,
|
||||||
br_code=br_code,
|
br_code=br_code,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -991,12 +993,14 @@ def confirm_value(
|
|||||||
if not verb and not hold:
|
if not verb and not hold:
|
||||||
raise ValueError("Either verb or hold=True must be set")
|
raise ValueError("Either verb or hold=True must be set")
|
||||||
|
|
||||||
return _placeholder_confirm(
|
return confirm_action(
|
||||||
ctx=ctx,
|
ctx,
|
||||||
br_type=br_type,
|
br_type,
|
||||||
title=title.upper(),
|
title.upper(),
|
||||||
data=value,
|
description,
|
||||||
description=description,
|
value,
|
||||||
|
verb=verb or "HOLD TO CONFIRM",
|
||||||
|
hold=hold,
|
||||||
br_code=br_code,
|
br_code=br_code,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -1032,11 +1036,14 @@ async def confirm_total(
|
|||||||
async def confirm_joint_total(
|
async def confirm_joint_total(
|
||||||
ctx: GenericContext, spending_amount: str, total_amount: str
|
ctx: GenericContext, spending_amount: str, total_amount: str
|
||||||
) -> None:
|
) -> None:
|
||||||
await _placeholder_confirm(
|
await confirm_properties(
|
||||||
ctx,
|
ctx,
|
||||||
"confirm_joint_total",
|
"confirm_joint_total",
|
||||||
"JOINT TRANSACTION",
|
"JOINT TRANSACTION",
|
||||||
f"You are contributing:\n{spending_amount}\nto the total amount:\n{total_amount}",
|
(
|
||||||
|
("You are contributing:", spending_amount),
|
||||||
|
("To the total amount:", total_amount),
|
||||||
|
),
|
||||||
br_code=ButtonRequestType.SignTx,
|
br_code=ButtonRequestType.SignTx,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -1054,19 +1061,21 @@ async def confirm_metadata(
|
|||||||
ctx,
|
ctx,
|
||||||
br_type,
|
br_type,
|
||||||
title.upper(),
|
title.upper(),
|
||||||
content.format(param),
|
description=content.format(param),
|
||||||
hold=hold,
|
hold=hold,
|
||||||
br_code=br_code,
|
br_code=br_code,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def confirm_replacement(ctx: GenericContext, description: str, txid: str) -> None:
|
async def confirm_replacement(ctx: GenericContext, description: str, txid: str) -> None:
|
||||||
await _placeholder_confirm(
|
await confirm_value(
|
||||||
ctx,
|
ctx,
|
||||||
"confirm_replacement",
|
|
||||||
description.upper(),
|
description.upper(),
|
||||||
f"Confirm transaction ID:\n{txid}",
|
txid,
|
||||||
br_code=ButtonRequestType.SignTx,
|
"Confirm transaction ID:",
|
||||||
|
"confirm_replacement",
|
||||||
|
ButtonRequestType.SignTx,
|
||||||
|
verb="CONFIRM",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -1100,24 +1109,26 @@ async def confirm_modify_fee(
|
|||||||
total_fee_new: str,
|
total_fee_new: str,
|
||||||
fee_rate_amount: str | None = None,
|
fee_rate_amount: str | None = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
text = ""
|
|
||||||
if sign == 0:
|
if sign == 0:
|
||||||
text += "Your fee did not change.\n"
|
change_verb = "Your fee did not change."
|
||||||
else:
|
else:
|
||||||
if sign < 0:
|
if sign < 0:
|
||||||
text += "Decrease your fee by:\n"
|
change_verb = "Decrease your fee by:"
|
||||||
else:
|
else:
|
||||||
text += "Increase your fee by:\n"
|
change_verb = "Increase your fee by:"
|
||||||
text += f"{user_fee_change}\n"
|
|
||||||
text += f"Transaction fee:\n{total_fee_new}"
|
|
||||||
if fee_rate_amount is not None:
|
|
||||||
text += "\n" + fee_rate_amount
|
|
||||||
|
|
||||||
await _placeholder_confirm(
|
properties: list[tuple[str, str]] = [
|
||||||
|
(change_verb, user_fee_change),
|
||||||
|
("Transaction fee:", total_fee_new),
|
||||||
|
]
|
||||||
|
if fee_rate_amount is not None:
|
||||||
|
properties.append(("Fee rate:", fee_rate_amount))
|
||||||
|
|
||||||
|
await confirm_properties(
|
||||||
ctx,
|
ctx,
|
||||||
"modify_fee",
|
"modify_fee",
|
||||||
"MODIFY FEE",
|
"MODIFY FEE",
|
||||||
text,
|
properties,
|
||||||
br_code=ButtonRequestType.SignTx,
|
br_code=ButtonRequestType.SignTx,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -1125,11 +1136,14 @@ async def confirm_modify_fee(
|
|||||||
async def confirm_coinjoin(
|
async def confirm_coinjoin(
|
||||||
ctx: GenericContext, max_rounds: int, max_fee_per_vbyte: str
|
ctx: GenericContext, max_rounds: int, max_fee_per_vbyte: str
|
||||||
) -> None:
|
) -> None:
|
||||||
await _placeholder_confirm(
|
await confirm_properties(
|
||||||
ctx,
|
ctx,
|
||||||
"coinjoin_final",
|
"coinjoin_final",
|
||||||
"AUTHORIZE COINJOIN",
|
"AUTHORIZE COINJOIN",
|
||||||
f"Maximum rounds: {max_rounds}\n\nMaximum mining fee:\n{max_fee_per_vbyte}",
|
(
|
||||||
|
("Maximum rounds:", str(max_rounds)),
|
||||||
|
("Maximum mining fee:", max_fee_per_vbyte),
|
||||||
|
),
|
||||||
br_code=BR_TYPE_OTHER,
|
br_code=BR_TYPE_OTHER,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -1166,20 +1180,24 @@ async def confirm_signverify(
|
|||||||
header = f"Sign {coin} message"
|
header = f"Sign {coin} message"
|
||||||
br_type = "sign_message"
|
br_type = "sign_message"
|
||||||
|
|
||||||
await _placeholder_confirm(
|
await confirm_value(
|
||||||
ctx=ctx,
|
ctx,
|
||||||
br_type=br_type,
|
header.upper(),
|
||||||
title=header.upper(),
|
address,
|
||||||
data=f"Confirm address:\n{address}",
|
"Confirm address:",
|
||||||
br_code=BR_TYPE_OTHER,
|
br_type,
|
||||||
|
BR_TYPE_OTHER,
|
||||||
|
verb="CONFIRM",
|
||||||
)
|
)
|
||||||
|
|
||||||
await _placeholder_confirm(
|
await confirm_value(
|
||||||
ctx,
|
ctx,
|
||||||
br_type,
|
|
||||||
header.upper(),
|
header.upper(),
|
||||||
f"Confirm message:\n{message}",
|
message,
|
||||||
br_code=BR_TYPE_OTHER,
|
"Confirm message:",
|
||||||
|
br_type,
|
||||||
|
BR_TYPE_OTHER,
|
||||||
|
verb="CONFIRM",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -1257,7 +1275,6 @@ async def request_pin_on_device(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
while True:
|
|
||||||
result = await ctx.wait(dialog)
|
result = await ctx.wait(dialog)
|
||||||
if result is trezorui2.CANCELLED:
|
if result is trezorui2.CANCELLED:
|
||||||
raise wire.PinCancelled
|
raise wire.PinCancelled
|
||||||
@ -1331,6 +1348,8 @@ async def confirm_set_new_pin(
|
|||||||
br_code=br_code,
|
br_code=br_code,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Additional information for the user to know about PIN/WIPE CODE
|
||||||
|
|
||||||
if "wipe_code" in br_type:
|
if "wipe_code" in br_type:
|
||||||
title = "WIPE CODE INFO"
|
title = "WIPE CODE INFO"
|
||||||
verb = "HODL TO BEGIN" # Easter egg from @Hannsek
|
verb = "HODL TO BEGIN" # Easter egg from @Hannsek
|
||||||
@ -1344,7 +1363,7 @@ async def confirm_set_new_pin(
|
|||||||
return await confirm_action(
|
return await confirm_action(
|
||||||
ctx,
|
ctx,
|
||||||
br_type,
|
br_type,
|
||||||
title=title,
|
title,
|
||||||
description="\n".join(information),
|
description="\n".join(information),
|
||||||
verb=verb,
|
verb=verb,
|
||||||
hold=True,
|
hold=True,
|
||||||
|
@ -1110,7 +1110,6 @@ async def request_pin_on_device(
|
|||||||
wrong_pin=wrong_pin,
|
wrong_pin=wrong_pin,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
while True:
|
|
||||||
result = await ctx.wait(dialog)
|
result = await ctx.wait(dialog)
|
||||||
if result is CANCELLED:
|
if result is CANCELLED:
|
||||||
raise PinCancelled
|
raise PinCancelled
|
||||||
|
@ -992,7 +992,8 @@ static secbool decrypt_dek(const uint8_t *kek, const uint8_t *keiv) {
|
|||||||
static void ensure_not_wipe_code(const uint8_t *pin, size_t pin_len) {
|
static void ensure_not_wipe_code(const uint8_t *pin, size_t pin_len) {
|
||||||
if (sectrue != is_not_wipe_code(pin, pin_len)) {
|
if (sectrue != is_not_wipe_code(pin, pin_len)) {
|
||||||
storage_wipe();
|
storage_wipe();
|
||||||
// TODO: need to account for smaller model R - smaller font and different copy
|
// TODO: need to account for smaller model R - smaller font and different
|
||||||
|
// copy
|
||||||
error_shutdown("You have entered the", "wipe code. All private",
|
error_shutdown("You have entered the", "wipe code. All private",
|
||||||
"data has been erased.", NULL);
|
"data has been erased.", NULL);
|
||||||
}
|
}
|
||||||
|
@ -333,6 +333,7 @@ def test_signmessage_pagination(client: Client, message: str):
|
|||||||
|
|
||||||
br = yield
|
br = yield
|
||||||
# TODO: try load the message_read the same way as in model T
|
# TODO: try load the message_read the same way as in model T
|
||||||
|
if br.pages is not None:
|
||||||
for i in range(br.pages):
|
for i in range(br.pages):
|
||||||
if i < br.pages - 1:
|
if i < br.pages - 1:
|
||||||
client.debug.swipe_up()
|
client.debug.swipe_up()
|
||||||
|
@ -90,7 +90,7 @@ def test_cancel_on_paginated(client: Client):
|
|||||||
|
|
||||||
resp = client._raw_read()
|
resp = client._raw_read()
|
||||||
assert isinstance(resp, m.ButtonRequest)
|
assert isinstance(resp, m.ButtonRequest)
|
||||||
assert resp.pages is not None
|
# assert resp.pages is not None
|
||||||
client._raw_write(m.ButtonAck())
|
client._raw_write(m.ButtonAck())
|
||||||
|
|
||||||
client._raw_write(m.Cancel())
|
client._raw_write(m.Cancel())
|
||||||
|
Loading…
Reference in New Issue
Block a user