2024-03-09 21:05:05 +00:00
|
|
|
from trezorlib import messages, models
|
2023-07-21 09:38:28 +00:00
|
|
|
from trezorlib.debuglink import TrezorClientDebugLink as Client
|
|
|
|
|
2024-05-27 22:19:01 +00:00
|
|
|
from . import buttons
|
2023-08-11 15:57:32 +00:00
|
|
|
from . import translations as TR
|
|
|
|
from .common import BRGeneratorType, get_text_possible_pagination
|
2023-07-21 09:38:28 +00:00
|
|
|
|
|
|
|
B = messages.ButtonRequestType
|
|
|
|
|
|
|
|
|
|
|
|
class PinFlow:
|
|
|
|
def __init__(self, client: Client):
|
|
|
|
self.client = client
|
|
|
|
self.debug = self.client.debug
|
|
|
|
|
|
|
|
def setup_new_pin(
|
|
|
|
self, pin: str, second_different_pin: str | None = None
|
|
|
|
) -> BRGeneratorType:
|
|
|
|
yield # Enter PIN
|
|
|
|
assert "PinKeyboard" in self.debug.wait_layout().all_components()
|
|
|
|
self.debug.input(pin)
|
2024-03-09 21:05:05 +00:00
|
|
|
if self.client.model is models.T2B1:
|
2023-07-21 09:38:28 +00:00
|
|
|
yield # Reenter PIN
|
2023-08-11 15:57:32 +00:00
|
|
|
TR.assert_in(
|
|
|
|
self.debug.wait_layout().text_content(), "pin__reenter_to_confirm"
|
|
|
|
)
|
2023-07-21 09:38:28 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
yield # Enter PIN again
|
|
|
|
assert "PinKeyboard" in self.debug.wait_layout().all_components()
|
|
|
|
if second_different_pin is not None:
|
|
|
|
self.debug.input(second_different_pin)
|
|
|
|
else:
|
|
|
|
self.debug.input(pin)
|
|
|
|
|
|
|
|
|
|
|
|
class BackupFlow:
|
|
|
|
def __init__(self, client: Client):
|
|
|
|
self.client = client
|
|
|
|
self.debug = self.client.debug
|
|
|
|
|
|
|
|
def confirm_new_wallet(self) -> BRGeneratorType:
|
|
|
|
yield
|
2023-08-11 15:57:32 +00:00
|
|
|
TR.assert_in(self.debug.wait_layout().text_content(), "reset__by_continuing")
|
2024-03-09 21:05:05 +00:00
|
|
|
if self.client.model is models.T2B1:
|
2023-07-21 09:38:28 +00:00
|
|
|
self.debug.press_right()
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
|
|
|
|
class RecoveryFlow:
|
|
|
|
def __init__(self, client: Client):
|
|
|
|
self.client = client
|
|
|
|
self.debug = self.client.debug
|
|
|
|
|
2023-08-11 15:57:32 +00:00
|
|
|
def _text_content(self) -> str:
|
2024-05-27 22:19:01 +00:00
|
|
|
layout = self.debug.wait_layout()
|
|
|
|
return layout.title() + " " + layout.text_content()
|
2023-08-11 15:57:32 +00:00
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def confirm_recovery(self) -> BRGeneratorType:
|
|
|
|
yield
|
2023-08-11 15:57:32 +00:00
|
|
|
TR.assert_in(self._text_content(), "reset__by_continuing")
|
2024-03-09 21:05:05 +00:00
|
|
|
if self.client.model is models.T2B1:
|
2023-07-21 09:38:28 +00:00
|
|
|
self.debug.press_right()
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
def confirm_dry_run(self) -> BRGeneratorType:
|
|
|
|
yield
|
2023-08-11 15:57:32 +00:00
|
|
|
TR.assert_in(self._text_content(), "recovery__check_dry_run")
|
2023-07-21 09:38:28 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
def setup_slip39_recovery(self, num_words: int) -> BRGeneratorType:
|
2024-03-09 21:05:05 +00:00
|
|
|
if self.client.model is models.T2B1:
|
2023-07-21 09:38:28 +00:00
|
|
|
yield from self.tr_recovery_homescreen()
|
|
|
|
yield from self.input_number_of_words(num_words)
|
|
|
|
yield from self.enter_any_share()
|
|
|
|
|
2024-04-23 10:26:46 +00:00
|
|
|
def setup_repeated_backup_recovery(self, num_words: int) -> BRGeneratorType:
|
|
|
|
if self.client.model is models.T2B1:
|
|
|
|
yield from self.tr_recovery_homescreen()
|
|
|
|
yield from self.input_number_of_words(num_words)
|
|
|
|
yield from self.enter_your_backup()
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def setup_bip39_recovery(self, num_words: int) -> BRGeneratorType:
|
2024-03-09 21:05:05 +00:00
|
|
|
if self.client.model is models.T2B1:
|
2023-07-21 09:38:28 +00:00
|
|
|
yield from self.tr_recovery_homescreen()
|
|
|
|
yield from self.input_number_of_words(num_words)
|
|
|
|
yield from self.enter_your_backup()
|
|
|
|
|
|
|
|
def tr_recovery_homescreen(self) -> BRGeneratorType:
|
|
|
|
yield
|
2023-08-11 15:57:32 +00:00
|
|
|
TR.assert_in(self._text_content(), "recovery__num_of_words")
|
2023-07-21 09:38:28 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
def enter_your_backup(self) -> BRGeneratorType:
|
|
|
|
yield
|
2024-05-27 22:19:01 +00:00
|
|
|
if self.debug.model is models.T3T1:
|
2024-06-02 10:47:24 +00:00
|
|
|
TR.assert_in(self._text_content(), "recovery__enter_each_word")
|
2024-05-27 22:19:01 +00:00
|
|
|
else:
|
|
|
|
TR.assert_in(self._text_content(), "recovery__enter_backup")
|
2023-08-11 15:57:32 +00:00
|
|
|
is_dry_run = any(
|
|
|
|
title in self.debug.wait_layout().title().lower()
|
|
|
|
for title in TR.translate("recovery__title_dry_run", lower=True)
|
|
|
|
)
|
2024-03-09 21:05:05 +00:00
|
|
|
if self.client.model is models.T2B1 and not is_dry_run:
|
2023-07-21 09:38:28 +00:00
|
|
|
# Normal recovery has extra info (not dry run)
|
|
|
|
self.debug.press_right(wait=True)
|
|
|
|
self.debug.press_right(wait=True)
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
def enter_any_share(self) -> BRGeneratorType:
|
|
|
|
yield
|
2024-05-27 22:19:01 +00:00
|
|
|
TR.assert_in_multiple(
|
|
|
|
self._text_content(),
|
2024-06-02 10:47:24 +00:00
|
|
|
["recovery__enter_any_share", "recovery__enter_each_word"],
|
2024-05-27 22:19:01 +00:00
|
|
|
)
|
2023-08-11 15:57:32 +00:00
|
|
|
is_dry_run = any(
|
|
|
|
title in self.debug.wait_layout().title().lower()
|
|
|
|
for title in TR.translate("recovery__title_dry_run", lower=True)
|
|
|
|
)
|
2024-03-09 21:05:05 +00:00
|
|
|
if self.client.model is models.T2B1 and not is_dry_run:
|
2023-07-21 09:38:28 +00:00
|
|
|
# Normal recovery has extra info (not dry run)
|
|
|
|
self.debug.press_right(wait=True)
|
|
|
|
self.debug.press_right(wait=True)
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
def abort_recovery(self, confirm: bool) -> BRGeneratorType:
|
|
|
|
yield
|
2024-03-09 21:05:05 +00:00
|
|
|
if self.client.model is models.T2B1:
|
2023-08-11 15:57:32 +00:00
|
|
|
TR.assert_in(self._text_content(), "recovery__num_of_words")
|
2024-07-28 16:54:42 +00:00
|
|
|
self.debug.press_no()
|
|
|
|
yield
|
|
|
|
TR.assert_in(self._text_content(), "recovery__wanna_cancel_recovery")
|
|
|
|
self.debug.press_right()
|
|
|
|
if confirm:
|
|
|
|
self.debug.press_yes()
|
|
|
|
else:
|
|
|
|
self.debug.press_no()
|
2024-05-27 22:19:01 +00:00
|
|
|
elif self.client.model is models.T3T1:
|
2024-06-02 10:47:24 +00:00
|
|
|
TR.assert_in(self._text_content(), "recovery__enter_each_word")
|
2024-07-28 16:54:42 +00:00
|
|
|
self.debug.click(buttons.CORNER_BUTTON, wait=True)
|
|
|
|
self.debug.synchronize_at("VerticalMenu")
|
|
|
|
if confirm:
|
|
|
|
self.debug.click(buttons.VERTICAL_MENU[0], wait=True)
|
|
|
|
else:
|
|
|
|
self.debug.click(buttons.CORNER_BUTTON, wait=True)
|
2023-07-21 09:38:28 +00:00
|
|
|
else:
|
2023-08-11 15:57:32 +00:00
|
|
|
TR.assert_in(self._text_content(), "recovery__enter_any_share")
|
2023-07-21 09:38:28 +00:00
|
|
|
self.debug.press_no()
|
2024-07-28 16:54:42 +00:00
|
|
|
yield
|
|
|
|
TR.assert_in(self._text_content(), "recovery__wanna_cancel_recovery")
|
|
|
|
if confirm:
|
|
|
|
self.debug.press_yes()
|
|
|
|
else:
|
|
|
|
self.debug.press_no()
|
2023-07-21 09:38:28 +00:00
|
|
|
|
2024-07-30 14:54:40 +00:00
|
|
|
def abort_recovery_between_shares(self) -> BRGeneratorType:
|
|
|
|
yield
|
|
|
|
if self.client.model is models.T2B1:
|
|
|
|
TR.assert_template(
|
|
|
|
self._text_content(), "recovery__x_of_y_entered_template"
|
|
|
|
)
|
|
|
|
self.debug.press_no()
|
|
|
|
assert (yield).name == "abort_recovery"
|
|
|
|
TR.assert_in(self._text_content(), "recovery__wanna_cancel_recovery")
|
|
|
|
self.debug.press_right()
|
|
|
|
self.debug.press_yes()
|
|
|
|
elif self.client.model is models.T3T1:
|
|
|
|
TR.assert_template(
|
|
|
|
self._text_content(), "recovery__x_of_y_entered_template"
|
|
|
|
)
|
|
|
|
self.debug.click(buttons.CORNER_BUTTON, wait=True)
|
|
|
|
self.debug.synchronize_at("VerticalMenu")
|
|
|
|
self.debug.click(buttons.VERTICAL_MENU[0], wait=True)
|
|
|
|
self.debug.swipe_up(wait=True)
|
|
|
|
assert (yield).name == "abort_recovery"
|
|
|
|
self.debug.synchronize_at("PromptScreen")
|
|
|
|
self.debug.click(buttons.TAP_TO_CONFIRM)
|
|
|
|
else:
|
|
|
|
TR.assert_template(
|
|
|
|
self._text_content(), "recovery__x_of_y_entered_template"
|
|
|
|
)
|
|
|
|
self.debug.press_no()
|
|
|
|
assert (yield).name == "abort_recovery"
|
|
|
|
TR.assert_in(self._text_content(), "recovery__wanna_cancel_recovery")
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_number_of_words(self, num_words: int) -> BRGeneratorType:
|
|
|
|
br = yield
|
|
|
|
assert br.code == B.MnemonicWordCount
|
2024-03-09 21:05:05 +00:00
|
|
|
if self.client.model is models.T2B1:
|
2023-08-11 15:57:32 +00:00
|
|
|
TR.assert_in(self.debug.wait_layout().title(), "word_count__title")
|
2023-07-21 09:38:28 +00:00
|
|
|
else:
|
2023-08-11 15:57:32 +00:00
|
|
|
TR.assert_in(self._text_content(), "recovery__num_of_words")
|
2023-07-21 09:38:28 +00:00
|
|
|
self.debug.input(str(num_words))
|
|
|
|
|
|
|
|
def warning_invalid_recovery_seed(self) -> BRGeneratorType:
|
|
|
|
br = yield
|
|
|
|
assert br.code == B.Warning
|
2024-04-25 09:30:24 +00:00
|
|
|
TR.assert_in(self._text_content(), "recovery__invalid_wallet_backup_entered")
|
2023-07-21 09:38:28 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
def warning_invalid_recovery_share(self) -> BRGeneratorType:
|
|
|
|
br = yield
|
|
|
|
assert br.code == B.Warning
|
2023-08-11 15:57:32 +00:00
|
|
|
TR.assert_in(self._text_content(), "recovery__invalid_share_entered")
|
2023-07-21 09:38:28 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
def warning_group_threshold_reached(self) -> BRGeneratorType:
|
|
|
|
br = yield
|
|
|
|
assert br.code == B.Warning
|
2023-08-11 15:57:32 +00:00
|
|
|
TR.assert_in(self._text_content(), "recovery__group_threshold_reached")
|
2023-07-21 09:38:28 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
def warning_share_already_entered(self) -> BRGeneratorType:
|
|
|
|
br = yield
|
|
|
|
assert br.code == B.Warning
|
2023-08-11 15:57:32 +00:00
|
|
|
TR.assert_in(self._text_content(), "recovery__share_already_entered")
|
2023-07-21 09:38:28 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
def warning_share_from_another_shamir(self) -> BRGeneratorType:
|
|
|
|
br = yield
|
|
|
|
assert br.code == B.Warning
|
2024-05-08 10:43:07 +00:00
|
|
|
TR.assert_in(
|
|
|
|
self._text_content(), "recovery__share_from_another_multi_share_backup"
|
|
|
|
)
|
2023-07-21 09:38:28 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
def success_share_group_entered(self) -> BRGeneratorType:
|
|
|
|
yield
|
2023-08-11 15:57:32 +00:00
|
|
|
TR.assert_in(self._text_content(), "recovery__you_have_entered")
|
2023-07-21 09:38:28 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
def success_wallet_recovered(self) -> BRGeneratorType:
|
|
|
|
br = yield
|
|
|
|
assert br.code == B.Success
|
2023-08-11 15:57:32 +00:00
|
|
|
TR.assert_in(self._text_content(), "recovery__wallet_recovered")
|
2023-07-21 09:38:28 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
def success_bip39_dry_run_valid(self) -> BRGeneratorType:
|
|
|
|
br = yield
|
|
|
|
assert br.code == B.Success
|
2023-08-11 15:57:32 +00:00
|
|
|
text = get_text_possible_pagination(self.debug, br)
|
|
|
|
# TODO: make sure the translations fit on one page
|
2024-03-09 21:05:05 +00:00
|
|
|
if self.client.model not in (models.T2T1, models.T3T1):
|
2023-08-11 15:57:32 +00:00
|
|
|
TR.assert_in(text, "recovery__dry_run_bip39_valid_match")
|
2023-07-21 09:38:28 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
def success_slip39_dryrun_valid(self) -> BRGeneratorType:
|
|
|
|
br = yield
|
|
|
|
assert br.code == B.Success
|
2023-08-11 15:57:32 +00:00
|
|
|
text = get_text_possible_pagination(self.debug, br)
|
|
|
|
# TODO: make sure the translations fit on one page
|
2024-03-09 21:05:05 +00:00
|
|
|
if self.client.model not in (models.T2T1, models.T3T1):
|
2023-08-11 15:57:32 +00:00
|
|
|
TR.assert_in(text, "recovery__dry_run_slip39_valid_match")
|
2023-07-21 09:38:28 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
def warning_slip39_dryrun_mismatch(self) -> BRGeneratorType:
|
|
|
|
br = yield
|
|
|
|
assert br.code == B.Warning
|
2023-08-11 15:57:32 +00:00
|
|
|
text = get_text_possible_pagination(self.debug, br)
|
|
|
|
# TODO: make sure the translations fit on one page on TT
|
2024-03-09 21:05:05 +00:00
|
|
|
if self.client.model not in (models.T2T1, models.T3T1):
|
2023-08-11 15:57:32 +00:00
|
|
|
TR.assert_in(text, "recovery__dry_run_slip39_valid_mismatch")
|
2023-07-21 09:38:28 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
def warning_bip39_dryrun_mismatch(self) -> BRGeneratorType:
|
|
|
|
br = yield
|
|
|
|
assert br.code == B.Warning
|
2023-08-11 15:57:32 +00:00
|
|
|
text = get_text_possible_pagination(self.debug, br)
|
|
|
|
# TODO: make sure the translations fit on one page
|
2024-03-09 21:05:05 +00:00
|
|
|
if self.client.model not in (models.T2T1, models.T3T1):
|
2023-08-11 15:57:32 +00:00
|
|
|
TR.assert_in(text, "recovery__dry_run_bip39_valid_mismatch")
|
2023-07-21 09:38:28 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
def success_more_shares_needed(
|
|
|
|
self, count_needed: int | None = None
|
|
|
|
) -> BRGeneratorType:
|
2023-08-11 15:57:32 +00:00
|
|
|
br = yield
|
|
|
|
text = get_text_possible_pagination(self.debug, br)
|
2023-07-21 09:38:28 +00:00
|
|
|
if count_needed is not None:
|
2023-08-11 15:57:32 +00:00
|
|
|
assert str(count_needed) in text
|
2023-07-21 09:38:28 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
def input_mnemonic(self, mnemonic: list[str]) -> BRGeneratorType:
|
|
|
|
br = yield
|
|
|
|
assert br.code == B.MnemonicInput
|
|
|
|
assert "MnemonicKeyboard" in self.debug.wait_layout().all_components()
|
2023-08-11 15:57:32 +00:00
|
|
|
for _, word in enumerate(mnemonic):
|
2023-07-21 09:38:28 +00:00
|
|
|
self.debug.input(word)
|
|
|
|
|
|
|
|
def input_all_slip39_shares(
|
|
|
|
self,
|
|
|
|
shares: list[str],
|
|
|
|
has_groups: bool = False,
|
|
|
|
click_info: bool = False,
|
|
|
|
) -> BRGeneratorType:
|
|
|
|
for index, share in enumerate(shares):
|
|
|
|
mnemonic = share.split(" ")
|
|
|
|
yield from self.input_mnemonic(mnemonic)
|
|
|
|
|
|
|
|
if index < len(shares) - 1:
|
|
|
|
if has_groups:
|
|
|
|
yield from self.success_share_group_entered()
|
2024-05-27 22:19:01 +00:00
|
|
|
if click_info:
|
|
|
|
if self.client.model is models.T2T1:
|
|
|
|
yield from self.tt_click_info()
|
|
|
|
elif self.client.model is models.T3T1:
|
|
|
|
self.mercury_click_info()
|
2023-07-21 09:38:28 +00:00
|
|
|
yield from self.success_more_shares_needed()
|
|
|
|
|
|
|
|
def tt_click_info(
|
|
|
|
self,
|
|
|
|
) -> BRGeneratorType:
|
|
|
|
# Moving through the INFO button
|
|
|
|
self.debug.press_info()
|
|
|
|
yield
|
|
|
|
self.debug.swipe_up()
|
|
|
|
self.debug.press_yes()
|
2023-08-02 10:48:06 +00:00
|
|
|
|
2024-05-27 22:19:01 +00:00
|
|
|
def mercury_click_info(self):
|
|
|
|
self.debug.click(buttons.CORNER_BUTTON, wait=True)
|
|
|
|
self.debug.synchronize_at("VerticalMenu")
|
|
|
|
self.debug.click(buttons.VERTICAL_MENU[0], wait=True)
|
|
|
|
self.debug.click(buttons.CORNER_BUTTON, wait=True)
|
|
|
|
self.debug.click(buttons.CORNER_BUTTON, wait=True)
|
|
|
|
|
2023-08-02 10:48:06 +00:00
|
|
|
|
|
|
|
class EthereumFlow:
|
|
|
|
GO_BACK = (16, 220)
|
|
|
|
|
|
|
|
def __init__(self, client: Client):
|
|
|
|
self.client = client
|
|
|
|
self.debug = self.client.debug
|
|
|
|
|
|
|
|
def confirm_data(self, info: bool = False, cancel: bool = False) -> BRGeneratorType:
|
|
|
|
yield
|
2023-08-11 15:57:32 +00:00
|
|
|
TR.assert_equals(
|
|
|
|
self.debug.wait_layout().title(), "ethereum__title_confirm_data"
|
|
|
|
)
|
2023-08-02 10:48:06 +00:00
|
|
|
if info:
|
|
|
|
self.debug.press_info()
|
|
|
|
elif cancel:
|
|
|
|
self.debug.press_no()
|
|
|
|
else:
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
def paginate_data(self) -> BRGeneratorType:
|
|
|
|
br = yield
|
2023-08-11 15:57:32 +00:00
|
|
|
TR.assert_equals(
|
|
|
|
self.debug.wait_layout().title(), "ethereum__title_confirm_data"
|
|
|
|
)
|
2023-08-02 10:48:06 +00:00
|
|
|
assert br.pages is not None
|
|
|
|
for i in range(br.pages):
|
|
|
|
self.debug.wait_layout()
|
|
|
|
if i < br.pages - 1:
|
|
|
|
self.debug.swipe_up()
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
def paginate_data_go_back(self) -> BRGeneratorType:
|
|
|
|
br = yield
|
2023-08-11 15:57:32 +00:00
|
|
|
TR.assert_equals(
|
|
|
|
self.debug.wait_layout().title(), "ethereum__title_confirm_data"
|
|
|
|
)
|
2023-08-02 10:48:06 +00:00
|
|
|
assert br.pages is not None
|
|
|
|
assert br.pages > 2
|
2024-03-09 21:05:05 +00:00
|
|
|
if self.client.model in (models.T2T1, models.T3T1):
|
2023-08-02 10:48:06 +00:00
|
|
|
self.debug.swipe_up(wait=True)
|
|
|
|
self.debug.swipe_up(wait=True)
|
|
|
|
self.debug.click(self.GO_BACK)
|
|
|
|
else:
|
|
|
|
self.debug.press_right()
|
|
|
|
self.debug.press_right()
|
|
|
|
self.debug.press_left()
|
|
|
|
self.debug.press_left()
|
|
|
|
self.debug.press_left()
|
|
|
|
|
2023-12-05 10:50:13 +00:00
|
|
|
def confirm_tx(
|
|
|
|
self,
|
|
|
|
cancel: bool = False,
|
|
|
|
info: bool = False,
|
|
|
|
go_back_from_summary: bool = False,
|
|
|
|
) -> BRGeneratorType:
|
2024-08-14 09:00:06 +00:00
|
|
|
|
2023-08-02 10:48:06 +00:00
|
|
|
yield
|
|
|
|
|
2024-08-14 09:00:06 +00:00
|
|
|
if self.client.model in (models.T2T1,):
|
|
|
|
TR.assert_equals(self.debug.wait_layout().title(), "words__recipient")
|
2023-08-02 10:48:06 +00:00
|
|
|
if cancel:
|
|
|
|
self.debug.press_no()
|
|
|
|
else:
|
|
|
|
self.debug.press_yes()
|
|
|
|
yield
|
2023-08-11 15:57:32 +00:00
|
|
|
TR.assert_equals(
|
|
|
|
self.debug.wait_layout().title(), "words__title_summary"
|
|
|
|
)
|
|
|
|
TR.assert_in(
|
|
|
|
self.debug.wait_layout().text_content(), "send__maximum_fee"
|
|
|
|
)
|
2023-12-05 10:50:13 +00:00
|
|
|
if go_back_from_summary:
|
|
|
|
self.debug.press_no()
|
|
|
|
yield
|
|
|
|
self.debug.press_yes()
|
|
|
|
yield
|
2023-08-02 10:48:06 +00:00
|
|
|
if info:
|
|
|
|
self.debug.press_info(wait=True)
|
2023-08-11 15:57:32 +00:00
|
|
|
TR.assert_in(
|
|
|
|
self.debug.wait_layout().text_content(), "ethereum__gas_limit"
|
|
|
|
)
|
|
|
|
TR.assert_in(
|
|
|
|
self.debug.wait_layout().text_content(), "ethereum__gas_price"
|
|
|
|
)
|
2023-08-02 10:48:06 +00:00
|
|
|
self.debug.press_no(wait=True)
|
|
|
|
self.debug.press_yes()
|
2024-08-14 09:00:06 +00:00
|
|
|
|
|
|
|
yield
|
|
|
|
elif self.client.model in (
|
|
|
|
models.T2B1,
|
|
|
|
models.T3B1,
|
|
|
|
):
|
|
|
|
TR.assert_equals(self.debug.wait_layout().title(), "words__recipient")
|
2023-08-02 10:48:06 +00:00
|
|
|
if cancel:
|
|
|
|
self.debug.press_left()
|
|
|
|
else:
|
|
|
|
self.debug.press_right()
|
2023-11-07 09:00:07 +00:00
|
|
|
yield
|
2023-08-11 15:57:32 +00:00
|
|
|
TR.assert_in(
|
|
|
|
self.debug.wait_layout().text_content(), "send__maximum_fee"
|
|
|
|
)
|
2023-12-05 10:50:13 +00:00
|
|
|
if go_back_from_summary:
|
|
|
|
self.debug.press_left()
|
|
|
|
yield
|
|
|
|
self.debug.press_right()
|
|
|
|
yield
|
2023-08-02 10:48:06 +00:00
|
|
|
if info:
|
|
|
|
self.debug.press_right(wait=True)
|
2023-08-11 15:57:32 +00:00
|
|
|
TR.assert_in(
|
|
|
|
self.debug.wait_layout().text_content(), "ethereum__gas_limit"
|
|
|
|
)
|
2023-08-02 10:48:06 +00:00
|
|
|
self.debug.press_right(wait=True)
|
2023-08-11 15:57:32 +00:00
|
|
|
TR.assert_in(
|
|
|
|
self.debug.wait_layout().text_content(), "ethereum__gas_price"
|
|
|
|
)
|
2023-08-02 10:48:06 +00:00
|
|
|
self.debug.press_left(wait=True)
|
|
|
|
self.debug.press_left(wait=True)
|
|
|
|
self.debug.press_middle()
|
2024-02-21 15:03:48 +00:00
|
|
|
|
2024-08-14 09:00:06 +00:00
|
|
|
yield
|
|
|
|
elif self.client.model in (models.T3T1,):
|
|
|
|
TR.assert_equals(
|
|
|
|
self.debug.wait_layout().title().split("\n")[0], "words__address"
|
|
|
|
)
|
|
|
|
TR.assert_equals(
|
|
|
|
self.debug.wait_layout().title().split("\n")[1], "words__recipient"
|
|
|
|
)
|
|
|
|
if cancel:
|
|
|
|
self.debug.press_no()
|
|
|
|
else:
|
2024-08-20 11:57:04 +00:00
|
|
|
self.debug.swipe_up()
|
2024-08-14 09:00:06 +00:00
|
|
|
yield
|
|
|
|
TR.assert_equals(
|
|
|
|
self.debug.wait_layout().title(), "words__title_summary"
|
|
|
|
)
|
|
|
|
TR.assert_in(
|
|
|
|
self.debug.wait_layout().text_content(), "send__maximum_fee"
|
|
|
|
)
|
|
|
|
if go_back_from_summary:
|
|
|
|
self.debug.press_no()
|
|
|
|
yield
|
|
|
|
self.debug.press_yes()
|
|
|
|
yield
|
|
|
|
if info:
|
|
|
|
self.debug.click(buttons.CORNER_BUTTON, wait=True)
|
|
|
|
self.debug.synchronize_at("VerticalMenu")
|
|
|
|
self.debug.click(buttons.VERTICAL_MENU[0], wait=True)
|
|
|
|
TR.assert_in(
|
|
|
|
self.debug.wait_layout().text_content(), "ethereum__gas_limit"
|
|
|
|
)
|
|
|
|
TR.assert_in(
|
|
|
|
self.debug.wait_layout().text_content(), "ethereum__gas_price"
|
|
|
|
)
|
|
|
|
self.debug.click(buttons.CORNER_BUTTON, wait=True)
|
|
|
|
self.debug.click(buttons.CORNER_BUTTON, wait=True)
|
|
|
|
self.debug.swipe_up()
|
|
|
|
self.debug.wait_layout()
|
|
|
|
self.debug.click(buttons.TAP_TO_CONFIRM)
|
|
|
|
yield
|
|
|
|
else:
|
|
|
|
raise ValueError("Unknown model!")
|
|
|
|
|
2024-02-21 15:03:48 +00:00
|
|
|
def confirm_tx_staking(
|
|
|
|
self,
|
|
|
|
info: bool = False,
|
|
|
|
) -> BRGeneratorType:
|
|
|
|
yield
|
|
|
|
TR.assert_equals_multiple(
|
|
|
|
self.debug.wait_layout().title(),
|
|
|
|
[
|
|
|
|
"ethereum__staking_stake",
|
|
|
|
"ethereum__staking_unstake",
|
|
|
|
"ethereum__staking_claim",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
TR.assert_equals_multiple(
|
|
|
|
self.debug.wait_layout().text_content(),
|
|
|
|
[
|
|
|
|
"ethereum__staking_stake_intro",
|
|
|
|
"ethereum__staking_unstake_intro",
|
|
|
|
"ethereum__staking_claim_intro",
|
|
|
|
],
|
|
|
|
)
|
2024-03-09 21:05:05 +00:00
|
|
|
if self.client.model in (models.T2T1, models.T3T1):
|
2024-02-21 15:03:48 +00:00
|
|
|
# confirm intro
|
|
|
|
if info:
|
2024-05-27 22:19:01 +00:00
|
|
|
self.debug.click(buttons.CORNER_BUTTON, wait=True)
|
2024-02-21 15:03:48 +00:00
|
|
|
TR.assert_equals_multiple(
|
|
|
|
self.debug.wait_layout().title(),
|
|
|
|
[
|
|
|
|
"ethereum__staking_stake_address",
|
|
|
|
"ethereum__staking_claim_address",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
self.debug.press_no(wait=True)
|
|
|
|
self.debug.press_yes()
|
|
|
|
yield
|
|
|
|
|
|
|
|
# confirm summary
|
2024-05-27 22:19:01 +00:00
|
|
|
if info and self.client.model != models.T3T1:
|
2024-02-21 15:03:48 +00:00
|
|
|
self.debug.press_info(wait=True)
|
|
|
|
TR.assert_in(
|
|
|
|
self.debug.wait_layout().text_content(), "ethereum__gas_limit"
|
|
|
|
)
|
|
|
|
TR.assert_in(
|
|
|
|
self.debug.wait_layout().text_content(), "ethereum__gas_price"
|
|
|
|
)
|
|
|
|
self.debug.press_no(wait=True)
|
|
|
|
self.debug.press_yes()
|
|
|
|
yield
|
2024-08-14 09:00:06 +00:00
|
|
|
|
|
|
|
self.debug.press_yes()
|
2024-02-21 15:03:48 +00:00
|
|
|
else:
|
|
|
|
# confirm intro
|
|
|
|
if info:
|
|
|
|
self.debug.press_right(wait=True)
|
|
|
|
TR.assert_equals_multiple(
|
2024-08-08 13:13:43 +00:00
|
|
|
self.debug.wait_layout().title().rstrip(":"),
|
2024-02-21 15:03:48 +00:00
|
|
|
[
|
|
|
|
"ethereum__staking_stake_address",
|
|
|
|
"ethereum__staking_claim_address",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
self.debug.press_left(wait=True)
|
|
|
|
self.debug.press_middle()
|
|
|
|
yield
|
|
|
|
|
|
|
|
# confirm summary
|
|
|
|
if info:
|
|
|
|
self.debug.press_right(wait=True)
|
|
|
|
TR.assert_in(
|
|
|
|
self.debug.wait_layout().text_content(), "ethereum__gas_limit"
|
|
|
|
)
|
|
|
|
self.debug.press_right(wait=True)
|
|
|
|
TR.assert_in(
|
|
|
|
self.debug.wait_layout().text_content(), "ethereum__gas_price"
|
|
|
|
)
|
|
|
|
self.debug.press_left(wait=True)
|
|
|
|
self.debug.press_left(wait=True)
|
|
|
|
self.debug.press_middle()
|
|
|
|
yield
|
2024-08-14 09:00:06 +00:00
|
|
|
|
|
|
|
self.debug.press_yes()
|