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

pull/2643/head
grdddj 2 years ago committed by Martin Milata
parent d045e0089d
commit ae525fed26

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

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

@ -237,7 +237,16 @@ where
T: Component,
{
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 {
inner: SwipePage::new(content, buttons, background),
loader: Loader::new(),

@ -278,6 +278,7 @@ extern "C" fn new_confirm_action(n_args: usize, args: *const Obj, kwargs: *mut M
.try_into_option()?;
let reverse: bool = kwargs.get_or(Qstr::MP_QSTR_reverse, 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 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 {
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 {
let buttons = Button::cancel_confirm_text(verb_cancel, verb);
LayoutObj::new(Frame::new(
@ -1080,6 +1086,7 @@ pub static mp_module_trezorui2: Module = obj_module! {
/// verb: str | None = None,
/// verb_cancel: str | None = None,
/// hold: bool = False,
/// hold_danger: bool = False,
/// reverse: bool = False,
/// ) -> object:
/// """Confirm action."""

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

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

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

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

@ -158,17 +158,6 @@ class 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:
return any((self.path, self.key_hash, self.script_hash, self.pointer))

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

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

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

@ -1,5 +1,5 @@
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
@ -17,8 +17,6 @@ async def _confirm_retry_wrong_card(ctx: wire.GenericContext) -> None:
"Please insert the correct SD card for this device.",
verb="Retry",
verb_cancel="Abort",
icon=ui.ICON_WRONG,
larger_vspace=True,
exc=SdCardUnavailable("Wrong SD card."),
)
else:
@ -26,7 +24,6 @@ async def _confirm_retry_wrong_card(ctx: wire.GenericContext) -> None:
ctx,
"warning_wrong_sd",
"Please unplug the\ndevice and insert the correct SD card.",
"SD card protection",
"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.",
verb="Retry",
verb_cancel="Abort",
icon=ui.ICON_WRONG,
larger_vspace=True,
exc=SdCardUnavailable("SD card required."),
)
else:
@ -51,7 +46,6 @@ async def _confirm_retry_insert_card(ctx: wire.GenericContext) -> None:
ctx,
"warning_no_sd",
"Please unplug the\ndevice and insert your SD card.",
"SD card protection",
"SD card required.",
exc=SdCardUnavailable("SD card required."),
)
@ -65,11 +59,8 @@ async def _confirm_format_card(ctx: wire.GenericContext) -> None:
"SD card error",
"Unknown 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_cancel="Cancel",
larger_vspace=True,
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?",
reverse=True,
verb="Format SD card",
icon=ui.ICON_WIPE,
icon_color=ui.RED,
hold=True,
larger_vspace=True,
exc=SdCardUnavailable("SD card not formatted."),
)
@ -100,8 +88,6 @@ async def confirm_retry_sd(
"SD card problem",
None,
"There was a problem accessing the SD card.",
icon=ui.ICON_WRONG,
icon_color=ui.RED,
verb="Retry",
verb_cancel="Abort",
exc=exc,

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

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

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

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

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

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

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

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

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

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

@ -23,7 +23,6 @@ _NUM_OF_CHOICES = const(3)
async def show_internal_entropy(ctx: GenericContext, entropy: bytes) -> None:
from trezor import ui
from trezor.ui.layouts import confirm_blob
await confirm_blob(
@ -31,8 +30,6 @@ async def show_internal_entropy(ctx: GenericContext, entropy: bytes) -> None:
"entropy",
"Internal entropy",
entropy,
icon=ui.ICON_RESET,
icon_color=ui.ORANGE_ICON,
br_code=ButtonRequestType.ResetDevice,
)
@ -127,15 +124,10 @@ async def _show_confirmation_failure(
) -> None:
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(
ctx,
"warning_backup_check",
"Please check again.",
header,
"That is the wrong word.",
"Check again",
ButtonRequestType.ResetDevice,

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

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

@ -15,7 +15,6 @@ async def get_ecdh_session_key(ctx: Context, msg: GetECDHSessionKey) -> ECDHSess
serialize_identity_without_proto,
serialize_identity,
)
from trezor import ui
from trezor.wire import DataError
from trezor.messages import ECDHSessionKey
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}",
serialize_identity_without_proto(msg_identity),
None,
icon=ui.ICON_DEFAULT,
icon_color=ui.ORANGE_ICON,
)
# END require_confirm_ecdh_session_key

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

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

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

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

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

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

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

@ -47,9 +47,6 @@ async def add_resident_credential(
ctx,
"warning_credential",
"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)):

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

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

Loading…
Cancel
Save