1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-21 22:08:08 +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)) trezorui2.disable_animation(bool(DISABLE_ANIMATION))
class _RustLayout(ui.Layout): class RustLayout(ui.Layout):
# pylint: disable=super-init-not-called # pylint: disable=super-init-not-called
def __init__(self, layout: Any): def __init__(self, layout: Any):
self.layout = layout self.layout = layout
@ -85,7 +85,7 @@ async def confirm_action(
result = await interact( result = await interact(
ctx, ctx,
_RustLayout( RustLayout(
trezorui2.confirm_action( trezorui2.confirm_action(
title=title.upper(), title=title.upper(),
action=action, action=action,
@ -113,7 +113,7 @@ async def confirm_text(
) -> None: ) -> None:
result = await interact( result = await interact(
ctx, ctx,
_RustLayout( RustLayout(
trezorui2.confirm_text( trezorui2.confirm_text(
title=title.upper(), title=title.upper(),
data=data, data=data,
@ -134,7 +134,7 @@ async def show_success(
) -> None: ) -> None:
result = await interact( result = await interact(
ctx, ctx,
_RustLayout( RustLayout(
trezorui2.confirm_text( trezorui2.confirm_text(
title="Success", title="Success",
data=content, data=content,
@ -163,7 +163,7 @@ async def show_address(
) -> None: ) -> None:
result = await interact( result = await interact(
ctx, ctx,
_RustLayout( RustLayout(
trezorui2.confirm_text( trezorui2.confirm_text(
title="ADDRESS", title="ADDRESS",
data=address, data=address,
@ -186,7 +186,7 @@ async def confirm_output(
) -> None: ) -> None:
result = await interact( result = await interact(
ctx, ctx,
_RustLayout( RustLayout(
trezorui2.confirm_text( trezorui2.confirm_text(
title=title, title=title,
data=f"Send {amount} to {address}?", data=f"Send {amount} to {address}?",
@ -213,7 +213,7 @@ async def confirm_total(
) -> None: ) -> None:
result = await interact( result = await interact(
ctx, ctx,
_RustLayout( RustLayout(
trezorui2.confirm_text( trezorui2.confirm_text(
title=title, title=title,
data=f"{total_label}{total_amount}\n{fee_label}{fee_amount}", data=f"{total_label}{total_amount}\n{fee_label}{fee_amount}",
@ -239,7 +239,7 @@ async def confirm_blob(
) -> None: ) -> None:
result = await interact( result = await interact(
ctx, ctx,
_RustLayout( RustLayout(
trezorui2.confirm_text( trezorui2.confirm_text(
title=title, title=title,
data=str(data), data=str(data),

View File

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

View File

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

View File

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

View File

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

View File

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