1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-07-17 20:18:10 +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, ctx,
"fee_over_threshold", "fee_over_threshold",
"High fee", "High fee",
"The fee of\n{}is unexpectedly high.", "The fee of\n{}\nis unexpectedly high.",
fee_amount, fee_amount,
ButtonRequestType.FeeOverThreshold, ButtonRequestType.FeeOverThreshold,
) )

View File

@ -30,21 +30,15 @@ async def request_pin(
async def request_pin_confirm(ctx: Context, *args: Any, **kwargs: Any) -> str: async def request_pin_confirm(ctx: Context, *args: Any, **kwargs: Any) -> str:
from trezor.ui.layouts import confirm_reenter_pin, pin_mismatch
while True: while True:
pin1 = await request_pin(ctx, "Enter new PIN", *args, **kwargs) 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) pin2 = await request_pin(ctx, "Re-enter new PIN", *args, **kwargs)
if pin1 == pin2: if pin1 == pin2:
return pin1 return pin1
await _pin_mismatch() await pin_mismatch(ctx)
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.",
)
async def request_pin_and_sd_salt( async def request_pin_and_sd_salt(
@ -125,7 +119,7 @@ async def error_pin_invalid(ctx: Context) -> NoReturn:
await show_error_and_raise( await show_error_and_raise(
ctx, ctx,
"warning_wrong_pin", "warning_wrong_pin",
"The PIN you entered is invalid.", "The PIN you have entered is not valid.",
"Wrong PIN", # header "Wrong PIN", # header
exc=wire.PinInvalid, 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) await _require_confirm_change_pin(ctx, msg)
# get old pin # 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 changing pin, pre-check the entered pin before getting new pin
if curpin and not msg.remove: if curpin and not msg.remove:
@ -50,13 +54,13 @@ async def change_pin(ctx: Context, msg: ChangePin) -> Success:
if newpin: if newpin:
if curpin: if curpin:
msg_screen = "You have successfully changed your PIN." msg_screen = "PIN changed."
msg_wire = "PIN changed" msg_wire = "PIN changed"
else: else:
msg_screen = "You have successfully enabled PIN protection." msg_screen = "PIN protection enabled."
msg_wire = "PIN enabled" msg_wire = "PIN enabled"
else: else:
msg_screen = "You have successfully disabled PIN protection." msg_screen = "PIN protection disabled."
msg_wire = "PIN removed" msg_wire = "PIN removed"
await show_success(ctx, "success_pin", msg_screen) 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]: 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() has_pin = config.has_pin()
br_type = "set_pin"
title = "PIN settings"
if msg.remove and has_pin: # removing pin if msg.remove and has_pin: # removing pin
return confirm_action( return confirm_action(
ctx, ctx,
"set_pin", br_type,
"PIN settings", title,
description="Do you want to disable PIN protection?", description="Do you want to disable PIN protection?",
verb="Disable", 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 if not msg.remove and has_pin: # changing pin
return confirm_action( return confirm_action(
ctx, ctx,
"set_pin", br_type,
"PIN settings", title,
description="Do you want to change your PIN?", description="Do you want to change your PIN?",
verb="Change", verb="Change",
) )
if not msg.remove and not has_pin: # setting new pin if not msg.remove and not has_pin: # setting new pin
return confirm_action( return confirm_set_new_pin(
ctx, ctx,
"set_pin", br_type,
"PIN settings", title,
description="Do you want to enable PIN protection?", "Do you want to enable PIN protection?",
verb="Enable", [
"PIN will be used to access this device.",
"PIN should be 4-50 digits long.",
],
) )
# removing non-existing PIN # removing non-existing PIN

View File

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

View File

@ -65,7 +65,11 @@ async def _continue_recovery_process(ctx: GenericContext) -> Success:
if is_first_step: if is_first_step:
# If we are starting recovery, ask for word count first... # If we are starting recovery, ask for word count first...
# _request_word_count # _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 # ask for the number of words
word_count = await layout.request_word_count(ctx, dry_run) word_count = await layout.request_word_count(ctx, dry_run)
# ...and only then show the starting screen with word count. # ...and only then show the starting screen with word count.
@ -158,7 +162,7 @@ async def _finish_recovery(
storage_recovery.end_progress() storage_recovery.end_progress()
await show_success( 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") 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) await _request_share_next_screen(ctx)
else: else:
await layout.homescreen_dialog( 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 else: # BIP-39
await layout.homescreen_dialog( 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: if group_count > 1:
await layout.homescreen_dialog( await layout.homescreen_dialog(
ctx, ctx,
"Enter", "Continue",
"More shares needed", "More shares needed",
info_func=_show_remaining_groups_and_shares, info_func=_show_remaining_groups_and_shares,
) )
else: else:
text = strings.format_plural("{count} more {plural}", remaining[0], "share") 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: 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 from trezor.ui.layouts import show_success
if result: if result:
if is_slip39: text = "You have finished verifying your recovery seed"
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."
)
await show_success(ctx, "success_dry_recovery", text, button="Continue") await show_success(ctx, "success_dry_recovery", text, button="Continue")
else: else:
if is_slip39: 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: async def show_backup_success(ctx: GenericContext) -> None:
text = "Use your backup when you need to recover your wallet." from trezor.ui.layouts.reset import show_success_backup
await show_success(ctx, "success_backup", text, "Your backup is done.")
await show_success_backup(ctx)
# BIP39 # BIP39

View File

@ -12,7 +12,7 @@ if TYPE_CHECKING:
from typing import Any, Awaitable, Iterable, NoReturn, Sequence, TypeVar from typing import Any, Awaitable, Iterable, NoReturn, Sequence, TypeVar
from trezor.wire import GenericContext, Context from trezor.wire import GenericContext, Context
from ..common import PropertyType, ExceptionType, ProgressLayout from ..common import PropertyType, ExceptionType
T = TypeVar("T") T = TypeVar("T")
@ -1142,3 +1142,65 @@ async def request_pin_on_device(
raise PinCancelled raise PinCancelled
assert isinstance(result, str) assert isinstance(result, str)
return result 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: if result != CONFIRMED:
raise ActionCancelled 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.")