mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-04-19 08:39:03 +00:00
feat(eckhart): confirm_signverify, confirm_blob, ethereum, solana and nostr support
This commit is contained in:
parent
9de999f13b
commit
385b18fb6a
@ -510,16 +510,19 @@ def confirm_blob(
|
||||
hold: bool = False,
|
||||
br_code: ButtonRequestType = BR_CODE_OTHER,
|
||||
ask_pagination: bool = False,
|
||||
verb_skip_pagination: str | None = None,
|
||||
chunkify: bool = False,
|
||||
prompt_screen: bool = True,
|
||||
_prompt_screen: bool = True,
|
||||
) -> Awaitable[None]:
|
||||
|
||||
if ask_pagination:
|
||||
main_layout = trezorui_api.confirm_value_intro(
|
||||
title=title,
|
||||
value=data,
|
||||
subtitle=description,
|
||||
verb=verb,
|
||||
subtitle=TR.instructions__view_all_data,
|
||||
verb=verb_skip_pagination or verb,
|
||||
verb_cancel=verb_cancel,
|
||||
hold=hold,
|
||||
chunkify=chunkify,
|
||||
)
|
||||
info_layout = trezorui_api.confirm_value(
|
||||
@ -528,13 +531,10 @@ def confirm_blob(
|
||||
subtitle=description,
|
||||
description=None,
|
||||
verb=None,
|
||||
verb_cancel=verb_cancel,
|
||||
info=False,
|
||||
hold=False,
|
||||
hold=hold,
|
||||
chunkify=chunkify,
|
||||
page_counter=True,
|
||||
prompt_screen=False,
|
||||
cancel=True,
|
||||
)
|
||||
|
||||
return with_info(
|
||||
@ -556,7 +556,6 @@ def confirm_blob(
|
||||
info=info,
|
||||
hold=hold,
|
||||
chunkify=chunkify,
|
||||
prompt_screen=prompt_screen,
|
||||
)
|
||||
return raise_if_not_confirmed(
|
||||
layout,
|
||||
@ -641,7 +640,7 @@ def confirm_value(
|
||||
"""General confirmation dialog, used by many other confirm_* functions."""
|
||||
|
||||
if not verb and not hold:
|
||||
raise ValueError("Either verb or hold=True must be set")
|
||||
verb = TR.buttons__confirm
|
||||
|
||||
info_items = info_items or []
|
||||
info_layout = trezorui_api.show_info_with_cancel(
|
||||
@ -781,9 +780,39 @@ if not utils.BITCOIN_ONLY:
|
||||
br_code: ButtonRequestType = ButtonRequestType.SignTx,
|
||||
chunkify: bool = False,
|
||||
) -> None:
|
||||
# FIXME: not implemented
|
||||
# use `flow_confirm_output` or `TT/TR` style?
|
||||
raise NotImplementedError
|
||||
await raise_if_not_confirmed(
|
||||
trezorui_api.flow_confirm_output(
|
||||
title=TR.words__address,
|
||||
subtitle=(
|
||||
TR.words__recipient
|
||||
if not is_contract_interaction
|
||||
else TR.ethereum__interaction_contract
|
||||
),
|
||||
description=None,
|
||||
extra=None,
|
||||
message=(recipient or TR.ethereum__new_contract),
|
||||
amount=None,
|
||||
chunkify=(chunkify if recipient else False),
|
||||
text_mono=True,
|
||||
account_title=TR.send__send_from,
|
||||
account=account,
|
||||
account_path=account_path,
|
||||
address_item=None,
|
||||
extra_item=None,
|
||||
br_code=ButtonRequestType.SignTx,
|
||||
br_name="confirm_output",
|
||||
summary_items=(
|
||||
(TR.words__amount, total_amount),
|
||||
(TR.send__maximum_fee, maximum_fee),
|
||||
),
|
||||
fee_items=fee_info_items,
|
||||
summary_title=TR.words__title_summary,
|
||||
summary_br_name="confirm_total",
|
||||
summary_br_code=ButtonRequestType.SignTx,
|
||||
cancel_text=TR.buttons__cancel,
|
||||
),
|
||||
None,
|
||||
)
|
||||
|
||||
async def confirm_ethereum_staking_tx(
|
||||
title: str,
|
||||
@ -800,9 +829,39 @@ if not utils.BITCOIN_ONLY:
|
||||
br_name: str = "confirm_ethereum_staking_tx",
|
||||
br_code: ButtonRequestType = ButtonRequestType.SignTx,
|
||||
) -> None:
|
||||
# FIXME: not implemented
|
||||
# use `confirm_output` or `TT/TR` style?
|
||||
raise NotImplementedError
|
||||
if verb == TR.ethereum__staking_claim:
|
||||
summary_items = ((TR.send__maximum_fee, maximum_fee),)
|
||||
else:
|
||||
summary_items = (
|
||||
(TR.words__amount, total_amount),
|
||||
(TR.send__maximum_fee, maximum_fee),
|
||||
)
|
||||
await raise_if_not_confirmed(
|
||||
trezorui_api.flow_confirm_output(
|
||||
title=verb,
|
||||
subtitle=None,
|
||||
description=None,
|
||||
extra=None,
|
||||
message=intro_question,
|
||||
amount=None,
|
||||
chunkify=False,
|
||||
text_mono=False,
|
||||
account_title=TR.address_details__account_info,
|
||||
account=account,
|
||||
account_path=account_path,
|
||||
br_code=br_code,
|
||||
br_name=br_name,
|
||||
address_item=(address_title, address),
|
||||
extra_item=None,
|
||||
summary_items=summary_items,
|
||||
fee_items=info_items,
|
||||
summary_title=verb,
|
||||
summary_br_name="confirm_total",
|
||||
summary_br_code=ButtonRequestType.SignTx,
|
||||
cancel_text=TR.buttons__cancel, # cancel staking
|
||||
),
|
||||
br_name=None,
|
||||
)
|
||||
|
||||
def confirm_solana_tx(
|
||||
amount: str,
|
||||
@ -827,6 +886,47 @@ if not utils.BITCOIN_ONLY:
|
||||
br_code=br_code,
|
||||
)
|
||||
|
||||
async def confirm_solana_staking_tx(
|
||||
title: str,
|
||||
description: str,
|
||||
account: str,
|
||||
account_path: str,
|
||||
vote_account: str,
|
||||
stake_item: tuple[str, str] | None,
|
||||
amount_item: tuple[str, str],
|
||||
fee_item: tuple[str, str],
|
||||
fee_details: Iterable[tuple[str, str]],
|
||||
blockhash_item: tuple[str, str],
|
||||
br_name: str = "confirm_solana_staking_tx",
|
||||
br_code: ButtonRequestType = ButtonRequestType.SignTx,
|
||||
) -> None:
|
||||
await raise_if_not_confirmed(
|
||||
trezorui_api.flow_confirm_output(
|
||||
title=title,
|
||||
subtitle=None,
|
||||
description=description,
|
||||
extra=TR.solana__stake_provider if vote_account else None,
|
||||
message=vote_account,
|
||||
amount=None,
|
||||
chunkify=True,
|
||||
text_mono=True,
|
||||
account_title=TR.address_details__account_info,
|
||||
account=account,
|
||||
account_path=account_path,
|
||||
br_code=br_code,
|
||||
br_name=br_name,
|
||||
address_item=stake_item,
|
||||
extra_item=blockhash_item,
|
||||
fee_items=fee_details,
|
||||
summary_title=title,
|
||||
summary_items=(amount_item, fee_item),
|
||||
summary_br_name="confirm_total",
|
||||
summary_br_code=ButtonRequestType.SignTx,
|
||||
cancel_text=TR.buttons__cancel,
|
||||
),
|
||||
br_name=None,
|
||||
)
|
||||
|
||||
def confirm_cardano_tx(
|
||||
amount: str,
|
||||
fee: str,
|
||||
@ -889,7 +989,6 @@ def confirm_replacement(title: str, txid: str) -> Awaitable[None]:
|
||||
verb=TR.buttons__continue,
|
||||
info=False,
|
||||
br_code=ButtonRequestType.SignTx,
|
||||
prompt_screen=False,
|
||||
)
|
||||
|
||||
|
||||
@ -979,6 +1078,9 @@ def confirm_sign_identity(
|
||||
)
|
||||
|
||||
|
||||
LONG_MSG_PAGE_THRESHOLD = 5
|
||||
|
||||
|
||||
async def confirm_signverify(
|
||||
message: str,
|
||||
address: str,
|
||||
@ -987,8 +1089,82 @@ async def confirm_signverify(
|
||||
account: str | None = None,
|
||||
chunkify: bool = False,
|
||||
) -> None:
|
||||
# FIXME: not implemented
|
||||
raise NotImplementedError
|
||||
if verify:
|
||||
address_title = TR.sign_message__verify_address
|
||||
br_name = "verify_message"
|
||||
else:
|
||||
address_title = TR.sign_message__confirm_address
|
||||
br_name = "sign_message"
|
||||
|
||||
address_layout = trezorui_api.confirm_value(
|
||||
title=address_title,
|
||||
value=address,
|
||||
description="",
|
||||
is_data=True,
|
||||
verb=TR.buttons__continue,
|
||||
info=True,
|
||||
chunkify=chunkify,
|
||||
)
|
||||
|
||||
items: list[tuple[str, str]] = []
|
||||
if account is not None:
|
||||
items.append((TR.words__account, account))
|
||||
if path is not None:
|
||||
items.append((TR.address_details__derivation_path, path))
|
||||
items.append(
|
||||
(
|
||||
TR.sign_message__message_size,
|
||||
TR.sign_message__bytes_template.format(len(message)),
|
||||
)
|
||||
)
|
||||
|
||||
info_layout = trezorui_api.show_info_with_cancel(
|
||||
title=TR.words__title_information,
|
||||
items=items,
|
||||
horizontal=True,
|
||||
)
|
||||
|
||||
while True:
|
||||
try:
|
||||
await with_info(address_layout, info_layout, br_name, br_code=BR_CODE_OTHER)
|
||||
except ActionCancelled:
|
||||
result = await interact(
|
||||
trezorui_api.show_mismatch(title=TR.addr_mismatch__mismatch),
|
||||
None,
|
||||
raise_on_cancel=None,
|
||||
)
|
||||
assert result in (CONFIRMED, CANCELLED)
|
||||
# Right button aborts action, left goes back to showing address.
|
||||
if result is CONFIRMED:
|
||||
raise
|
||||
continue
|
||||
else:
|
||||
break
|
||||
|
||||
message_layout = trezorui_api.confirm_value(
|
||||
title=TR.sign_message__confirm_message,
|
||||
description=None,
|
||||
value=message,
|
||||
extra=None,
|
||||
prompt_screen=True,
|
||||
hold=not verify,
|
||||
info=False,
|
||||
verb=TR.buttons__confirm,
|
||||
)
|
||||
|
||||
if message_layout.page_count() <= LONG_MSG_PAGE_THRESHOLD:
|
||||
await interact(message_layout, br_name, BR_CODE_OTHER)
|
||||
else:
|
||||
await confirm_blob(
|
||||
br_name,
|
||||
TR.sign_message__confirm_message,
|
||||
message,
|
||||
verb="",
|
||||
br_code=BR_CODE_OTHER,
|
||||
hold=not verify,
|
||||
ask_pagination=True,
|
||||
verb_skip_pagination=TR.sign_message__confirm_without_review,
|
||||
)
|
||||
|
||||
|
||||
def error_popup(
|
||||
|
Loading…
Reference in New Issue
Block a user