1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-21 05:48:23 +00:00

chore(core/ui): RustLayout not a private class

[no changelog]
This commit is contained in:
Martin Milata 2022-11-11 13:34:47 +01:00
parent 2a3aabb57e
commit a11be914cc
6 changed files with 57 additions and 57 deletions

View File

@ -19,7 +19,7 @@ if __debug__:
trezorui2.disable_animation(bool(DISABLE_ANIMATION))
class _RustLayout(ui.Layout):
class RustLayout(ui.Layout):
# pylint: disable=super-init-not-called
def __init__(self, layout: Any):
self.layout = layout
@ -85,7 +85,7 @@ async def confirm_action(
result = await interact(
ctx,
_RustLayout(
RustLayout(
trezorui2.confirm_action(
title=title.upper(),
action=action,
@ -113,7 +113,7 @@ async def confirm_text(
) -> None:
result = await interact(
ctx,
_RustLayout(
RustLayout(
trezorui2.confirm_text(
title=title.upper(),
data=data,
@ -134,7 +134,7 @@ async def show_success(
) -> None:
result = await interact(
ctx,
_RustLayout(
RustLayout(
trezorui2.confirm_text(
title="Success",
data=content,
@ -163,7 +163,7 @@ async def show_address(
) -> None:
result = await interact(
ctx,
_RustLayout(
RustLayout(
trezorui2.confirm_text(
title="ADDRESS",
data=address,
@ -186,7 +186,7 @@ async def confirm_output(
) -> None:
result = await interact(
ctx,
_RustLayout(
RustLayout(
trezorui2.confirm_text(
title=title,
data=f"Send {amount} to {address}?",
@ -213,7 +213,7 @@ async def confirm_total(
) -> None:
result = await interact(
ctx,
_RustLayout(
RustLayout(
trezorui2.confirm_text(
title=title,
data=f"{total_label}{total_amount}\n{fee_label}{fee_amount}",
@ -239,7 +239,7 @@ async def confirm_blob(
) -> None:
result = await interact(
ctx,
_RustLayout(
RustLayout(
trezorui2.confirm_text(
title=title,
data=str(data),

View File

@ -30,7 +30,7 @@ if __debug__:
trezorui2.disable_animation(bool(DISABLE_ANIMATION))
class _RustLayout(ui.Layout):
class RustLayout(ui.Layout):
# pylint: disable=super-init-not-called
def __init__(self, layout: Any, is_backup: bool = False):
self.layout = layout
@ -234,7 +234,7 @@ async def confirm_action(
await raise_if_not_confirmed(
interact(
ctx,
_RustLayout(
RustLayout(
trezorui2.confirm_action(
title=title.upper(),
action=action,
@ -264,7 +264,7 @@ async def confirm_reset_device(
await raise_if_not_confirmed(
interact(
ctx,
_RustLayout(
RustLayout(
trezorui2.confirm_reset_device(
title=title.upper(),
prompt=prompt.replace("\n", " "),
@ -282,7 +282,7 @@ async def confirm_reset_device(
async def confirm_backup(ctx: GenericContext) -> bool:
result = await interact(
ctx,
_RustLayout(
RustLayout(
trezorui2.confirm_action(
title="SUCCESS",
action="New wallet created successfully.",
@ -299,7 +299,7 @@ async def confirm_backup(ctx: GenericContext) -> bool:
result = await interact(
ctx,
_RustLayout(
RustLayout(
trezorui2.confirm_action(
title="WARNING",
action="Are you sure you want to skip the backup?",
@ -322,7 +322,7 @@ async def confirm_path_warning(
await raise_if_not_confirmed(
interact(
ctx,
_RustLayout(
RustLayout(
trezorui2.show_warning(
title="Unknown path"
if not path_type
@ -337,7 +337,7 @@ async def confirm_path_warning(
def _show_xpub(xpub: str, title: str, cancel: str) -> ui.Layout:
content = _RustLayout(
content = RustLayout(
trezorui2.confirm_blob(
title=title,
data=xpub,
@ -377,7 +377,7 @@ async def show_address(
while True:
result = await interact(
ctx,
_RustLayout(
RustLayout(
trezorui2.confirm_blob(
title=title.upper(),
data=address,
@ -394,7 +394,7 @@ async def show_address(
result = await interact(
ctx,
_RustLayout(
RustLayout(
trezorui2.show_qr(
address=address if address_qr is None else address_qr,
case_sensitive=case_sensitive,
@ -445,7 +445,7 @@ async def show_error_and_raise(
) -> NoReturn:
await interact(
ctx,
_RustLayout(
RustLayout(
trezorui2.show_error(
title=content.replace("\n", " "),
description=subheader or "",
@ -470,7 +470,7 @@ async def show_warning(
await raise_if_not_confirmed(
interact(
ctx,
_RustLayout(
RustLayout(
trezorui2.show_warning(
title=content.replace("\n", " "),
description=subheader or "",
@ -494,7 +494,7 @@ async def show_success(
await raise_if_not_confirmed(
interact(
ctx,
_RustLayout(
RustLayout(
trezorui2.show_success(
title=content.replace("\n", " "),
description=subheader or "",
@ -550,7 +550,7 @@ async def confirm_payment_request(
result = await interact(
ctx,
_RustLayout(
RustLayout(
trezorui2.confirm_with_info(
title="SENDING",
items=[(ui.NORMAL, f"{amount} to\n{recipient_name}")]
@ -589,7 +589,7 @@ async def should_show_more(
result = await interact(
ctx,
_RustLayout(
RustLayout(
trezorui2.confirm_with_info(
title=title.upper(),
items=para,
@ -635,7 +635,7 @@ async def _confirm_ask_pagination(
return
if paginated is None:
paginated = _RustLayout(
paginated = RustLayout(
trezorui2.confirm_more(
title=title,
button="CLOSE",
@ -663,7 +663,7 @@ async def confirm_blob(
) -> None:
title = title.upper()
description = description or ""
layout = _RustLayout(
layout = RustLayout(
trezorui2.confirm_blob(
title=title,
description=description,
@ -764,7 +764,7 @@ def confirm_value(
return raise_if_not_confirmed(
interact(
ctx,
_RustLayout(
RustLayout(
trezorui2.confirm_value(
title=title.upper(),
description=description,
@ -793,7 +793,7 @@ async def confirm_properties(
await raise_if_not_confirmed(
interact(
ctx,
_RustLayout(
RustLayout(
trezorui2.confirm_properties(
title=title.upper(),
items=items,
@ -847,7 +847,7 @@ async def confirm_joint_total(
await raise_if_not_confirmed(
interact(
ctx,
_RustLayout(
RustLayout(
trezorui2.confirm_joint_total(
spending_amount=spending_amount,
total_amount=total_amount,
@ -897,7 +897,7 @@ async def confirm_metadata(
await raise_if_not_confirmed(
interact(
ctx,
_RustLayout(layout),
RustLayout(layout),
br_type,
br_code,
)
@ -925,7 +925,7 @@ async def confirm_modify_output(
await raise_if_not_confirmed(
interact(
ctx,
_RustLayout(
RustLayout(
trezorui2.confirm_modify_output(
address=address,
sign=sign,
@ -950,7 +950,7 @@ async def confirm_modify_fee(
await raise_if_not_confirmed(
interact(
ctx,
_RustLayout(
RustLayout(
trezorui2.confirm_modify_fee(
sign=sign,
user_fee_change=user_fee_change,
@ -969,7 +969,7 @@ async def confirm_coinjoin(
await raise_if_not_confirmed(
interact(
ctx,
_RustLayout(
RustLayout(
trezorui2.confirm_coinjoin(
max_rounds=str(max_rounds),
max_feerate=max_fee_per_vbyte,
@ -1043,7 +1043,7 @@ async def show_popup(
) -> None:
if subtitle:
title += f"\n{subtitle}"
await _RustLayout(
await RustLayout(
trezorui2.show_error(
title=title,
description=description.format(description_param),
@ -1071,7 +1071,7 @@ async def request_passphrase_on_device(ctx: GenericContext, max_len: int) -> str
ctx, "passphrase_device", code=ButtonRequestType.PassphraseEntry
)
keyboard = _RustLayout(
keyboard = RustLayout(
trezorui2.request_passphrase(prompt="Enter passphrase", max_len=max_len)
)
result = await ctx.wait(keyboard)
@ -1103,7 +1103,7 @@ async def request_pin_on_device(
prompt = "Enter PIN"
subprompt = f"{attempts_remaining} tries left"
dialog = _RustLayout(
dialog = RustLayout(
trezorui2.request_pin(
prompt=prompt,
subprompt=subprompt,

View File

@ -5,7 +5,7 @@ from trezor.enums import ButtonRequestType
import trezorui2
from ..common import interact
from . import _RustLayout
from . import RustLayout
if TYPE_CHECKING:
from trezor.loop import AwaitableTask
@ -16,7 +16,7 @@ if __debug__:
from trezor import io
from ... import Result
class _RustFidoLayoutImpl(_RustLayout):
class _RustFidoLayoutImpl(RustLayout):
def create_tasks(self) -> tuple[AwaitableTask, ...]:
return (
self.handle_timers(),
@ -48,7 +48,7 @@ if __debug__:
_RustFidoLayout = _RustFidoLayoutImpl
else:
_RustFidoLayout = _RustLayout
_RustFidoLayout = RustLayout
async def confirm_fido(
@ -85,7 +85,7 @@ async def confirm_fido(
async def confirm_fido_reset() -> bool:
confirm = _RustLayout(
confirm = RustLayout(
trezorui2.confirm_action(
title="FIDO2 RESET",
action="erase all credentials?",

View File

@ -5,14 +5,14 @@ from trezor import ui
import trezorui2
from . import _RustLayout
from . import RustLayout
if TYPE_CHECKING:
from trezor import loop
from typing import Any, Tuple
class HomescreenBase(_RustLayout):
class HomescreenBase(RustLayout):
RENDER_INDICATOR: object | None = None
def __init__(self, layout: Any) -> None:

View File

@ -6,7 +6,7 @@ from trezor.wire import ActionCancelled
import trezorui2
from ..common import interact
from . import _RustLayout
from . import RustLayout
if TYPE_CHECKING:
from typing import Iterable, Callable
@ -19,7 +19,7 @@ INFO = trezorui2.INFO # global_import_cache
async def _is_confirmed_info(
ctx: GenericContext,
dialog: _RustLayout,
dialog: RustLayout,
info_func: Callable,
) -> bool:
while True:
@ -32,7 +32,7 @@ async def _is_confirmed_info(
async def request_word_count(ctx: GenericContext, dry_run: bool) -> int:
selector = _RustLayout(trezorui2.select_word_count(dry_run=dry_run))
selector = RustLayout(trezorui2.select_word_count(dry_run=dry_run))
count = await interact(
ctx, selector, "word_count", ButtonRequestType.MnemonicWordCount
)
@ -44,9 +44,9 @@ async def request_word(
) -> str:
prompt = f"Type word {word_index + 1} of {word_count}:"
if is_slip39:
keyboard = _RustLayout(trezorui2.request_slip39(prompt=prompt))
keyboard = RustLayout(trezorui2.request_slip39(prompt=prompt))
else:
keyboard = _RustLayout(trezorui2.request_bip39(prompt=prompt))
keyboard = RustLayout(trezorui2.request_bip39(prompt=prompt))
word: str = await ctx.wait(keyboard)
return word
@ -81,7 +81,7 @@ async def show_remaining_shares(
result = await interact(
ctx,
_RustLayout(trezorui2.show_remaining_shares(pages=pages)),
RustLayout(trezorui2.show_remaining_shares(pages=pages)),
"show_shares",
ButtonRequestType.Other,
)
@ -94,7 +94,7 @@ async def show_group_share_success(
) -> None:
result = await interact(
ctx,
_RustLayout(
RustLayout(
trezorui2.show_group_share_success(
lines=[
"You have entered",
@ -129,7 +129,7 @@ async def continue_recovery(
description = "It is safe to eject Trezor\nand continue later"
if info_func is not None:
homepage = _RustLayout(
homepage = RustLayout(
trezorui2.confirm_recovery(
title=title,
description=description,
@ -141,7 +141,7 @@ async def continue_recovery(
await button_request(ctx, "recovery", ButtonRequestType.RecoveryHomepage)
return await _is_confirmed_info(ctx, homepage, info_func)
else:
homepage = _RustLayout(
homepage = RustLayout(
trezorui2.confirm_recovery(
title=text,
description=description,

View File

@ -6,7 +6,7 @@ from trezor.wire import ActionCancelled
import trezorui2
from ..common import interact
from . import _RustLayout
from . import RustLayout
if TYPE_CHECKING:
from typing import Callable, Sequence, List
@ -51,7 +51,7 @@ async def show_share_words(
# result = await interact(
# ctx,
# _RustLayout(
# RustLayout(
# trezorui2.show_simple(
# title=title,
# description=f"Write down these {len(share_words)} words in the exact order:",
@ -68,7 +68,7 @@ async def show_share_words(
result = await interact(
ctx,
_RustLayout(
RustLayout(
trezorui2.show_share_words(
title=title,
pages=pages,
@ -99,7 +99,7 @@ async def select_word(
title = f"CHECK G{group_index + 1} - SHARE {share_index + 1}"
result = await ctx.wait(
_RustLayout(
RustLayout(
trezorui2.select_word(
title=title,
description=f"Select word {checked_index + 1} of {count}:",
@ -136,7 +136,7 @@ async def slip39_show_checklist(
result = await interact(
ctx,
_RustLayout(
RustLayout(
trezorui2.show_checklist(
title="BACKUP CHECKLIST",
button="CONTINUE",
@ -161,7 +161,7 @@ async def _prompt_number(
max_count: int,
br_name: str,
) -> int:
num_input = _RustLayout(
num_input = RustLayout(
trezorui2.request_number(
title=title.upper(),
description=description,
@ -190,7 +190,7 @@ async def _prompt_number(
return value
await ctx.wait(
_RustLayout(
RustLayout(
trezorui2.show_simple(
title=None, description=info(value), button="OK, I UNDERSTAND"
)
@ -338,7 +338,7 @@ async def show_warning_backup(ctx: GenericContext, slip39: bool) -> None:
)
result = await interact(
ctx,
_RustLayout(
RustLayout(
trezorui2.show_info(
title=description,
button="OK, I UNDERSTAND",