1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-29 10:58:21 +00:00

confirm: allow to resolve the dialogs from outside

This commit is contained in:
Jan Pochyla 2016-11-15 13:48:31 +01:00
parent 5d7c2ac4e2
commit 39b3ecb224

View File

@ -1,6 +1,10 @@
from trezor import wire, ui from trezor import wire, ui, loop
from trezor.utils import unimport from trezor.utils import unimport
# used to confirm/cancel the dialogs from outside of this module (i.e.
# through debug link)
future = loop.Future()
@unimport @unimport
async def confirm(session_id, content=None, code=None, *args, **kwargs): async def confirm(session_id, content=None, code=None, *args, **kwargs):
@ -16,7 +20,7 @@ async def confirm(session_id, content=None, code=None, *args, **kwargs):
if code is None: if code is None:
code = Other code = Other
await wire.reply_message(session_id, ButtonRequest(code=code), ButtonAck) await wire.reply_message(session_id, ButtonRequest(code=code), ButtonAck)
return await dialog == CONFIRMED return await loop.Wait((future, dialog)) == CONFIRMED
@unimport @unimport
@ -36,7 +40,7 @@ async def hold_to_confirm(session_id, content=None, code=None, *args, **kwargs):
if code is None: if code is None:
code = Other code = Other
await wire.reply_message(session_id, ButtonRequest(code=code), ButtonAck) await wire.reply_message(session_id, ButtonRequest(code=code), ButtonAck)
return await dialog == CONFIRMED return await loop.Wait((future, dialog)) == CONFIRMED
@unimport @unimport