1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-02-22 12:32:02 +00:00

core/src: wording changes, new dialogs, specific dialogs for each model

This commit is contained in:
grdddj 2023-03-30 17:54:38 +02:00
parent 68ddb7da39
commit 5469dc45dc
9 changed files with 133 additions and 59 deletions

View File

@ -261,7 +261,7 @@ async def confirm_feeoverthreshold(
ctx,
"fee_over_threshold",
"High fee",
"The fee of\n{}is unexpectedly high.",
"The fee of\n{}\nis unexpectedly high.",
fee_amount,
ButtonRequestType.FeeOverThreshold,
)

View File

@ -30,21 +30,15 @@ async def request_pin(
async def request_pin_confirm(ctx: Context, *args: Any, **kwargs: Any) -> str:
from trezor.ui.layouts import confirm_reenter_pin, pin_mismatch
while True:
pin1 = await request_pin(ctx, "Enter new PIN", *args, **kwargs)
await confirm_reenter_pin(ctx)
pin2 = await request_pin(ctx, "Re-enter new PIN", *args, **kwargs)
if pin1 == pin2:
return pin1
await _pin_mismatch()
async def _pin_mismatch() -> None:
from trezor.ui.layouts import show_popup
await show_popup(
"PIN mismatch",
"The PINs you entered do not match.\n\nPlease try again.",
)
await pin_mismatch(ctx)
async def request_pin_and_sd_salt(
@ -125,7 +119,7 @@ async def error_pin_invalid(ctx: Context) -> NoReturn:
await show_error_and_raise(
ctx,
"warning_wrong_pin",
"The PIN you entered is invalid.",
"The PIN you have entered is not valid.",
"Wrong PIN", # header
exc=wire.PinInvalid,
)

View File

@ -28,7 +28,11 @@ async def change_pin(ctx: Context, msg: ChangePin) -> Success:
await _require_confirm_change_pin(ctx, msg)
# get old pin
curpin, salt = await request_pin_and_sd_salt(ctx, "Enter PIN")
if msg.remove:
prompt = "Enter PIN"
else:
prompt = "Enter old PIN"
curpin, salt = await request_pin_and_sd_salt(ctx, prompt)
# if changing pin, pre-check the entered pin before getting new pin
if curpin and not msg.remove:
@ -50,13 +54,13 @@ async def change_pin(ctx: Context, msg: ChangePin) -> Success:
if newpin:
if curpin:
msg_screen = "You have successfully changed your PIN."
msg_screen = "PIN changed."
msg_wire = "PIN changed"
else:
msg_screen = "You have successfully enabled PIN protection."
msg_screen = "PIN protection enabled."
msg_wire = "PIN enabled"
else:
msg_screen = "You have successfully disabled PIN protection."
msg_screen = "PIN protection disabled."
msg_wire = "PIN removed"
await show_success(ctx, "success_pin", msg_screen)
@ -64,15 +68,18 @@ async def change_pin(ctx: Context, msg: ChangePin) -> Success:
def _require_confirm_change_pin(ctx: Context, msg: ChangePin) -> Awaitable[None]:
from trezor.ui.layouts import confirm_action
from trezor.ui.layouts import confirm_action, confirm_set_new_pin
has_pin = config.has_pin()
br_type = "set_pin"
title = "PIN settings"
if msg.remove and has_pin: # removing pin
return confirm_action(
ctx,
"set_pin",
"PIN settings",
br_type,
title,
description="Do you want to disable PIN protection?",
verb="Disable",
)
@ -80,19 +87,22 @@ def _require_confirm_change_pin(ctx: Context, msg: ChangePin) -> Awaitable[None]
if not msg.remove and has_pin: # changing pin
return confirm_action(
ctx,
"set_pin",
"PIN settings",
br_type,
title,
description="Do you want to change your PIN?",
verb="Change",
)
if not msg.remove and not has_pin: # setting new pin
return confirm_action(
return confirm_set_new_pin(
ctx,
"set_pin",
"PIN settings",
description="Do you want to enable PIN protection?",
verb="Enable",
br_type,
title,
"Do you want to enable PIN protection?",
[
"PIN will be used to access this device.",
"PIN should be 4-50 digits long.",
],
)
# removing non-existing PIN

View File

@ -44,13 +44,13 @@ async def change_wipe_code(ctx: Context, msg: ChangeWipeCode) -> Success:
if wipe_code:
if has_wipe_code:
msg_screen = "You have successfully changed the wipe code."
msg_screen = "Wipe code changed."
msg_wire = "Wipe code changed"
else:
msg_screen = "You have successfully set the wipe code."
msg_screen = "Wipe code enabled."
msg_wire = "Wipe code set"
else:
msg_screen = "You have successfully disabled the wipe code."
msg_screen = "Wipe code disabled."
msg_wire = "Wipe code removed"
await show_success(ctx, "success_wipe_code", msg_screen)
@ -61,36 +61,37 @@ def _require_confirm_action(
ctx: Context, msg: ChangeWipeCode, has_wipe_code: bool
) -> Awaitable[None]:
from trezor.wire import ProcessError
from trezor.ui.layouts import confirm_action
from trezor.ui.layouts import confirm_action, confirm_set_new_pin
title = "Wipe code settings"
if msg.remove and has_wipe_code:
return confirm_action(
ctx,
"disable_wipe_code",
"Disable wipe code",
"disable wipe code protection?",
"Do you really want to",
reverse=True,
title,
description="Do you want to disable wipe code protection?",
verb="Disable",
)
if not msg.remove and has_wipe_code:
return confirm_action(
ctx,
"change_wipe_code",
"Change wipe code",
"change the wipe code?",
"Do you really want to",
reverse=True,
title,
description="Do you want to change the wipe code?",
verb="Change",
)
if not msg.remove and not has_wipe_code:
return confirm_action(
return confirm_set_new_pin(
ctx,
"set_wipe_code",
"Set wipe code",
"set the wipe code?",
"Do you really want to",
reverse=True,
title,
"Do you want to enable wipe code?",
[
"Wipe code can be used to erase all data from this device.",
],
)
# Removing non-existing wipe code.
@ -111,7 +112,7 @@ async def _request_wipe_code_confirm(ctx: Context, pin: str) -> str:
)
continue
code2 = await request_pin(ctx, "Re-enter new wipe code")
code2 = await request_pin(ctx, "Re-enter wipe code")
if code1 == code2:
return code1
# _wipe_code_mismatch

View File

@ -65,7 +65,11 @@ async def _continue_recovery_process(ctx: GenericContext) -> Success:
if is_first_step:
# If we are starting recovery, ask for word count first...
# _request_word_count
await layout.homescreen_dialog(ctx, "Select", "Select number of words")
await layout.homescreen_dialog(
ctx,
"Continue",
"First select the number of words in your recovery seed",
)
# ask for the number of words
word_count = await layout.request_word_count(ctx, dry_run)
# ...and only then show the starting screen with word count.
@ -158,7 +162,7 @@ async def _finish_recovery(
storage_recovery.end_progress()
await show_success(
ctx, "success_recovery", "You have successfully recovered your wallet."
ctx, "success_recovery", "You have finished recovering your wallet."
)
return Success(message="Device recovered")
@ -192,11 +196,11 @@ async def _request_share_first_screen(ctx: GenericContext, word_count: int) -> N
await _request_share_next_screen(ctx)
else:
await layout.homescreen_dialog(
ctx, "Enter share", "Enter any share", f"({word_count} words)"
ctx, "Continue", "Enter any share", f"({word_count} words)"
)
else: # BIP-39
await layout.homescreen_dialog(
ctx, "Enter seed", "Enter recovery seed", f"({word_count} words)"
ctx, "Continue", "Now enter your recovery seed", f"({word_count} words)"
)
@ -212,13 +216,13 @@ async def _request_share_next_screen(ctx: GenericContext) -> None:
if group_count > 1:
await layout.homescreen_dialog(
ctx,
"Enter",
"Continue",
"More shares needed",
info_func=_show_remaining_groups_and_shares,
)
else:
text = strings.format_plural("{count} more {plural}", remaining[0], "share")
await layout.homescreen_dialog(ctx, "Enter share", text, "needed to enter")
await layout.homescreen_dialog(ctx, "Continue", text, "needed to enter")
async def _show_remaining_groups_and_shares(ctx: GenericContext) -> None:

View File

@ -91,12 +91,7 @@ async def show_dry_run_result(
from trezor.ui.layouts import show_success
if result:
if is_slip39:
text = "The entered recovery shares are valid and match what is currently in the device."
else:
text = (
"The entered recovery seed is valid and matches the one in the device."
)
text = "You have finished verifying your recovery seed"
await show_success(ctx, "success_dry_recovery", text, button="Continue")
else:
if is_slip39:

View File

@ -168,8 +168,9 @@ async def show_backup_warning(ctx: GenericContext, slip39: bool = False) -> None
async def show_backup_success(ctx: GenericContext) -> None:
text = "Use your backup when you need to recover your wallet."
await show_success(ctx, "success_backup", text, "Your backup is done.")
from trezor.ui.layouts.reset import show_success_backup
await show_success_backup(ctx)
# BIP39

View File

@ -12,7 +12,7 @@ if TYPE_CHECKING:
from typing import Any, Awaitable, Iterable, NoReturn, Sequence, TypeVar
from trezor.wire import GenericContext, Context
from ..common import PropertyType, ExceptionType, ProgressLayout
from ..common import PropertyType, ExceptionType
T = TypeVar("T")
@ -1142,3 +1142,65 @@ async def request_pin_on_device(
raise PinCancelled
assert isinstance(result, str)
return result
async def confirm_reenter_pin(
ctx: GenericContext,
br_type: str = "set_pin",
br_code: ButtonRequestType = BR_TYPE_OTHER,
) -> None:
return await confirm_action(
ctx,
br_type,
"CHECK PIN",
action="Please re-enter to confirm.",
verb="BEGIN",
br_code=br_code,
)
async def pin_mismatch(
ctx: GenericContext,
br_type: str = "set_pin",
br_code: ButtonRequestType = BR_TYPE_OTHER,
) -> None:
return await confirm_action(
ctx,
br_type,
"PIN MISMATCH",
action="The PINs you entered do not match.\n\nPlease try again.",
verb="TRY AGAIN",
verb_cancel=None,
br_code=br_code,
)
async def confirm_set_new_pin(
ctx: GenericContext,
br_type: str,
title: str,
description: str,
information: list[str],
br_code: ButtonRequestType = BR_TYPE_OTHER,
) -> None:
await confirm_action(
ctx,
br_type,
title,
description=description,
verb="ENABLE",
br_code=br_code,
)
if "wipe_code" in br_type:
title = "WIPE CODE INFO"
else:
title = "PIN INFORMATION"
return await confirm_action(
ctx,
br_type,
title=title,
description="\n\n".join(information),
br_code=br_code,
)

View File

@ -355,3 +355,10 @@ async def show_warning_backup(ctx: GenericContext, slip39: bool) -> None:
)
if result != CONFIRMED:
raise ActionCancelled
async def show_success_backup(ctx: GenericContext) -> None:
from . import show_success
text = "Use your backup when you need to recover your wallet."
await show_success(ctx, "success_backup", text, "Your backup is done.")