1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-14 03:30:02 +00:00
This commit is contained in:
matejcik 2024-08-22 14:11:13 +02:00
parent 2c61321857
commit 354a8ec9ec
2 changed files with 18 additions and 15 deletions

View File

@ -138,19 +138,17 @@ async def _prepare_pairing(ctx: PairingContext) -> None:
async def show_display_data(ctx: PairingContext, expected_types: Container[int] = ()):
from trezorui2 import CANCELLED
read_task = ctx.read(expected_types)
cancel_task = ctx.display_data.get_display_layout()
race = loop.race(read_task, cancel_task)
race = loop.race(read_task, cancel_task.get_result())
result = await race
if read_task in race.finished:
return result
if cancel_task in race.finished:
if result is CANCELLED:
raise ActionCancelled
else:
return Exception("Should not happen") # TODO what to do here?
return result
@check_state_and_log(ChannelState.TP1)
async def _handle_code_entry_is_included(ctx: PairingContext) -> None:

View File

@ -11,6 +11,7 @@ from trezor.wire.protocol_common import Context, Message
if TYPE_CHECKING:
from typing import Container
from trezor import ui
from .channel import Channel
from .cpace import Cpace
@ -28,7 +29,9 @@ class PairingDisplayData:
self.code_qr_code: bytes | None = None
self.code_nfc_unidirectional: bytes | None = None
def get_display_layout(self):
def get_display_layout(self) -> ui.Layout:
from trezor import ui
# TODO have different layouts when there is only QR code or only Code Entry
qr_str = ""
code_str = ""
@ -37,14 +40,16 @@ class PairingDisplayData:
if self.code_code_entry is not None:
code_str = self._get_code_code_entry_str()
return trezorui2.show_address_details( # noqa
qr_title="Scan QR code to pair",
address=qr_str,
case_sensitive=True,
details_title="",
account="Code to rewrite:\n" + code_str,
path="",
xpubs=[],
return ui.Layout(
trezorui2.show_address_details( # noqa
qr_title="Scan QR code to pair",
address=qr_str,
case_sensitive=True,
details_title="",
account="Code to rewrite:\n" + code_str,
path="",
xpubs=[],
)
)
def _get_code_code_entry_str(self) -> str: