mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-18 04:18:10 +00:00
fix(core/ui): don't send ButtonRequest when displaying GetAddress QR code
[no changelog]
This commit is contained in:
parent
6e0c2578f8
commit
c100358ce2
@ -384,25 +384,30 @@ async def show_address(
|
||||
multisig_index: int | None = None,
|
||||
xpubs: Sequence[str] = (),
|
||||
) -> None:
|
||||
send_button_request = True
|
||||
while True:
|
||||
title = (
|
||||
"RECEIVE ADDRESS\n(MULTISIG)"
|
||||
if multisig_index is not None
|
||||
else "RECEIVE ADDRESS"
|
||||
)
|
||||
result = await interact(
|
||||
ctx,
|
||||
RustLayout(
|
||||
layout = RustLayout(
|
||||
trezorui2.confirm_address(
|
||||
title=title,
|
||||
data=address,
|
||||
description=network or "",
|
||||
extra=None,
|
||||
)
|
||||
),
|
||||
)
|
||||
if send_button_request:
|
||||
send_button_request = False
|
||||
await button_request(
|
||||
ctx,
|
||||
"show_address",
|
||||
ButtonRequestType.Address,
|
||||
pages=layout.page_count(),
|
||||
)
|
||||
result = await ctx.wait(layout)
|
||||
|
||||
# User pressed right button.
|
||||
if result is CONFIRMED:
|
||||
@ -416,8 +421,7 @@ async def show_address(
|
||||
result += "(YOURS)" if i == multisig_index else "(COSIGNER)"
|
||||
return result
|
||||
|
||||
result = await interact(
|
||||
ctx,
|
||||
result = await ctx.wait(
|
||||
RustLayout(
|
||||
trezorui2.show_address_details(
|
||||
address=address if address_qr is None else address_qr,
|
||||
@ -426,19 +430,12 @@ async def show_address(
|
||||
path=path,
|
||||
xpubs=[(xpub_title(i), xpub) for i, xpub in enumerate(xpubs)],
|
||||
)
|
||||
),
|
||||
"show_address_details",
|
||||
ButtonRequestType.Address,
|
||||
)
|
||||
)
|
||||
assert result is CANCELLED
|
||||
|
||||
else:
|
||||
result = await interact(
|
||||
ctx,
|
||||
RustLayout(trezorui2.show_mismatch()),
|
||||
"warning_address_mismatch",
|
||||
ButtonRequestType.Warning,
|
||||
)
|
||||
result = await ctx.wait(RustLayout(trezorui2.show_mismatch()))
|
||||
assert result in (CONFIRMED, CANCELLED)
|
||||
# Right button aborts action, left goes back to showing address.
|
||||
if result is CONFIRMED:
|
||||
|
@ -368,14 +368,14 @@ class DebugLink:
|
||||
x, y = click
|
||||
return self.input(x=x, y=y, wait=wait)
|
||||
|
||||
def press_yes(self) -> None:
|
||||
self.input(button=messages.DebugButton.YES)
|
||||
def press_yes(self, wait: bool = False) -> None:
|
||||
self.input(button=messages.DebugButton.YES, wait=wait)
|
||||
|
||||
def press_no(self) -> None:
|
||||
self.input(button=messages.DebugButton.NO)
|
||||
def press_no(self, wait: bool = False) -> None:
|
||||
self.input(button=messages.DebugButton.NO, wait=wait)
|
||||
|
||||
def press_info(self) -> None:
|
||||
self.input(button=messages.DebugButton.INFO)
|
||||
def press_info(self, wait: bool = False) -> None:
|
||||
self.input(button=messages.DebugButton.INFO, wait=wait)
|
||||
|
||||
def swipe_up(self, wait: bool = False) -> None:
|
||||
self.input(swipe=messages.DebugSwipeDirection.UP, wait=wait)
|
||||
|
@ -78,20 +78,16 @@ def test_show_tt(
|
||||
):
|
||||
def input_flow():
|
||||
yield
|
||||
client.debug.click(CORNER_BUTTON)
|
||||
yield
|
||||
client.debug.click(CORNER_BUTTON, wait=True)
|
||||
# synchronize; TODO get rid of this once we have single-global-layout
|
||||
client.debug.synchronize_at("HorizontalPage")
|
||||
|
||||
client.debug.swipe_left(wait=True)
|
||||
client.debug.swipe_right(wait=True)
|
||||
client.debug.swipe_left(wait=True)
|
||||
client.debug.click(CORNER_BUTTON)
|
||||
yield
|
||||
client.debug.press_no()
|
||||
yield
|
||||
client.debug.press_no()
|
||||
yield
|
||||
client.debug.click(CORNER_BUTTON, wait=True)
|
||||
client.debug.press_no(wait=True)
|
||||
client.debug.press_no(wait=True)
|
||||
client.debug.press_yes()
|
||||
|
||||
with client:
|
||||
@ -115,16 +111,13 @@ def test_show_cancel(
|
||||
):
|
||||
def input_flow():
|
||||
yield
|
||||
client.debug.click(CORNER_BUTTON)
|
||||
yield
|
||||
client.debug.click(CORNER_BUTTON, wait=True)
|
||||
# synchronize; TODO get rid of this once we have single-global-layout
|
||||
client.debug.synchronize_at("HorizontalPage")
|
||||
|
||||
client.debug.swipe_left(wait=True)
|
||||
client.debug.click(CORNER_BUTTON)
|
||||
yield
|
||||
client.debug.press_no()
|
||||
yield
|
||||
client.debug.click(CORNER_BUTTON, wait=True)
|
||||
client.debug.press_no(wait=True)
|
||||
client.debug.press_yes()
|
||||
|
||||
with client, pytest.raises(Cancelled):
|
||||
@ -285,7 +278,6 @@ def test_show_multisig_xpubs(
|
||||
assert layout.get_content().replace(" ", "") == address
|
||||
|
||||
client.debug.click(CORNER_BUTTON)
|
||||
yield # show QR code
|
||||
assert "Qr" in client.debug.wait_layout().text
|
||||
|
||||
layout = client.debug.swipe_left(wait=True)
|
||||
@ -302,12 +294,12 @@ def test_show_multisig_xpubs(
|
||||
content = layout.get_content().replace(" ", "")
|
||||
assert xpubs[xpub_num] in content
|
||||
|
||||
client.debug.click(CORNER_BUTTON)
|
||||
yield # show address
|
||||
client.debug.press_no()
|
||||
yield # address mismatch
|
||||
client.debug.press_no()
|
||||
yield # show address
|
||||
client.debug.click(CORNER_BUTTON, wait=True)
|
||||
# show address
|
||||
client.debug.press_no(wait=True)
|
||||
# address mismatch
|
||||
client.debug.press_no(wait=True)
|
||||
# show address
|
||||
client.debug.press_yes()
|
||||
|
||||
with client:
|
||||
|
Loading…
Reference in New Issue
Block a user