1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-06-07 00:28:45 +00:00

chore(core/ui): delete unused arguments to layouts

This commit is contained in:
grdddj 2022-10-20 14:28:29 +02:00 committed by Martin Milata
parent d045e0089d
commit ae525fed26
37 changed files with 85 additions and 262 deletions

View File

@ -64,6 +64,7 @@ static void _librust_qstrs(void) {
MP_QSTR_verb; MP_QSTR_verb;
MP_QSTR_verb_cancel; MP_QSTR_verb_cancel;
MP_QSTR_hold; MP_QSTR_hold;
MP_QSTR_hold_danger;
MP_QSTR_reverse; MP_QSTR_reverse;
MP_QSTR_prompt; MP_QSTR_prompt;
MP_QSTR_subprompt; MP_QSTR_subprompt;

View File

@ -6,7 +6,7 @@ use crate::{
}, },
}; };
use super::{theme, Button, ButtonMsg, Loader, LoaderMsg}; use super::{theme, Button, ButtonMsg, ButtonStyleSheet, Loader, LoaderMsg};
pub enum HoldToConfirmMsg<T> { pub enum HoldToConfirmMsg<T> {
Content(T), Content(T),
@ -29,7 +29,7 @@ where
Self { Self {
loader: Loader::new(), loader: Loader::new(),
content: Child::new(content), content: Child::new(content),
buttons: Child::new(CancelHold::new()), buttons: Child::new(CancelHold::new(theme::button_confirm())),
pad: Pad::with_background(theme::BG), pad: Pad::with_background(theme::BG),
} }
} }
@ -123,11 +123,11 @@ pub enum CancelHoldMsg {
} }
impl CancelHold { impl CancelHold {
pub fn new() -> FixedHeightBar<Self> { pub fn new(button_style: ButtonStyleSheet) -> FixedHeightBar<Self> {
theme::button_bar(Self { theme::button_bar(Self {
cancel: Some(Button::with_icon(theme::ICON_CANCEL).into_child()), cancel: Some(Button::with_icon(theme::ICON_CANCEL).into_child()),
hold: Button::with_text("HOLD TO CONFIRM") hold: Button::with_text("HOLD TO CONFIRM")
.styled(theme::button_confirm()) .styled(button_style)
.into_child(), .into_child(),
}) })
} }

View File

@ -237,7 +237,16 @@ where
T: Component, T: Component,
{ {
pub fn new(content: T, background: Color) -> Self { pub fn new(content: T, background: Color) -> Self {
let buttons = CancelHold::new(); let buttons = CancelHold::new(theme::button_confirm());
Self {
inner: SwipePage::new(content, buttons, background),
loader: Loader::new(),
pad: Pad::with_background(background),
}
}
pub fn with_danger(content: T, background: Color) -> Self {
let buttons = CancelHold::new(theme::button_danger());
Self { Self {
inner: SwipePage::new(content, buttons, background), inner: SwipePage::new(content, buttons, background),
loader: Loader::new(), loader: Loader::new(),

View File

@ -278,6 +278,7 @@ extern "C" fn new_confirm_action(n_args: usize, args: *const Obj, kwargs: *mut M
.try_into_option()?; .try_into_option()?;
let reverse: bool = kwargs.get_or(Qstr::MP_QSTR_reverse, false)?; let reverse: bool = kwargs.get_or(Qstr::MP_QSTR_reverse, false)?;
let hold: bool = kwargs.get_or(Qstr::MP_QSTR_hold, false)?; let hold: bool = kwargs.get_or(Qstr::MP_QSTR_hold, false)?;
let hold_danger: bool = kwargs.get_or(Qstr::MP_QSTR_hold_danger, false)?;
let paragraphs = { let paragraphs = {
let action = action.unwrap_or_default(); let action = action.unwrap_or_default();
@ -296,7 +297,12 @@ extern "C" fn new_confirm_action(n_args: usize, args: *const Obj, kwargs: *mut M
}; };
let obj = if hold { let obj = if hold {
LayoutObj::new(Frame::new(title, SwipeHoldPage::new(paragraphs, theme::BG)))? let page = if hold_danger {
SwipeHoldPage::with_danger(paragraphs, theme::BG)
} else {
SwipeHoldPage::new(paragraphs, theme::BG)
};
LayoutObj::new(Frame::new(title, page))?
} else { } else {
let buttons = Button::cancel_confirm_text(verb_cancel, verb); let buttons = Button::cancel_confirm_text(verb_cancel, verb);
LayoutObj::new(Frame::new( LayoutObj::new(Frame::new(
@ -1080,6 +1086,7 @@ pub static mp_module_trezorui2: Module = obj_module! {
/// verb: str | None = None, /// verb: str | None = None,
/// verb_cancel: str | None = None, /// verb_cancel: str | None = None,
/// hold: bool = False, /// hold: bool = False,
/// hold_danger: bool = False,
/// reverse: bool = False, /// reverse: bool = False,
/// ) -> object: /// ) -> object:
/// """Confirm action.""" /// """Confirm action."""

View File

@ -240,6 +240,10 @@ pub fn button_cancel() -> ButtonStyleSheet {
} }
} }
pub fn button_danger() -> ButtonStyleSheet {
button_cancel()
}
pub fn button_reset() -> ButtonStyleSheet { pub fn button_reset() -> ButtonStyleSheet {
ButtonStyleSheet { ButtonStyleSheet {
normal: &ButtonStyle { normal: &ButtonStyle {

View File

@ -65,6 +65,7 @@ def confirm_action(
verb: str | None = None, verb: str | None = None,
verb_cancel: str | None = None, verb_cancel: str | None = None,
hold: bool = False, hold: bool = False,
hold_danger: bool = False,
reverse: bool = False, reverse: bool = False,
) -> object: ) -> object:
"""Confirm action.""" """Confirm action."""

View File

@ -18,7 +18,6 @@ async def get_ownership_proof(
coin: CoinInfo, coin: CoinInfo,
authorization: CoinJoinAuthorization | None = None, authorization: CoinJoinAuthorization | None = None,
) -> OwnershipProof: ) -> OwnershipProof:
from trezor import ui
from trezor.wire import DataError, ProcessError from trezor.wire import DataError, ProcessError
from trezor.enums import InputScriptType from trezor.enums import InputScriptType
from trezor.messages import OwnershipProof from trezor.messages import OwnershipProof
@ -84,8 +83,6 @@ async def get_ownership_proof(
"Proof of ownership", "Proof of ownership",
msg.commitment_data, msg.commitment_data,
"Commitment data:", "Commitment data:",
icon=ui.ICON_CONFIG,
icon_color=ui.ORANGE_ICON,
) )
ownership_proof, signature = generate_proof( ownership_proof, signature = generate_proof(

View File

@ -49,7 +49,6 @@ def format_coin_amount(amount: int, coin: CoinInfo, amount_unit: AmountUnit) ->
async def confirm_output( async def confirm_output(
ctx: Context, output: TxOutput, coin: CoinInfo, amount_unit: AmountUnit ctx: Context, output: TxOutput, coin: CoinInfo, amount_unit: AmountUnit
) -> None: ) -> None:
from trezor import ui
from . import omni from . import omni
from trezor.enums import OutputScriptType from trezor.enums import OutputScriptType
@ -79,17 +78,14 @@ async def confirm_output(
address_short = addresses.address_short(coin, output.address) address_short = addresses.address_short(coin, output.address)
if output.payment_req_index is not None: if output.payment_req_index is not None:
title = "Confirm details" title = "Confirm details"
icon = ui.ICON_CONFIRM
else: else:
title = "Confirm sending" title = "Confirm sending"
icon = ui.ICON_SEND
layout = layouts.confirm_output( layout = layouts.confirm_output(
ctx, ctx,
address_short, address_short,
format_coin_amount(output.amount, coin, amount_unit), format_coin_amount(output.amount, coin, amount_unit),
title=title, title=title,
icon=icon,
) )
await layout await layout

View File

@ -158,17 +158,6 @@ class Credential:
return credential return credential
def should_warn(self) -> bool:
return any(
(
self.is_reward,
self.is_no_staking,
self.is_mismatch,
self.is_unusual_path,
self.is_other_warning,
)
)
def is_set(self) -> bool: def is_set(self) -> bool:
return any((self.path, self.key_hash, self.script_hash, self.pointer)) return any((self.path, self.key_hash, self.script_hash, self.pointer))

View File

@ -192,10 +192,7 @@ async def show_tx_init(ctx: Context, title: str) -> bool:
(ui.NORMAL, "Choose level of details:"), (ui.NORMAL, "Choose level of details:"),
), ),
"Show All", "Show All",
icon=ui.ICON_SEND,
icon_color=ui.GREEN,
confirm="Show Simple", confirm="Show Simple",
major_confirm=True,
) )
return should_show_details return should_show_details
@ -222,11 +219,11 @@ async def confirm_sending(
network_id: int, network_id: int,
) -> None: ) -> None:
if output_type == "address": if output_type == "address":
message = "Confirm sending" title = "Sending"
elif output_type == "change": elif output_type == "change":
message = "Change amount" title = "Change output"
elif output_type == "collateral-return": elif output_type == "collateral-return":
message = "Collateral return" title = "Collateral return"
else: else:
raise RuntimeError # should be unreachable raise RuntimeError # should be unreachable
@ -234,13 +231,8 @@ async def confirm_sending(
ctx, ctx,
to, to,
format_coin_amount(ada_amount, network_id), format_coin_amount(ada_amount, network_id),
ui.BOLD, title,
"Confirm transaction", ButtonRequestType.Other,
f"{message}:",
width_paginated=17,
to_str="\nto\n",
to_paginated=True,
br_code=BRT_Other,
) )
@ -403,20 +395,11 @@ async def _show_credential(
) )
) )
if credential.should_warn():
icon = ui.ICON_WRONG
icon_color = ui.RED
else:
icon = ui.ICON_SEND
icon_color = ui.GREEN
await confirm_properties( await confirm_properties(
ctx, ctx,
"confirm_credential", "confirm_credential",
title, title,
props, props,
icon,
icon_color,
br_code=BRT_Other, br_code=BRT_Other,
) )
@ -438,7 +421,6 @@ async def warn_tx_output_contains_tokens(
"confirm_tokens", "confirm_tokens",
"Confirm transaction", "Confirm transaction",
content, content,
larger_vspace=True,
br_code=BRT_Other, br_code=BRT_Other,
) )
@ -449,7 +431,6 @@ async def warn_tx_contains_mint(ctx: Context) -> None:
"confirm_tokens", "confirm_tokens",
"Confirm transaction", "Confirm transaction",
"The transaction contains minting or burning of tokens.", "The transaction contains minting or burning of tokens.",
larger_vspace=True,
br_code=BRT_Other, br_code=BRT_Other,
) )
@ -860,7 +841,6 @@ async def warn_tx_network_unverifiable(ctx: Context) -> None:
"warning_no_outputs", "warning_no_outputs",
"Warning", "Warning",
"Transaction has no outputs, network cannot be verified.", "Transaction has no outputs, network cannot be verified.",
larger_vspace=True,
br_code=BRT_Other, br_code=BRT_Other,
) )

View File

@ -60,7 +60,6 @@ async def _request_on_host(ctx: Context) -> str:
# non-empty passphrase # non-empty passphrase
if passphrase: if passphrase:
from trezor import ui
from trezor.ui.layouts import confirm_action, confirm_blob from trezor.ui.layouts import confirm_action, confirm_blob
await confirm_action( await confirm_action(
@ -68,7 +67,6 @@ async def _request_on_host(ctx: Context) -> str:
"passphrase_host1", "passphrase_host1",
"Hidden wallet", "Hidden wallet",
description="Access hidden wallet?\n\nNext screen will show\nthe passphrase!", description="Access hidden wallet?\n\nNext screen will show\nthe passphrase!",
icon=ui.ICON_CONFIG,
) )
await confirm_blob( await confirm_blob(
@ -77,8 +75,6 @@ async def _request_on_host(ctx: Context) -> str:
"Hidden wallet", "Hidden wallet",
passphrase, passphrase,
"Use this passphrase?\n", "Use this passphrase?\n",
icon=ui.ICON_CONFIG,
icon_color=ui.ORANGE_ICON,
) )
return passphrase return passphrase

View File

@ -127,7 +127,6 @@ async def error_pin_invalid(ctx: Context) -> NoReturn:
"warning_wrong_pin", "warning_wrong_pin",
"The PIN you entered is invalid.", "The PIN you entered is invalid.",
"Wrong PIN", # header "Wrong PIN", # header
red=True,
exc=wire.PinInvalid, exc=wire.PinInvalid,
) )
assert False assert False
@ -141,7 +140,6 @@ async def error_pin_matches_wipe_code(ctx: Context) -> NoReturn:
"warning_invalid_new_pin", "warning_invalid_new_pin",
"The new PIN must be different from your\nwipe code.", "The new PIN must be different from your\nwipe code.",
"Invalid PIN", # header "Invalid PIN", # header
red=True,
exc=wire.PinInvalid, exc=wire.PinInvalid,
) )
assert False assert False

View File

@ -1,5 +1,5 @@
from storage.sd_salt import SD_CARD_HOT_SWAPPABLE from storage.sd_salt import SD_CARD_HOT_SWAPPABLE
from trezor import io, ui, wire from trezor import io, wire
from trezor.ui.layouts import confirm_action, show_error_and_raise from trezor.ui.layouts import confirm_action, show_error_and_raise
@ -17,8 +17,6 @@ async def _confirm_retry_wrong_card(ctx: wire.GenericContext) -> None:
"Please insert the correct SD card for this device.", "Please insert the correct SD card for this device.",
verb="Retry", verb="Retry",
verb_cancel="Abort", verb_cancel="Abort",
icon=ui.ICON_WRONG,
larger_vspace=True,
exc=SdCardUnavailable("Wrong SD card."), exc=SdCardUnavailable("Wrong SD card."),
) )
else: else:
@ -26,7 +24,6 @@ async def _confirm_retry_wrong_card(ctx: wire.GenericContext) -> None:
ctx, ctx,
"warning_wrong_sd", "warning_wrong_sd",
"Please unplug the\ndevice and insert the correct SD card.", "Please unplug the\ndevice and insert the correct SD card.",
"SD card protection",
"Wrong SD card.", "Wrong SD card.",
exc=SdCardUnavailable("Wrong SD card."), exc=SdCardUnavailable("Wrong SD card."),
) )
@ -42,8 +39,6 @@ async def _confirm_retry_insert_card(ctx: wire.GenericContext) -> None:
"Please insert your SD card.", "Please insert your SD card.",
verb="Retry", verb="Retry",
verb_cancel="Abort", verb_cancel="Abort",
icon=ui.ICON_WRONG,
larger_vspace=True,
exc=SdCardUnavailable("SD card required."), exc=SdCardUnavailable("SD card required."),
) )
else: else:
@ -51,7 +46,6 @@ async def _confirm_retry_insert_card(ctx: wire.GenericContext) -> None:
ctx, ctx,
"warning_no_sd", "warning_no_sd",
"Please unplug the\ndevice and insert your SD card.", "Please unplug the\ndevice and insert your SD card.",
"SD card protection",
"SD card required.", "SD card required.",
exc=SdCardUnavailable("SD card required."), exc=SdCardUnavailable("SD card required."),
) )
@ -65,11 +59,8 @@ async def _confirm_format_card(ctx: wire.GenericContext) -> None:
"SD card error", "SD card error",
"Unknown filesystem.", "Unknown filesystem.",
"Use a different card or format the SD card to the FAT32 filesystem.", "Use a different card or format the SD card to the FAT32 filesystem.",
icon=ui.ICON_WRONG,
icon_color=ui.RED,
verb="Format", verb="Format",
verb_cancel="Cancel", verb_cancel="Cancel",
larger_vspace=True,
exc=SdCardUnavailable("SD card not formatted."), exc=SdCardUnavailable("SD card not formatted."),
) )
@ -82,10 +73,7 @@ async def _confirm_format_card(ctx: wire.GenericContext) -> None:
"Do you really want to format the SD card?", "Do you really want to format the SD card?",
reverse=True, reverse=True,
verb="Format SD card", verb="Format SD card",
icon=ui.ICON_WIPE,
icon_color=ui.RED,
hold=True, hold=True,
larger_vspace=True,
exc=SdCardUnavailable("SD card not formatted."), exc=SdCardUnavailable("SD card not formatted."),
) )
@ -100,8 +88,6 @@ async def confirm_retry_sd(
"SD card problem", "SD card problem",
None, None,
"There was a problem accessing the SD card.", "There was a problem accessing the SD card.",
icon=ui.ICON_WRONG,
icon_color=ui.RED,
verb="Retry", verb="Retry",
verb_cancel="Abort", verb_cancel="Abort",
exc=exc, exc=exc,

View File

@ -6,6 +6,8 @@ if not __debug__:
if __debug__: if __debug__:
from storage import debug as storage from storage import debug as storage
import trezorui2
from trezor import log, loop, wire from trezor import log, loop, wire
from trezor.ui import display from trezor.ui import display
from trezor.enums import MessageType from trezor.enums import MessageType
@ -50,13 +52,6 @@ if __debug__:
LAYOUT_WATCHER_STATE = 1 LAYOUT_WATCHER_STATE = 1
LAYOUT_WATCHER_LAYOUT = 2 LAYOUT_WATCHER_LAYOUT = 2
try:
import trezorui2
UI2 = True
except ImportError:
UI2 = False
def screenshot() -> bool: def screenshot() -> bool:
if storage.save_screen: if storage.save_screen:
display.save(storage.save_screen_directory + "/refresh-") display.save(storage.save_screen_directory + "/refresh-")
@ -78,20 +73,16 @@ if __debug__:
SWIPE_RIGHT, SWIPE_RIGHT,
) )
if UI2:
confirm = trezorui2
else:
from trezor.ui.components.tt import confirm
button = msg.button # local_cache_attribute button = msg.button # local_cache_attribute
swipe = msg.swipe # local_cache_attribute swipe = msg.swipe # local_cache_attribute
if button is not None: if button is not None:
if button == DebugButton.NO: if button == DebugButton.NO:
await confirm_chan.put(Result(confirm.CANCELLED)) await confirm_chan.put(Result(trezorui2.CANCELLED))
elif button == DebugButton.YES: elif button == DebugButton.YES:
await confirm_chan.put(Result(confirm.CONFIRMED)) await confirm_chan.put(Result(trezorui2.CONFIRMED))
elif button == DebugButton.INFO: elif button == DebugButton.INFO:
await confirm_chan.put(Result(confirm.INFO)) await confirm_chan.put(Result(trezorui2.INFO))
if swipe is not None: if swipe is not None:
if swipe == DebugSwipeDirection.UP: if swipe == DebugSwipeDirection.UP:
await swipe_chan.put(SWIPE_UP) await swipe_chan.put(SWIPE_UP)

View File

@ -1,6 +1,5 @@
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from trezor import ui
from trezor.enums import ButtonRequestType from trezor.enums import ButtonRequestType
from trezor.ui.layouts import confirm_properties from trezor.ui.layouts import confirm_properties
@ -42,7 +41,6 @@ async def _confirm_properties(
br_type, br_type,
title, title,
props, props,
icon=ui.ICON_CONFIRM,
br_code=ButtonRequestType.ConfirmOutput, br_code=ButtonRequestType.ConfirmOutput,
) )
@ -267,8 +265,6 @@ async def confirm_action_unknown(
("Action Name:", eos_name_to_string(action.name)), ("Action Name:", eos_name_to_string(action.name)),
("Checksum:", checksum), ("Checksum:", checksum),
), ),
ui.ICON_WIPE,
ui.RED,
br_code=ButtonRequestType.ConfirmOutput, br_code=ButtonRequestType.ConfirmOutput,
) )

View File

@ -11,7 +11,6 @@ async def require_get_public_key(ctx: Context, public_key: str) -> None:
async def require_sign_tx(ctx: Context, num_actions: int) -> None: async def require_sign_tx(ctx: Context, num_actions: int) -> None:
from trezor import ui
from trezor.enums import ButtonRequestType from trezor.enums import ButtonRequestType
from trezor.strings import format_plural from trezor.strings import format_plural
from trezor.ui.layouts import confirm_action from trezor.ui.layouts import confirm_action
@ -22,7 +21,5 @@ async def require_sign_tx(ctx: Context, num_actions: int) -> None:
"Sign transaction", "Sign transaction",
description="You are about to sign {}.", description="You are about to sign {}.",
description_param=format_plural("{count} {plural}", num_actions, "action"), description_param=format_plural("{count} {plural}", num_actions, "action"),
icon=ui.ICON_SEND,
icon_color=ui.GREEN,
br_code=ButtonRequestType.SignTx, br_code=ButtonRequestType.SignTx,
) )

View File

@ -34,8 +34,6 @@ def require_confirm_tx(
ctx, ctx,
to_str, to_str,
format_ethereum_amount(value, token, chain_id), format_ethereum_amount(value, token, chain_id),
ui.BOLD,
color_to=ui.GREY,
br_code=ButtonRequestType.SignTx, br_code=ButtonRequestType.SignTx,
) )
@ -85,8 +83,8 @@ async def require_confirm_eip1559_fee(
ctx, ctx,
format_ethereum_amount(spending, token, chain_id), format_ethereum_amount(spending, token, chain_id),
format_ethereum_amount(max_gas_fee * gas_limit, None, chain_id), format_ethereum_amount(max_gas_fee * gas_limit, None, chain_id),
total_label="Amount sent:\n", total_label="Amount sent:",
fee_label="\nMaximum fee:\n", fee_label="Maximum fee:",
) )
@ -103,7 +101,6 @@ def require_confirm_unknown_token(
contract_address_hex, contract_address_hex,
"Contract:", "Contract:",
"unknown_token", "unknown_token",
icon_color=ui.ORANGE,
br_code=ButtonRequestType.SignTx, br_code=ButtonRequestType.SignTx,
) )

View File

@ -238,7 +238,6 @@ async def _require_confirm_safety_checks(
hold=True, hold=True,
verb="Hold to confirm", verb="Hold to confirm",
reverse=True, reverse=True,
larger_vspace=level == SafetyCheckLevel.PromptAlways,
br_code=BRT_PROTECT_CALL, br_code=BRT_PROTECT_CALL,
) )
else: else:

View File

@ -60,7 +60,6 @@ async def change_wipe_code(ctx: Context, msg: ChangeWipeCode) -> Success:
def _require_confirm_action( 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 import ui
from trezor.wire import ProcessError from trezor.wire import ProcessError
from trezor.ui.layouts import confirm_action from trezor.ui.layouts import confirm_action
@ -72,7 +71,6 @@ def _require_confirm_action(
"disable wipe code protection?", "disable wipe code protection?",
"Do you really want to", "Do you really want to",
reverse=True, reverse=True,
icon=ui.ICON_CONFIG,
) )
if not msg.remove and has_wipe_code: if not msg.remove and has_wipe_code:
@ -83,7 +81,6 @@ def _require_confirm_action(
"change the wipe code?", "change the wipe code?",
"Do you really want to", "Do you really want to",
reverse=True, reverse=True,
icon=ui.ICON_CONFIG,
) )
if not msg.remove and not has_wipe_code: if not msg.remove and not has_wipe_code:
@ -94,7 +91,6 @@ def _require_confirm_action(
"set the wipe code?", "set the wipe code?",
"Do you really want to", "Do you really want to",
reverse=True, reverse=True,
icon=ui.ICON_CONFIG,
) )
# Removing non-existing wipe code. # Removing non-existing wipe code.

View File

@ -7,7 +7,6 @@ if TYPE_CHECKING:
async def get_next_u2f_counter(ctx: Context, msg: GetNextU2FCounter) -> NextU2FCounter: async def get_next_u2f_counter(ctx: Context, msg: GetNextU2FCounter) -> NextU2FCounter:
import storage.device as storage_device import storage.device as storage_device
from trezor import ui
from trezor.wire import NotInitialized from trezor.wire import NotInitialized
from trezor.enums import ButtonRequestType from trezor.enums import ButtonRequestType
from trezor.messages import NextU2FCounter from trezor.messages import NextU2FCounter
@ -21,7 +20,6 @@ async def get_next_u2f_counter(ctx: Context, msg: GetNextU2FCounter) -> NextU2FC
"get_u2f_counter", "get_u2f_counter",
"Get next U2F counter", "Get next U2F counter",
description="Do you really want to increase and retrieve\nthe U2F counter?", description="Do you really want to increase and retrieve\nthe U2F counter?",
icon=ui.ICON_CONFIG,
br_code=ButtonRequestType.ProtectCall, br_code=ButtonRequestType.ProtectCall,
) )

View File

@ -20,7 +20,6 @@ async def reboot_to_bootloader(ctx: Context, msg: RebootToBootloader) -> NoRetur
"reboot", "reboot",
"Go to bootloader", "Go to bootloader",
"Do you want to restart Trezor in bootloader mode?", "Do you want to restart Trezor in bootloader mode?",
hold_danger=True,
verb="Restart", verb="Restart",
) )
await ctx.write(Success(message="Rebooting")) await ctx.write(Success(message="Rebooting"))

View File

@ -21,7 +21,7 @@ async def recovery_device(ctx: Context, msg: RecoveryDevice) -> Success:
import storage import storage
import storage.device as storage_device import storage.device as storage_device
import storage.recovery as storage_recovery import storage.recovery as storage_recovery
from trezor import config, ui, wire, workflow from trezor import config, wire, workflow
from trezor.enums import ButtonRequestType from trezor.enums import ButtonRequestType
from trezor.ui.layouts import confirm_action, confirm_reset_device from trezor.ui.layouts import confirm_action, confirm_reset_device
from apps.common.request_pin import ( from apps.common.request_pin import (
@ -66,7 +66,6 @@ async def recovery_device(ctx: Context, msg: RecoveryDevice) -> Success:
"confirm_seedcheck", "confirm_seedcheck",
"Seed check", "Seed check",
description="Do you really want to check the recovery seed?", description="Do you really want to check the recovery seed?",
icon=ui.ICON_RECOVERY,
br_code=ButtonRequestType.ProtectCall, br_code=ButtonRequestType.ProtectCall,
) )
# END _continue_dialog # END _continue_dialog

View File

@ -17,7 +17,6 @@ if TYPE_CHECKING:
async def _confirm_abort(ctx: GenericContext, dry_run: bool = False) -> None: async def _confirm_abort(ctx: GenericContext, dry_run: bool = False) -> None:
from trezor import ui
from trezor.ui.layouts import confirm_action from trezor.ui.layouts import confirm_action
if dry_run: if dry_run:
@ -26,7 +25,6 @@ async def _confirm_abort(ctx: GenericContext, dry_run: bool = False) -> None:
"abort_recovery", "abort_recovery",
"Abort seed check", "Abort seed check",
description="Do you really want to abort the seed check?", description="Do you really want to abort the seed check?",
icon=ui.ICON_WIPE,
br_code=ButtonRequestType.ProtectCall, br_code=ButtonRequestType.ProtectCall,
) )
else: else:
@ -37,7 +35,6 @@ async def _confirm_abort(ctx: GenericContext, dry_run: bool = False) -> None:
"All progress will be lost.", "All progress will be lost.",
"Do you really want to abort the recovery process?", "Do you really want to abort the recovery process?",
reverse=True, reverse=True,
icon=ui.ICON_WIPE,
br_code=ButtonRequestType.ProtectCall, br_code=ButtonRequestType.ProtectCall,
) )

View File

@ -23,7 +23,6 @@ _NUM_OF_CHOICES = const(3)
async def show_internal_entropy(ctx: GenericContext, entropy: bytes) -> None: async def show_internal_entropy(ctx: GenericContext, entropy: bytes) -> None:
from trezor import ui
from trezor.ui.layouts import confirm_blob from trezor.ui.layouts import confirm_blob
await confirm_blob( await confirm_blob(
@ -31,8 +30,6 @@ async def show_internal_entropy(ctx: GenericContext, entropy: bytes) -> None:
"entropy", "entropy",
"Internal entropy", "Internal entropy",
entropy, entropy,
icon=ui.ICON_RESET,
icon_color=ui.ORANGE_ICON,
br_code=ButtonRequestType.ResetDevice, br_code=ButtonRequestType.ResetDevice,
) )
@ -127,15 +124,10 @@ async def _show_confirmation_failure(
) -> None: ) -> None:
from trezor.ui.layouts import show_warning from trezor.ui.layouts import show_warning
if share_index is None:
header = "Recovery seed"
else:
header = f"Recovery share #{share_index + 1}"
await show_warning( await show_warning(
ctx, ctx,
"warning_backup_check", "warning_backup_check",
"Please check again.", "Please check again.",
header,
"That is the wrong word.", "That is the wrong word.",
"Check again", "Check again",
ButtonRequestType.ResetDevice, ButtonRequestType.ResetDevice,

View File

@ -7,7 +7,7 @@ if TYPE_CHECKING:
async def set_u2f_counter(ctx: Context, msg: SetU2FCounter) -> Success: async def set_u2f_counter(ctx: Context, msg: SetU2FCounter) -> Success:
import storage.device as storage_device import storage.device as storage_device
from trezor import ui, wire from trezor import wire
from trezor.enums import ButtonRequestType from trezor.enums import ButtonRequestType
from trezor.messages import Success from trezor.messages import Success
from trezor.ui.layouts import confirm_action from trezor.ui.layouts import confirm_action
@ -23,7 +23,6 @@ async def set_u2f_counter(ctx: Context, msg: SetU2FCounter) -> Success:
"Set U2F counter", "Set U2F counter",
description="Do you really want to\nset the U2F counter\nto {}?", description="Do you really want to\nset the U2F counter\nto {}?",
description_param=str(msg.u2f_counter), description_param=str(msg.u2f_counter),
icon=ui.ICON_CONFIG,
br_code=ButtonRequestType.ProtectCall, br_code=ButtonRequestType.ProtectCall,
) )

View File

@ -7,7 +7,6 @@ if TYPE_CHECKING:
async def wipe_device(ctx: GenericContext, msg: WipeDevice) -> Success: async def wipe_device(ctx: GenericContext, msg: WipeDevice) -> Success:
import storage import storage
from trezor import ui
from trezor.enums import ButtonRequestType from trezor.enums import ButtonRequestType
from trezor.messages import Success from trezor.messages import Success
from trezor.ui.layouts import confirm_action from trezor.ui.layouts import confirm_action
@ -18,14 +17,12 @@ async def wipe_device(ctx: GenericContext, msg: WipeDevice) -> Success:
ctx, ctx,
"confirm_wipe", "confirm_wipe",
"Wipe device", "Wipe device",
"All data will be lost.", "All data will be erased.",
"Do you really want to\nwipe the device?\n", "Do you really want to\nwipe the device?\n",
reverse=True, reverse=True,
verb="Hold to confirm", verb="Hold to confirm",
hold=True, hold=True,
hold_danger=True, hold_danger=True,
icon=ui.ICON_WIPE,
icon_color=ui.RED,
br_code=ButtonRequestType.WipeDevice, br_code=ButtonRequestType.WipeDevice,
) )

View File

@ -15,7 +15,6 @@ async def get_ecdh_session_key(ctx: Context, msg: GetECDHSessionKey) -> ECDHSess
serialize_identity_without_proto, serialize_identity_without_proto,
serialize_identity, serialize_identity,
) )
from trezor import ui
from trezor.wire import DataError from trezor.wire import DataError
from trezor.messages import ECDHSessionKey from trezor.messages import ECDHSessionKey
from apps.common.keychain import get_keychain from apps.common.keychain import get_keychain
@ -35,8 +34,6 @@ async def get_ecdh_session_key(ctx: Context, msg: GetECDHSessionKey) -> ECDHSess
f"Decrypt {proto}", f"Decrypt {proto}",
serialize_identity_without_proto(msg_identity), serialize_identity_without_proto(msg_identity),
None, None,
icon=ui.ICON_DEFAULT,
icon_color=ui.ORANGE_ICON,
) )
# END require_confirm_ecdh_session_key # END require_confirm_ecdh_session_key

View File

@ -34,8 +34,6 @@ async def require_confirm_watchkey(ctx: Context) -> None:
"get_watchkey", "get_watchkey",
"Confirm export", "Confirm export",
description="Do you really want to export watch-only credentials?", description="Do you really want to export watch-only credentials?",
icon=ui.ICON_SEND,
icon_color=ui.GREEN,
br_code=BRT_SignTx, br_code=BRT_SignTx,
) )
@ -46,8 +44,6 @@ async def require_confirm_keyimage_sync(ctx: Context) -> None:
"key_image_sync", "key_image_sync",
"Confirm ki sync", "Confirm ki sync",
description="Do you really want to\nsync key images?", description="Do you really want to\nsync key images?",
icon=ui.ICON_SEND,
icon_color=ui.GREEN,
br_code=BRT_SignTx, br_code=BRT_SignTx,
) )
@ -58,8 +54,6 @@ async def require_confirm_live_refresh(ctx: Context) -> None:
"live_refresh", "live_refresh",
"Confirm refresh", "Confirm refresh",
description="Do you really want to\nstart refresh?", description="Do you really want to\nstart refresh?",
icon=ui.ICON_SEND,
icon_color=ui.GREEN,
br_code=BRT_SignTx, br_code=BRT_SignTx,
) )
@ -75,8 +69,6 @@ async def require_confirm_tx_key(ctx: Context, export_key: bool = False) -> None
"export_tx_key", "export_tx_key",
"Confirm export", "Confirm export",
description=description, description=description,
icon=ui.ICON_SEND,
icon_color=ui.GREEN,
br_code=BRT_SignTx, br_code=BRT_SignTx,
) )
@ -145,7 +137,6 @@ async def _require_confirm_output(
ctx, ctx,
addr, addr,
_format_amount(dst.amount), _format_amount(dst.amount),
ui.BOLD,
br_code=BRT_SignTx, br_code=BRT_SignTx,
) )
@ -169,7 +160,6 @@ async def _require_confirm_fee(ctx: Context, fee: int) -> None:
"Confirm fee", "Confirm fee",
"{}", "{}",
_format_amount(fee), _format_amount(fee),
hide_continue=True,
hold=True, hold=True,
) )

View File

@ -16,7 +16,6 @@ async def require_confirm_text(ctx: Context, action: str) -> None:
"confirm_nem", "confirm_nem",
"Confirm action", "Confirm action",
action, action,
hide_continue=True,
br_code=ButtonRequestType.ConfirmOutput, br_code=ButtonRequestType.ConfirmOutput,
) )
@ -29,7 +28,6 @@ async def require_confirm_fee(ctx: Context, action: str, fee: int) -> None:
action + "\n{}", action + "\n{}",
f"{format_amount(fee, NEM_MAX_DIVISIBILITY)} XEM", f"{format_amount(fee, NEM_MAX_DIVISIBILITY)} XEM",
ButtonRequestType.ConfirmOutput, ButtonRequestType.ConfirmOutput,
hide_continue=True,
) )
@ -52,6 +50,5 @@ async def require_confirm_final(ctx: Context, fee: int) -> None:
"Final confirm", "Final confirm",
"Sign this transaction\n{}\nfor network fee?", "Sign this transaction\n{}\nfor network fee?",
f"and pay {format_amount(fee, NEM_MAX_DIVISIBILITY)} XEM", f"and pay {format_amount(fee, NEM_MAX_DIVISIBILITY)} XEM",
hide_continue=True,
hold=True, hold=True,
) )

View File

@ -54,7 +54,6 @@ async def _require_confirm_properties(
ctx: Context, definition: NEMMosaicDefinition ctx: Context, definition: NEMMosaicDefinition
) -> None: ) -> None:
from trezor.enums import NEMMosaicLevy from trezor.enums import NEMMosaicLevy
from trezor import ui
from trezor.ui.layouts import confirm_properties from trezor.ui.layouts import confirm_properties
properties = [] properties = []
@ -102,5 +101,4 @@ async def _require_confirm_properties(
"confirm_properties", "confirm_properties",
"Confirm properties", "Confirm properties",
properties, properties,
icon_color=ui.ORANGE_ICON,
) )

View File

@ -1,6 +1,5 @@
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from trezor import ui
from trezor.enums import ButtonRequestType from trezor.enums import ButtonRequestType
from trezor.strings import format_amount from trezor.strings import format_amount
@ -36,7 +35,6 @@ async def ask_transfer(
bytes(transfer.payload).decode(), bytes(transfer.payload).decode(),
"Encrypted:" if encrypted else "Unencrypted:", "Encrypted:" if encrypted else "Unencrypted:",
ButtonRequestType.ConfirmOutput, ButtonRequestType.ConfirmOutput,
icon_color=ui.GREEN if encrypted else ui.RED,
) )
for mosaic in transfer.mosaics: for mosaic in transfer.mosaics:
@ -47,9 +45,7 @@ async def ask_transfer(
ctx, ctx,
transfer.recipient, transfer.recipient,
f"Send {format_amount(_get_xem_amount(transfer), NEM_MAX_DIVISIBILITY)} XEM", f"Send {format_amount(_get_xem_amount(transfer), NEM_MAX_DIVISIBILITY)} XEM",
ui.BOLD,
"Confirm transfer", "Confirm transfer",
to_str="\nto\n",
) )
await require_confirm_final(ctx, common.fee) await require_confirm_final(ctx, common.fee)
@ -111,8 +107,6 @@ async def _ask_transfer_mosaic(
"Confirm mosaic", "Confirm mosaic",
"Unknown mosaic!", "Unknown mosaic!",
"Divisibility and levy cannot be shown for unknown mosaics", "Divisibility and levy cannot be shown for unknown mosaics",
icon=ui.ICON_SEND,
icon_color=ui.RED,
br_code=ButtonRequestType.ConfirmOutput, br_code=ButtonRequestType.ConfirmOutput,
) )

View File

@ -18,7 +18,6 @@ async def require_confirm_fee(ctx: Context, fee: int) -> None:
"Transaction fee:\n{}", "Transaction fee:\n{}",
format_amount(fee, DECIMALS) + " XRP", format_amount(fee, DECIMALS) + " XRP",
ButtonRequestType.ConfirmOutput, ButtonRequestType.ConfirmOutput,
hide_continue=True,
) )
@ -30,7 +29,6 @@ async def require_confirm_destination_tag(ctx: Context, tag: int) -> None:
"Destination tag:\n{}", "Destination tag:\n{}",
str(tag), str(tag),
ButtonRequestType.ConfirmOutput, ButtonRequestType.ConfirmOutput,
hide_continue=True,
) )

View File

@ -1,7 +1,7 @@
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
import trezor.ui.layouts as layouts import trezor.ui.layouts as layouts
from trezor import strings, ui from trezor import strings
from trezor.enums import ButtonRequestType from trezor.enums import ButtonRequestType
from . import consts from . import consts
@ -26,7 +26,6 @@ async def require_confirm_init(
address, address,
description, description,
"confirm_init", "confirm_init",
icon=ui.ICON_SEND,
) )
# get_network_warning # get_network_warning
@ -45,8 +44,6 @@ async def require_confirm_init(
"Transaction is on {}", "Transaction is on {}",
network, network,
ButtonRequestType.ConfirmOutput, ButtonRequestType.ConfirmOutput,
icon=ui.ICON_CONFIRM,
hide_continue=True,
) )
@ -88,8 +85,6 @@ async def require_confirm_memo(
"Confirm memo", "Confirm memo",
"No memo set!", "No memo set!",
"Important: Many exchanges require a memo when depositing", "Important: Many exchanges require a memo when depositing",
icon=ui.ICON_CONFIRM,
icon_color=ui.GREEN,
br_code=ButtonRequestType.ConfirmOutput, br_code=ButtonRequestType.ConfirmOutput,
) )
@ -110,7 +105,6 @@ async def require_confirm_final(ctx: Context, fee: int, num_operations: int) ->
"Final confirm", "Final confirm",
"Sign this transaction made up of " + op_str + " and pay {}\nfor fee?", "Sign this transaction made up of " + op_str + " and pay {}\nfor fee?",
format_amount(fee), format_amount(fee),
hide_continue=True,
hold=True, hold=True,
) )

View File

@ -1,6 +1,5 @@
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from trezor import ui
from trezor.enums import ButtonRequestType from trezor.enums import ButtonRequestType
from trezor.ui.layouts import confirm_address, confirm_metadata, confirm_properties from trezor.ui.layouts import confirm_address, confirm_metadata, confirm_properties
@ -9,7 +8,6 @@ if TYPE_CHECKING:
BR_SIGN_TX = ButtonRequestType.SignTx # global_import_cache BR_SIGN_TX = ButtonRequestType.SignTx # global_import_cache
BLUE = ui.BLUE # global_import_cache
async def require_confirm_tx(ctx: Context, to: str, value: int) -> None: async def require_confirm_tx(ctx: Context, to: str, value: int) -> None:
@ -19,9 +17,6 @@ async def require_confirm_tx(ctx: Context, to: str, value: int) -> None:
ctx, ctx,
to, to,
format_tezos_amount(value), format_tezos_amount(value),
ui.BOLD,
to_str="\nto\n",
width=18,
br_code=BR_SIGN_TX, br_code=BR_SIGN_TX,
) )
@ -33,8 +28,7 @@ async def require_confirm_fee(ctx: Context, value: int, fee: int) -> None:
ctx, ctx,
format_tezos_amount(value), format_tezos_amount(value),
format_tezos_amount(fee), format_tezos_amount(fee),
total_label="Amount:\n", total_label="Amount:",
fee_label="\nFee:\n",
) )
@ -46,7 +40,6 @@ async def require_confirm_origination(ctx: Context, address: str) -> None:
"Address:", "Address:",
"confirm_origination", "confirm_origination",
BR_SIGN_TX, BR_SIGN_TX,
icon_color=ui.ORANGE,
) )
@ -59,7 +52,6 @@ async def require_confirm_origination_fee(ctx: Context, balance: int, fee: int)
("Balance:", format_tezos_amount(balance)), ("Balance:", format_tezos_amount(balance)),
("Fee:", format_tezos_amount(fee)), ("Fee:", format_tezos_amount(fee)),
), ),
icon_color=ui.ORANGE,
hold=True, hold=True,
) )
@ -72,7 +64,6 @@ async def require_confirm_delegation_baker(ctx: Context, baker: str) -> None:
"Baker address:", "Baker address:",
"confirm_delegation", "confirm_delegation",
BR_SIGN_TX, BR_SIGN_TX,
icon_color=BLUE,
) )
@ -84,9 +75,7 @@ async def require_confirm_set_delegate(ctx: Context, fee: int) -> None:
"Fee:\n{}", "Fee:\n{}",
format_tezos_amount(fee), format_tezos_amount(fee),
BR_SIGN_TX, BR_SIGN_TX,
hide_continue=True,
hold=True, hold=True,
icon_color=BLUE,
) )
@ -101,7 +90,6 @@ async def require_confirm_register_delegate(
("Fee:", format_tezos_amount(fee)), ("Fee:", format_tezos_amount(fee)),
("Address:", address), ("Address:", address),
), ),
icon_color=BLUE,
br_code=BR_SIGN_TX, br_code=BR_SIGN_TX,
) )
@ -123,7 +111,6 @@ async def require_confirm_ballot(ctx: Context, proposal: str, ballot: str) -> No
("Ballot:", ballot), ("Ballot:", ballot),
("Proposal:", proposal), ("Proposal:", proposal),
), ),
icon_color=ui.PURPLE,
br_code=BR_SIGN_TX, br_code=BR_SIGN_TX,
) )
@ -134,7 +121,6 @@ async def require_confirm_proposals(ctx: Context, proposals: list[str]) -> None:
"confirm_proposals", "confirm_proposals",
"Submit proposals" if len(proposals) > 1 else "Submit proposal", "Submit proposals" if len(proposals) > 1 else "Submit proposal",
[("Proposal " + str(i), proposal) for i, proposal in enumerate(proposals, 1)], [("Proposal " + str(i), proposal) for i, proposal in enumerate(proposals, 1)],
icon_color=ui.PURPLE,
br_code=BR_SIGN_TX, br_code=BR_SIGN_TX,
) )
@ -149,8 +135,6 @@ async def require_confirm_delegation_manager_withdraw(
"Delegator:", "Delegator:",
"confirm_undelegation", "confirm_undelegation",
BR_SIGN_TX, BR_SIGN_TX,
icon=ui.ICON_RECEIVE,
icon_color=ui.RED,
) )
@ -162,8 +146,5 @@ async def require_confirm_manager_remove_delegate(ctx: Context, fee: int) -> Non
"Fee:\n{}", "Fee:\n{}",
format_tezos_amount(fee), format_tezos_amount(fee),
BR_SIGN_TX, BR_SIGN_TX,
hide_continue=True,
hold=True, hold=True,
icon=ui.ICON_RECEIVE,
icon_color=ui.RED,
) )

View File

@ -47,9 +47,6 @@ async def add_resident_credential(
ctx, ctx,
"warning_credential", "warning_credential",
"The credential you are trying to import does\nnot belong to this authenticator.", "The credential you are trying to import does\nnot belong to this authenticator.",
"Import credential",
button="Close",
red=True,
) )
if not await confirm_webauthn(ctx, ConfirmAddCredential(cred)): if not await confirm_webauthn(ctx, ConfirmAddCredential(cred)):

View File

@ -5,6 +5,7 @@ from trezor.enums import ButtonRequestType
import trezorui2 import trezorui2
from ...components.common.confirm import is_confirmed
from ..common import button_request, interact from ..common import button_request, interact
if TYPE_CHECKING: if TYPE_CHECKING:
@ -62,11 +63,7 @@ async def confirm_action(
verb: str | bytes | None = "OK", verb: str | bytes | None = "OK",
verb_cancel: str | bytes | None = "cancel", verb_cancel: str | bytes | None = "cancel",
hold: bool = False, hold: bool = False,
hold_danger: bool = False,
icon: str | None = None,
icon_color: int | None = None,
reverse: bool = False, reverse: bool = False,
larger_vspace: bool = False,
exc: ExceptionType = wire.ActionCancelled, exc: ExceptionType = wire.ActionCancelled,
br_code: ButtonRequestType = ButtonRequestType.Other, br_code: ButtonRequestType = ButtonRequestType.Other,
) -> None: ) -> None:
@ -97,7 +94,7 @@ async def confirm_action(
br_type, br_type,
br_code, br_code,
) )
if result is not trezorui2.CONFIRMED: if not is_confirmed(result):
raise exc raise exc
@ -108,8 +105,6 @@ async def confirm_text(
data: str, data: str,
description: str | None = None, description: str | None = None,
br_code: ButtonRequestType = ButtonRequestType.Other, br_code: ButtonRequestType = ButtonRequestType.Other,
icon: str = ui.ICON_SEND, # TODO cleanup @ redesign
icon_color: int = ui.GREEN, # TODO cleanup @ redesign
) -> None: ) -> None:
result = await interact( result = await interact(
ctx, ctx,
@ -123,7 +118,7 @@ async def confirm_text(
br_type, br_type,
br_code, br_code,
) )
if result is not trezorui2.CONFIRMED: if not is_confirmed(result):
raise wire.ActionCancelled raise wire.ActionCancelled
@ -144,7 +139,7 @@ async def show_success(
br_type, br_type,
br_code=ButtonRequestType.Other, br_code=ButtonRequestType.Other,
) )
if result is not trezorui2.CONFIRMED: if not is_confirmed(result):
raise wire.ActionCancelled raise wire.ActionCancelled
@ -173,7 +168,7 @@ async def show_address(
"show_address", "show_address",
ButtonRequestType.Address, ButtonRequestType.Address,
) )
if result is not trezorui2.CONFIRMED: if not is_confirmed(result):
raise wire.ActionCancelled raise wire.ActionCancelled
@ -181,9 +176,8 @@ async def confirm_output(
ctx: wire.GenericContext, ctx: wire.GenericContext,
address: str, address: str,
amount: str, amount: str,
font_amount: int = ui.NORMAL, # TODO cleanup @ redesign
title: str = "Confirm sending", title: str = "Confirm sending",
icon: str = ui.ICON_SEND, br_code: ButtonRequestType = ButtonRequestType.ConfirmOutput,
) -> None: ) -> None:
result = await interact( result = await interact(
ctx, ctx,
@ -195,9 +189,9 @@ async def confirm_output(
) )
), ),
"confirm_output", "confirm_output",
ButtonRequestType.Other, br_code,
) )
if result is not trezorui2.CONFIRMED: if not is_confirmed(result):
raise wire.ActionCancelled raise wire.ActionCancelled
@ -205,10 +199,10 @@ async def confirm_total(
ctx: wire.GenericContext, ctx: wire.GenericContext,
total_amount: str, total_amount: str,
fee_amount: str, fee_amount: str,
fee_rate_amount: str | None = None,
title: str = "Confirm transaction", title: str = "Confirm transaction",
total_label: str = "Total amount:\n", total_label: str = "Total amount:\n",
fee_label: str = "\nincluding fee:\n", fee_label: str = "\nincluding fee:\n",
icon_color: int = ui.GREEN,
br_type: str = "confirm_total", br_type: str = "confirm_total",
br_code: ButtonRequestType = ButtonRequestType.SignTx, br_code: ButtonRequestType = ButtonRequestType.SignTx,
) -> None: ) -> None:
@ -224,7 +218,7 @@ async def confirm_total(
br_type, br_type,
br_code, br_code,
) )
if result is not trezorui2.CONFIRMED: if not is_confirmed(result):
raise wire.ActionCancelled raise wire.ActionCancelled
@ -236,8 +230,6 @@ async def confirm_blob(
description: str | None = None, description: str | None = None,
hold: bool = False, hold: bool = False,
br_code: ButtonRequestType = ButtonRequestType.Other, br_code: ButtonRequestType = ButtonRequestType.Other,
icon: str = ui.ICON_SEND, # TODO cleanup @ redesign
icon_color: int = ui.GREEN, # TODO cleanup @ redesign
ask_pagination: bool = False, ask_pagination: bool = False,
) -> None: ) -> None:
result = await interact( result = await interact(
@ -252,7 +244,7 @@ async def confirm_blob(
br_type, br_type,
br_code, br_code,
) )
if result is not trezorui2.CONFIRMED: if not is_confirmed(result):
raise wire.ActionCancelled raise wire.ActionCancelled
@ -276,10 +268,8 @@ async def show_error_and_raise(
ctx: wire.GenericContext, ctx: wire.GenericContext,
br_type: str, br_type: str,
content: str, content: str,
header: str = "Error",
subheader: str | None = None, subheader: str | None = None,
button: str = "Close", button: str = "Close",
red: bool = False,
exc: ExceptionType = wire.ActionCancelled, exc: ExceptionType = wire.ActionCancelled,
) -> NoReturn: ) -> NoReturn:
raise NotImplementedError raise NotImplementedError

View File

@ -1,4 +1,5 @@
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from ubinascii import hexlify
from trezor import io, log, loop, ui from trezor import io, log, loop, ui
from trezor.enums import ButtonRequestType from trezor.enums import ButtonRequestType
@ -6,6 +7,7 @@ from trezor.wire import ActionCancelled
import trezorui2 import trezorui2
from ...components.common.confirm import CANCELLED, CONFIRMED, INFO
from ..common import button_request, interact from ..common import button_request, interact
if TYPE_CHECKING: if TYPE_CHECKING:
@ -17,9 +19,6 @@ if TYPE_CHECKING:
T = TypeVar("T") T = TypeVar("T")
CONFIRMED = trezorui2.CONFIRMED # global_import_cache
CANCELLED = trezorui2.CANCELLED # global_import_cache
INFO = trezorui2.INFO # global_import_cache
BR_TYPE_OTHER = ButtonRequestType.Other # global_import_cache BR_TYPE_OTHER = ButtonRequestType.Other # global_import_cache
@ -188,10 +187,7 @@ async def confirm_action(
verb_cancel: str | bytes | None = None, verb_cancel: str | bytes | None = None,
hold: bool = False, hold: bool = False,
hold_danger: bool = False, hold_danger: bool = False,
icon: str | None = None,
icon_color: int | None = None,
reverse: bool = False, reverse: bool = False,
larger_vspace: bool = False,
exc: ExceptionType = ActionCancelled, exc: ExceptionType = ActionCancelled,
br_code: ButtonRequestType = BR_TYPE_OTHER, br_code: ButtonRequestType = BR_TYPE_OTHER,
) -> None: ) -> None:
@ -218,6 +214,7 @@ async def confirm_action(
verb=verb, verb=verb,
verb_cancel=verb_cancel, verb_cancel=verb_cancel,
hold=hold, hold=hold,
hold_danger=hold_danger,
reverse=reverse, reverse=reverse,
) )
), ),
@ -290,14 +287,18 @@ async def confirm_backup(ctx: GenericContext) -> bool:
async def confirm_path_warning( async def confirm_path_warning(
ctx: GenericContext, path: str, path_type: str = "Path" ctx: GenericContext,
path: str,
path_type: str | None = None,
) -> None: ) -> None:
await raise_if_not_confirmed( await raise_if_not_confirmed(
interact( interact(
ctx, ctx,
_RustLayout( _RustLayout(
trezorui2.show_warning( trezorui2.show_warning(
title="Unknown path", title="Unknown path"
if not path_type
else f"Unknown {path_type.lower()}",
description=path, description=path,
) )
), ),
@ -397,11 +398,10 @@ def show_pubkey(
) -> Awaitable[None]: ) -> Awaitable[None]:
return confirm_blob( return confirm_blob(
ctx, ctx,
br_type="show_pubkey", "show_pubkey",
title="Confirm public key", title,
data=pubkey, pubkey,
br_code=ButtonRequestType.PublicKey, br_code=ButtonRequestType.PublicKey,
icon=ui.ICON_RECEIVE,
) )
@ -409,10 +409,8 @@ async def show_error_and_raise(
ctx: GenericContext, ctx: GenericContext,
br_type: str, br_type: str,
content: str, content: str,
header: str = "Error",
subheader: str | None = None, subheader: str | None = None,
button: str = "CLOSE", button: str = "CLOSE",
red: bool = False,
exc: ExceptionType = ActionCancelled, exc: ExceptionType = ActionCancelled,
) -> NoReturn: ) -> NoReturn:
await interact( await interact(
@ -435,12 +433,9 @@ async def show_warning(
ctx: GenericContext, ctx: GenericContext,
br_type: str, br_type: str,
content: str, content: str,
header: str = "Warning",
subheader: str | None = None, subheader: str | None = None,
button: str = "TRY AGAIN", button: str = "TRY AGAIN",
br_code: ButtonRequestType = ButtonRequestType.Warning, br_code: ButtonRequestType = ButtonRequestType.Warning,
icon: str = ui.ICON_WRONG,
icon_color: int = ui.RED,
) -> None: ) -> None:
await raise_if_not_confirmed( await raise_if_not_confirmed(
interact( interact(
@ -487,16 +482,8 @@ async def confirm_output(
ctx: GenericContext, ctx: GenericContext,
address: str, address: str,
amount: str, amount: str,
font_amount: int = ui.NORMAL, # TODO cleanup @ redesign
title: str = "SENDING", title: str = "SENDING",
subtitle: str | None = None, # TODO cleanup @ redesign
color_to: int = ui.FG, # TODO cleanup @ redesign
to_str: str = " to\n", # TODO cleanup @ redesign
to_paginated: bool = False, # TODO cleanup @ redesign
width: int = 0, # TODO cleanup @ redesign
width_paginated: int = 0, # TODO cleanup @ redesign
br_code: ButtonRequestType = ButtonRequestType.ConfirmOutput, br_code: ButtonRequestType = ButtonRequestType.ConfirmOutput,
icon: str = ui.ICON_SEND,
) -> None: ) -> None:
title = title.upper() title = title.upper()
if title.startswith("CONFIRM "): if title.startswith("CONFIRM "):
@ -559,10 +546,7 @@ async def should_show_more(
button_text: str = "Show all", button_text: str = "Show all",
br_type: str = "should_show_more", br_type: str = "should_show_more",
br_code: ButtonRequestType = BR_TYPE_OTHER, br_code: ButtonRequestType = BR_TYPE_OTHER,
icon: str = ui.ICON_DEFAULT,
icon_color: int = ui.ORANGE_ICON,
confirm: str | bytes | None = None, confirm: str | bytes | None = None,
major_confirm: bool = False,
) -> bool: ) -> bool:
"""Return True if the user wants to show more (they click a special button) """Return True if the user wants to show more (they click a special button)
and False when the user wants to continue without showing details. and False when the user wants to continue without showing details.
@ -607,12 +591,8 @@ async def confirm_blob(
description: str | None = None, description: str | None = None,
hold: bool = False, hold: bool = False,
br_code: ButtonRequestType = BR_TYPE_OTHER, br_code: ButtonRequestType = BR_TYPE_OTHER,
icon: str = ui.ICON_SEND, # TODO cleanup @ redesign
icon_color: int = ui.GREEN, # TODO cleanup @ redesign
ask_pagination: bool = False, ask_pagination: bool = False,
) -> None: ) -> None:
from ubinascii import hexlify
if isinstance(data, bytes): if isinstance(data, bytes):
data = hexlify(data).decode() data = hexlify(data).decode()
@ -641,8 +621,6 @@ def confirm_address(
description: str | None = "Address:", description: str | None = "Address:",
br_type: str = "confirm_address", br_type: str = "confirm_address",
br_code: ButtonRequestType = BR_TYPE_OTHER, br_code: ButtonRequestType = BR_TYPE_OTHER,
icon: str = ui.ICON_SEND, # TODO cleanup @ redesign
icon_color: int = ui.GREEN, # TODO cleanup @ redesign
) -> Awaitable[None]: ) -> Awaitable[None]:
return confirm_value( return confirm_value(
ctx, ctx,
@ -662,8 +640,6 @@ async def confirm_text(
data: str, data: str,
description: str | None = None, description: str | None = None,
br_code: ButtonRequestType = BR_TYPE_OTHER, br_code: ButtonRequestType = BR_TYPE_OTHER,
icon: str = ui.ICON_SEND, # TODO cleanup @ redesign
icon_color: int = ui.GREEN, # TODO cleanup @ redesign
) -> None: ) -> None:
return await confirm_value( return await confirm_value(
ctx, ctx,
@ -683,8 +659,6 @@ def confirm_amount(
description: str = "Amount:", description: str = "Amount:",
br_type: str = "confirm_amount", br_type: str = "confirm_amount",
br_code: ButtonRequestType = BR_TYPE_OTHER, br_code: ButtonRequestType = BR_TYPE_OTHER,
icon: str = ui.ICON_SEND, # TODO cleanup @ redesign
icon_color: int = ui.GREEN, # TODO cleanup @ redesign
) -> Awaitable[None]: ) -> Awaitable[None]:
return confirm_value( return confirm_value(
ctx, ctx,
@ -736,20 +710,17 @@ async def confirm_properties(
br_type: str, br_type: str,
title: str, title: str,
props: Iterable[PropertyType], props: Iterable[PropertyType],
icon: str = ui.ICON_SEND, # TODO cleanup @ redesign
icon_color: int = ui.GREEN, # TODO cleanup @ redesign
hold: bool = False, hold: bool = False,
br_code: ButtonRequestType = ButtonRequestType.ConfirmOutput, br_code: ButtonRequestType = ButtonRequestType.ConfirmOutput,
) -> None: ) -> None:
def handle_bytes(prop): def handle_bytes(prop: PropertyType) -> tuple[str | None, str | None, bool]:
from ubinascii import hexlify
if isinstance(prop[1], bytes): if isinstance(prop[1], bytes):
return (prop[0], hexlify(prop[1]).decode(), True) return (prop[0], hexlify(prop[1]).decode(), True)
else: else:
return (prop[0], prop[1], False) return (prop[0], prop[1], False)
result = await interact( await raise_if_not_confirmed(
interact(
ctx, ctx,
_RustLayout( _RustLayout(
trezorui2.confirm_properties( trezorui2.confirm_properties(
@ -761,8 +732,7 @@ async def confirm_properties(
br_type, br_type,
br_code, br_code,
) )
if result is not trezorui2.CONFIRMED: )
raise ActionCancelled
async def confirm_total( async def confirm_total(
@ -773,10 +743,10 @@ async def confirm_total(
title: str = "SENDING", title: str = "SENDING",
total_label: str = "Total amount:", total_label: str = "Total amount:",
fee_label: str = "Fee:", fee_label: str = "Fee:",
icon_color: int = ui.GREEN,
br_type: str = "confirm_total", br_type: str = "confirm_total",
br_code: ButtonRequestType = ButtonRequestType.SignTx, br_code: ButtonRequestType = ButtonRequestType.SignTx,
) -> None: ) -> None:
# TODO: include fee_rate_amount
await confirm_value( await confirm_value(
ctx, ctx,
title, title,
@ -824,12 +794,7 @@ async def confirm_metadata(
content: str, content: str,
param: str | None = None, param: str | None = None,
br_code: ButtonRequestType = ButtonRequestType.SignTx, br_code: ButtonRequestType = ButtonRequestType.SignTx,
hide_continue: bool = False,
hold: bool = False, hold: bool = False,
param_font: int = ui.BOLD,
icon: str = ui.ICON_SEND, # TODO cleanup @ redesign
icon_color: int = ui.GREEN, # TODO cleanup @ redesign
larger_vspace: bool = False, # TODO cleanup @ redesign
) -> None: ) -> None:
if param: if param:
content = content.format(param) content = content.format(param)
@ -909,6 +874,7 @@ 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:
# TODO: include fee_rate_amount
await raise_if_not_confirmed( await raise_if_not_confirmed(
interact( interact(
ctx, ctx,