1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-18 05:28:40 +00:00

feat(python): pass whole ButtonRequest to button_request UI handler

This commit is contained in:
matejcik 2021-06-17 16:27:58 +02:00 committed by matejcik
parent ea2a9375ac
commit 4f0aca7bb5
4 changed files with 7 additions and 5 deletions

View File

@ -0,0 +1,2 @@
The type of argument to `ui.button_request(x)` is changed from int to ButtonRequest.
The original int value can be accessed as `x.code`

View File

@ -209,7 +209,7 @@ class TrezorClient:
__tracebackhide__ = True # for pytest # pylint: disable=W0612
# do this raw - send ButtonAck first, notify UI later
self._raw_write(messages.ButtonAck())
self.ui.button_request(msg.code)
self.ui.button_request(msg)
return self._raw_read()
@tools.session

View File

@ -230,9 +230,9 @@ class DebugUI:
self.passphrase = ""
self.input_flow = None
def button_request(self, code):
def button_request(self, br):
if self.input_flow is None:
if code == messages.ButtonRequestType.PinEntry:
if br.code == messages.ButtonRequestType.PinEntry:
self.debuglink.input(self.get_pin())
else:
self.debuglink.press_yes()
@ -240,7 +240,7 @@ class DebugUI:
raise AssertionError("input flow ended prematurely")
else:
try:
self.input_flow.send(code)
self.input_flow.send(br)
except StopIteration:
self.input_flow = self.INPUT_FLOW_DONE

View File

@ -68,7 +68,7 @@ class ClickUI:
self.always_prompt = always_prompt
self.passphrase_on_host = passphrase_on_host
def button_request(self, code):
def button_request(self, _br):
if not self.prompt_shown:
echo("Please confirm action on your Trezor device.")
if not self.always_prompt: