diff --git a/core/src/apps/cardano/layout.py b/core/src/apps/cardano/layout.py index b95fb8a8b..ecfcc196d 100644 --- a/core/src/apps/cardano/layout.py +++ b/core/src/apps/cardano/layout.py @@ -16,6 +16,7 @@ from trezor.ui.layouts import ( confirm_path_warning, confirm_properties, confirm_text, + should_show_more, show_address, ) @@ -177,25 +178,25 @@ async def show_script_hash( ) -async def show_multisig_tx(ctx: wire.Context) -> None: - await confirm_metadata( +async def show_tx_init(ctx: wire.Context, title: str) -> bool: + should_show_details = await should_show_more( ctx, - "confirm_signing_mode", - title="Confirm transaction", - content="Confirming a multisig transaction.", - larger_vspace=True, - br_code=ButtonRequestType.Other, + "Confirm transaction", + ( + ( + ui.BOLD, + title, + ), + (ui.NORMAL, "Choose level of details:"), + ), + button_text="Show All", + icon=ui.ICON_SEND, + icon_color=ui.GREEN, + confirm="Show Simple", + major_confirm=True, ) - -async def show_plutus_tx(ctx: wire.Context) -> None: - await confirm_metadata( - ctx, - "confirm_signing_mode", - title="Confirm transaction", - content="Confirming a Plutus transaction.", - br_code=ButtonRequestType.Other, - ) + return should_show_details async def confirm_input(ctx: wire.Context, input: messages.CardanoTxInput) -> None: diff --git a/core/src/apps/cardano/sign_tx/multisig_signer.py b/core/src/apps/cardano/sign_tx/multisig_signer.py index abacc8486..74038e711 100644 --- a/core/src/apps/cardano/sign_tx/multisig_signer.py +++ b/core/src/apps/cardano/sign_tx/multisig_signer.py @@ -11,13 +11,7 @@ class MultisigSigner(Signer): The multisig signing mode only allows signing with multisig (and minting) keys. """ - def __init__( - self, - ctx: wire.Context, - msg: messages.CardanoSignTxInit, - keychain: seed.Keychain, - ) -> None: - super().__init__(ctx, msg, keychain) + SIGNING_MODE_TITLE = "Confirming a multisig transaction." def _validate_tx_init(self) -> None: super()._validate_tx_init() @@ -26,10 +20,6 @@ class MultisigSigner(Signer): self._assert_tx_init_cond(self.msg.total_collateral is None) self._assert_tx_init_cond(self.msg.reference_inputs_count == 0) - async def _show_tx_init(self) -> None: - await layout.show_multisig_tx(self.ctx) - await super()._show_tx_init() - async def _confirm_tx(self, tx_hash: bytes) -> None: # super() omitted intentionally is_network_id_verifiable = self._is_network_id_verifiable() diff --git a/core/src/apps/cardano/sign_tx/ordinary_signer.py b/core/src/apps/cardano/sign_tx/ordinary_signer.py index dd0233446..c61a58c77 100644 --- a/core/src/apps/cardano/sign_tx/ordinary_signer.py +++ b/core/src/apps/cardano/sign_tx/ordinary_signer.py @@ -17,13 +17,7 @@ class OrdinarySigner(Signer): controlled by 1852' keys, dealing with staking and minting/burning tokens. """ - def __init__( - self, - ctx: wire.Context, - msg: messages.CardanoSignTxInit, - keychain: seed.Keychain, - ) -> None: - super().__init__(ctx, msg, keychain) + SIGNING_MODE_TITLE = "Confirming a transaction." def _validate_tx_init(self) -> None: super()._validate_tx_init() diff --git a/core/src/apps/cardano/sign_tx/plutus_signer.py b/core/src/apps/cardano/sign_tx/plutus_signer.py index e858965b7..8f46c1434 100644 --- a/core/src/apps/cardano/sign_tx/plutus_signer.py +++ b/core/src/apps/cardano/sign_tx/plutus_signer.py @@ -13,16 +13,9 @@ class PlutusSigner(Signer): validation rules are less strict, but more tx items/warnings are shown to the user. """ - def __init__( - self, - ctx: wire.Context, - msg: messages.CardanoSignTxInit, - keychain: seed.Keychain, - ) -> None: - super().__init__(ctx, msg, keychain) + SIGNING_MODE_TITLE = "Confirming a Plutus transaction." async def _show_tx_init(self) -> None: - await layout.show_plutus_tx(self.ctx) await super()._show_tx_init() # These items should be present if a Plutus script is to be executed. diff --git a/core/src/apps/cardano/sign_tx/pool_owner_signer.py b/core/src/apps/cardano/sign_tx/pool_owner_signer.py index 6586a2e50..bbfafaeed 100644 --- a/core/src/apps/cardano/sign_tx/pool_owner_signer.py +++ b/core/src/apps/cardano/sign_tx/pool_owner_signer.py @@ -1,7 +1,7 @@ from trezor import messages, wire from trezor.enums import CardanoCertificateType -from .. import layout, seed +from .. import layout from ..helpers.paths import SCHEMA_STAKING_ANY_ACCOUNT from .signer import Signer @@ -19,13 +19,7 @@ class PoolOwnerSigner(Signer): staking key in the list of pool owners. """ - def __init__( - self, - ctx: wire.Context, - msg: messages.CardanoSignTxInit, - keychain: seed.Keychain, - ) -> None: - super().__init__(ctx, msg, keychain) + SIGNING_MODE_TITLE = "Confirming pool registration as owner." def _validate_tx_init(self) -> None: super()._validate_tx_init() diff --git a/core/src/apps/cardano/sign_tx/signer.py b/core/src/apps/cardano/sign_tx/signer.py index dbc348b34..d5762d73e 100644 --- a/core/src/apps/cardano/sign_tx/signer.py +++ b/core/src/apps/cardano/sign_tx/signer.py @@ -43,7 +43,7 @@ from ..helpers.utils import ( ) if TYPE_CHECKING: - from typing import Any + from typing import Any, Awaitable, ClassVar from apps.common.paths import PathSchema CardanoTxResponseType = ( @@ -92,6 +92,8 @@ class Signer: user confirmation and serialization of the tx item. """ + SIGNING_MODE_TITLE: ClassVar[str] + def __init__( self, ctx: wire.Context, @@ -131,6 +133,8 @@ class Signer: tx_dict_items_count, wire.ProcessError("Invalid tx signing request") ) + self.should_show_details = False + async def sign(self) -> None: hash_fn = hashlib.blake2b(outlen=32) self.tx_dict.start(hash_fn) @@ -243,6 +247,10 @@ class Signer: validate_network_info(self.msg.network_id, self.msg.protocol_magic) async def _show_tx_init(self) -> None: + self.should_show_details = await layout.show_tx_init( + self.ctx, self.SIGNING_MODE_TITLE + ) + if not self._is_network_id_verifiable(): await layout.warn_tx_network_unverifiable(self.ctx) diff --git a/core/src/trezor/ui/layouts/tt/__init__.py b/core/src/trezor/ui/layouts/tt/__init__.py index 1b689636a..516b209ad 100644 --- a/core/src/trezor/ui/layouts/tt/__init__.py +++ b/core/src/trezor/ui/layouts/tt/__init__.py @@ -553,6 +553,8 @@ async def should_show_more( br_code: ButtonRequestType = ButtonRequestType.Other, icon: str = ui.ICON_DEFAULT, icon_color: int = ui.ORANGE_ICON, + confirm: ButtonContent = Confirm.DEFAULT_CONFIRM, + major_confirm: bool = False, ) -> bool: """Return True if the user wants to show more (they click a special button) and False when the user wants to continue without showing details. @@ -568,7 +570,12 @@ async def should_show_more( ) for font, text in para: page.content.extend((font, text, "\n")) - ask_dialog = Confirm(AskPaginated(page, button_text)) + + ask_dialog = Confirm( + AskPaginated(page, button_text), + confirm=confirm, + major_confirm=major_confirm, + ) result = await raise_if_cancelled(interact(ctx, ask_dialog, br_type, br_code)) assert result in (SHOW_PAGINATED, CONFIRMED) diff --git a/core/src/trezor/ui/layouts/tt_v2/__init__.py b/core/src/trezor/ui/layouts/tt_v2/__init__.py index 676843058..c6864cc88 100644 --- a/core/src/trezor/ui/layouts/tt_v2/__init__.py +++ b/core/src/trezor/ui/layouts/tt_v2/__init__.py @@ -6,6 +6,8 @@ from trezor.enums import ButtonRequestType import trezorui2 +from ...components.tt.button import ButtonContent +from ...components.tt.confirm import Confirm from ...constants.tt import MONO_ADDR_PER_LINE from ..common import button_request, interact @@ -493,6 +495,8 @@ async def should_show_more( br_code: ButtonRequestType = ButtonRequestType.Other, icon: str = ui.ICON_DEFAULT, icon_color: int = ui.ORANGE_ICON, + confirm: ButtonContent = Confirm.DEFAULT_CONFIRM, + major_confirm: bool = False, ) -> bool: raise NotImplementedError