mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-18 05:28:40 +00:00
core: call close_others() in place of ButtonRequest
this makes sense, really: close_others() requests UI exclusivity, and that is something that generally happens at the same places we emit a ButtonRequest
This commit is contained in:
parent
0c3bbef81b
commit
01832d5ae9
@ -1,3 +1,19 @@
|
||||
from micropython import const
|
||||
|
||||
from trezor import workflow
|
||||
from trezor.messages import ButtonRequestType
|
||||
from trezor.messages.ButtonAck import ButtonAck
|
||||
from trezor.messages.ButtonRequest import ButtonRequest
|
||||
|
||||
if False:
|
||||
from trezor import wire
|
||||
from trezor.messages.ButtonRequest import EnumTypeButtonRequestType
|
||||
|
||||
HARDENED = const(0x80000000)
|
||||
|
||||
|
||||
async def button_request(
|
||||
ctx: wire.GenericContext, code: EnumTypeButtonRequestType = ButtonRequestType.Other
|
||||
) -> None:
|
||||
workflow.close_others()
|
||||
await ctx.call(ButtonRequest(code=code), ButtonAck)
|
||||
|
@ -1,12 +1,13 @@
|
||||
from trezor import wire
|
||||
from trezor.messages import ButtonRequestType
|
||||
from trezor.messages.ButtonAck import ButtonAck
|
||||
from trezor.messages.ButtonRequest import ButtonRequest
|
||||
from trezor.ui.confirm import CONFIRMED, INFO, Confirm, HoldToConfirm, InfoConfirm
|
||||
|
||||
from . import button_request
|
||||
|
||||
if __debug__:
|
||||
from trezor.ui.scroll import Paginated
|
||||
|
||||
|
||||
if False:
|
||||
from typing import Any, Callable, Optional
|
||||
from trezor import ui
|
||||
@ -25,7 +26,7 @@ async def confirm(
|
||||
cancel_style: ButtonStyleType = Confirm.DEFAULT_CANCEL_STYLE,
|
||||
major_confirm: bool = False,
|
||||
) -> bool:
|
||||
await ctx.call(ButtonRequest(code=code), ButtonAck)
|
||||
await button_request(ctx, code=code)
|
||||
|
||||
if content.__class__.__name__ == "Paginated":
|
||||
# The following works because asserts are omitted in non-debug builds.
|
||||
@ -61,7 +62,7 @@ async def info_confirm(
|
||||
info: ButtonContent = InfoConfirm.DEFAULT_INFO,
|
||||
info_style: ButtonStyleType = InfoConfirm.DEFAULT_INFO_STYLE,
|
||||
) -> bool:
|
||||
await ctx.call(ButtonRequest(code=code), ButtonAck)
|
||||
await button_request(ctx, code=code)
|
||||
|
||||
dialog = InfoConfirm(
|
||||
content, confirm, confirm_style, cancel, cancel_style, info, info_style
|
||||
@ -86,7 +87,7 @@ async def hold_to_confirm(
|
||||
loader_style: LoaderStyleType = HoldToConfirm.DEFAULT_LOADER_STYLE,
|
||||
cancel: bool = True,
|
||||
) -> bool:
|
||||
await ctx.call(ButtonRequest(code=code), ButtonAck)
|
||||
await button_request(ctx, code=code)
|
||||
|
||||
if content.__class__.__name__ == "Paginated":
|
||||
# The following works because asserts are omitted in non-debug builds.
|
||||
|
@ -3,14 +3,14 @@ from micropython import const
|
||||
import storage.device
|
||||
from trezor import wire, workflow
|
||||
from trezor.messages import ButtonRequestType
|
||||
from trezor.messages.ButtonAck import ButtonAck
|
||||
from trezor.messages.ButtonRequest import ButtonRequest
|
||||
from trezor.messages.PassphraseAck import PassphraseAck
|
||||
from trezor.messages.PassphraseRequest import PassphraseRequest
|
||||
from trezor.ui import ICON_CONFIG, draw_simple
|
||||
from trezor.ui.passphrase import CANCELLED, PassphraseKeyboard
|
||||
from trezor.ui.text import Text
|
||||
|
||||
from . import button_request
|
||||
|
||||
_MAX_PASSPHRASE_LEN = const(50)
|
||||
|
||||
|
||||
@ -56,7 +56,7 @@ async def _request_on_host(ctx: wire.Context) -> str:
|
||||
|
||||
|
||||
async def _request_on_device(ctx: wire.Context) -> str:
|
||||
await ctx.call(ButtonRequest(code=ButtonRequestType.PassphraseEntry), ButtonAck)
|
||||
await button_request(ctx, code=ButtonRequestType.PassphraseEntry)
|
||||
|
||||
keyboard = PassphraseKeyboard("Enter passphrase", _MAX_PASSPHRASE_LEN)
|
||||
passphrase = await ctx.wait(keyboard)
|
||||
|
@ -3,14 +3,13 @@ import utime
|
||||
import storage.sd_salt
|
||||
from trezor import config, ui, wire
|
||||
from trezor.messages import ButtonRequestType
|
||||
from trezor.messages.ButtonAck import ButtonAck
|
||||
from trezor.messages.ButtonRequest import ButtonRequest
|
||||
from trezor.pin import pin_to_int
|
||||
from trezor.ui.pin import CANCELLED, PinDialog
|
||||
from trezor.ui.popup import Popup
|
||||
from trezor.ui.text import Text
|
||||
|
||||
from apps.common.sdcard import SdCardUnavailable, request_sd_salt
|
||||
from . import button_request
|
||||
from .sdcard import SdCardUnavailable, request_sd_salt
|
||||
|
||||
if False:
|
||||
from typing import Any, NoReturn, Optional, Tuple
|
||||
@ -30,7 +29,7 @@ async def request_pin(
|
||||
attempts_remaining: int = None,
|
||||
allow_cancel: bool = True,
|
||||
) -> str:
|
||||
await ctx.call(ButtonRequest(code=ButtonRequestType.PinEntry), ButtonAck)
|
||||
await button_request(ctx, code=ButtonRequestType.PinEntry)
|
||||
|
||||
if attempts_remaining is None:
|
||||
subprompt = None
|
||||
|
@ -79,12 +79,12 @@ if __debug__:
|
||||
content = await layout_change_chan.take()
|
||||
await ctx.write(DebugLinkLayout(lines=content))
|
||||
|
||||
async def dispatch_DebugLinkWatchLayout( # type: ignore
|
||||
async def dispatch_DebugLinkWatchLayout(
|
||||
ctx: wire.Context, msg: DebugLinkWatchLayout
|
||||
) -> Success:
|
||||
global watch_layout_changes
|
||||
layout_change_chan.putters.clear()
|
||||
watch_layout_changes = msg.watch
|
||||
watch_layout_changes = bool(msg.watch)
|
||||
log.debug(__name__, "Watch layout changes: {}".format(watch_layout_changes))
|
||||
return Success()
|
||||
|
||||
|
@ -2,12 +2,11 @@ import storage.recovery
|
||||
from trezor import strings, ui, wire
|
||||
from trezor.crypto.slip39 import MAX_SHARE_COUNT
|
||||
from trezor.messages import ButtonRequestType
|
||||
from trezor.messages.ButtonAck import ButtonAck
|
||||
from trezor.messages.ButtonRequest import ButtonRequest
|
||||
from trezor.ui.scroll import Paginated
|
||||
from trezor.ui.text import Text
|
||||
from trezor.ui.word_select import WordSelector
|
||||
|
||||
from apps.common import button_request
|
||||
from apps.common.confirm import confirm, info_confirm, require_confirm
|
||||
from apps.common.layout import show_success, show_warning
|
||||
from apps.management import backup_types
|
||||
@ -34,7 +33,7 @@ async def confirm_abort(ctx: wire.GenericContext, dry_run: bool = False) -> bool
|
||||
|
||||
|
||||
async def request_word_count(ctx: wire.GenericContext, dry_run: bool) -> int:
|
||||
await ctx.call(ButtonRequest(code=ButtonRequestType.MnemonicWordCount), ButtonAck)
|
||||
await button_request(ctx, code=ButtonRequestType.MnemonicWordCount)
|
||||
|
||||
if dry_run:
|
||||
text = Text("Seed check", ui.ICON_RECOVERY)
|
||||
@ -52,7 +51,7 @@ async def request_word_count(ctx: wire.GenericContext, dry_run: bool) -> int:
|
||||
async def request_mnemonic(
|
||||
ctx: wire.GenericContext, word_count: int, backup_type: Optional[EnumTypeBackupType]
|
||||
) -> Optional[str]:
|
||||
await ctx.call(ButtonRequest(code=ButtonRequestType.MnemonicInput), ButtonAck)
|
||||
await button_request(ctx, code=ButtonRequestType.MnemonicInput)
|
||||
|
||||
words = [] # type: List[str]
|
||||
for i in range(word_count):
|
||||
|
@ -1,9 +1,9 @@
|
||||
from trezor import strings, ui, utils
|
||||
from trezor.messages import ButtonRequestType
|
||||
from trezor.messages.ButtonAck import ButtonAck
|
||||
from trezor.messages.ButtonRequest import ButtonRequest
|
||||
from trezor.ui.text import Text
|
||||
|
||||
from apps.common import button_request
|
||||
|
||||
|
||||
async def naive_pagination(
|
||||
ctx, lines, title, icon=ui.ICON_RESET, icon_color=ui.ORANGE, per_page=5
|
||||
@ -25,7 +25,7 @@ async def naive_pagination(
|
||||
paginated = PaginatedWithButtons(pages, one_by_one=True)
|
||||
|
||||
while True:
|
||||
await ctx.call(ButtonRequest(code=ButtonRequestType.SignTx), ButtonAck)
|
||||
await button_request(ctx, code=ButtonRequestType.SignTx)
|
||||
result = await ctx.wait(paginated)
|
||||
if result is CONFIRMED:
|
||||
return True
|
||||
|
Loading…
Reference in New Issue
Block a user