mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-06-25 09:22:33 +00:00
feat(cardano): add tx signing show details prompt
This commit is contained in:
parent
11f8e81083
commit
2f9435570d
@ -16,6 +16,7 @@ from trezor.ui.layouts import (
|
|||||||
confirm_path_warning,
|
confirm_path_warning,
|
||||||
confirm_properties,
|
confirm_properties,
|
||||||
confirm_text,
|
confirm_text,
|
||||||
|
should_show_more,
|
||||||
show_address,
|
show_address,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -177,25 +178,25 @@ async def show_script_hash(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def show_multisig_tx(ctx: wire.Context) -> None:
|
async def show_tx_init(ctx: wire.Context, title: str) -> bool:
|
||||||
await confirm_metadata(
|
should_show_details = await should_show_more(
|
||||||
ctx,
|
ctx,
|
||||||
"confirm_signing_mode",
|
"Confirm transaction",
|
||||||
title="Confirm transaction",
|
(
|
||||||
content="Confirming a multisig transaction.",
|
(
|
||||||
larger_vspace=True,
|
ui.BOLD,
|
||||||
br_code=ButtonRequestType.Other,
|
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,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
return should_show_details
|
||||||
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,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def confirm_input(ctx: wire.Context, input: messages.CardanoTxInput) -> None:
|
async def confirm_input(ctx: wire.Context, input: messages.CardanoTxInput) -> None:
|
||||||
|
@ -11,13 +11,7 @@ class MultisigSigner(Signer):
|
|||||||
The multisig signing mode only allows signing with multisig (and minting) keys.
|
The multisig signing mode only allows signing with multisig (and minting) keys.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
SIGNING_MODE_TITLE = "Confirming a multisig transaction."
|
||||||
self,
|
|
||||||
ctx: wire.Context,
|
|
||||||
msg: messages.CardanoSignTxInit,
|
|
||||||
keychain: seed.Keychain,
|
|
||||||
) -> None:
|
|
||||||
super().__init__(ctx, msg, keychain)
|
|
||||||
|
|
||||||
def _validate_tx_init(self) -> None:
|
def _validate_tx_init(self) -> None:
|
||||||
super()._validate_tx_init()
|
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.total_collateral is None)
|
||||||
self._assert_tx_init_cond(self.msg.reference_inputs_count == 0)
|
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:
|
async def _confirm_tx(self, tx_hash: bytes) -> None:
|
||||||
# super() omitted intentionally
|
# super() omitted intentionally
|
||||||
is_network_id_verifiable = self._is_network_id_verifiable()
|
is_network_id_verifiable = self._is_network_id_verifiable()
|
||||||
|
@ -17,13 +17,7 @@ class OrdinarySigner(Signer):
|
|||||||
controlled by 1852' keys, dealing with staking and minting/burning tokens.
|
controlled by 1852' keys, dealing with staking and minting/burning tokens.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
SIGNING_MODE_TITLE = "Confirming a transaction."
|
||||||
self,
|
|
||||||
ctx: wire.Context,
|
|
||||||
msg: messages.CardanoSignTxInit,
|
|
||||||
keychain: seed.Keychain,
|
|
||||||
) -> None:
|
|
||||||
super().__init__(ctx, msg, keychain)
|
|
||||||
|
|
||||||
def _validate_tx_init(self) -> None:
|
def _validate_tx_init(self) -> None:
|
||||||
super()._validate_tx_init()
|
super()._validate_tx_init()
|
||||||
|
@ -13,16 +13,9 @@ class PlutusSigner(Signer):
|
|||||||
validation rules are less strict, but more tx items/warnings are shown to the user.
|
validation rules are less strict, but more tx items/warnings are shown to the user.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
SIGNING_MODE_TITLE = "Confirming a Plutus transaction."
|
||||||
self,
|
|
||||||
ctx: wire.Context,
|
|
||||||
msg: messages.CardanoSignTxInit,
|
|
||||||
keychain: seed.Keychain,
|
|
||||||
) -> None:
|
|
||||||
super().__init__(ctx, msg, keychain)
|
|
||||||
|
|
||||||
async def _show_tx_init(self) -> None:
|
async def _show_tx_init(self) -> None:
|
||||||
await layout.show_plutus_tx(self.ctx)
|
|
||||||
await super()._show_tx_init()
|
await super()._show_tx_init()
|
||||||
|
|
||||||
# These items should be present if a Plutus script is to be executed.
|
# These items should be present if a Plutus script is to be executed.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from trezor import messages, wire
|
from trezor import messages, wire
|
||||||
from trezor.enums import CardanoCertificateType
|
from trezor.enums import CardanoCertificateType
|
||||||
|
|
||||||
from .. import layout, seed
|
from .. import layout
|
||||||
from ..helpers.paths import SCHEMA_STAKING_ANY_ACCOUNT
|
from ..helpers.paths import SCHEMA_STAKING_ANY_ACCOUNT
|
||||||
from .signer import Signer
|
from .signer import Signer
|
||||||
|
|
||||||
@ -19,13 +19,7 @@ class PoolOwnerSigner(Signer):
|
|||||||
staking key in the list of pool owners.
|
staking key in the list of pool owners.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
SIGNING_MODE_TITLE = "Confirming pool registration as owner."
|
||||||
self,
|
|
||||||
ctx: wire.Context,
|
|
||||||
msg: messages.CardanoSignTxInit,
|
|
||||||
keychain: seed.Keychain,
|
|
||||||
) -> None:
|
|
||||||
super().__init__(ctx, msg, keychain)
|
|
||||||
|
|
||||||
def _validate_tx_init(self) -> None:
|
def _validate_tx_init(self) -> None:
|
||||||
super()._validate_tx_init()
|
super()._validate_tx_init()
|
||||||
|
@ -43,7 +43,7 @@ from ..helpers.utils import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Any
|
from typing import Any, Awaitable, ClassVar
|
||||||
from apps.common.paths import PathSchema
|
from apps.common.paths import PathSchema
|
||||||
|
|
||||||
CardanoTxResponseType = (
|
CardanoTxResponseType = (
|
||||||
@ -92,6 +92,8 @@ class Signer:
|
|||||||
user confirmation and serialization of the tx item.
|
user confirmation and serialization of the tx item.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
SIGNING_MODE_TITLE: ClassVar[str]
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
ctx: wire.Context,
|
ctx: wire.Context,
|
||||||
@ -131,6 +133,8 @@ class Signer:
|
|||||||
tx_dict_items_count, wire.ProcessError("Invalid tx signing request")
|
tx_dict_items_count, wire.ProcessError("Invalid tx signing request")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.should_show_details = False
|
||||||
|
|
||||||
async def sign(self) -> None:
|
async def sign(self) -> None:
|
||||||
hash_fn = hashlib.blake2b(outlen=32)
|
hash_fn = hashlib.blake2b(outlen=32)
|
||||||
self.tx_dict.start(hash_fn)
|
self.tx_dict.start(hash_fn)
|
||||||
@ -243,6 +247,10 @@ class Signer:
|
|||||||
validate_network_info(self.msg.network_id, self.msg.protocol_magic)
|
validate_network_info(self.msg.network_id, self.msg.protocol_magic)
|
||||||
|
|
||||||
async def _show_tx_init(self) -> None:
|
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():
|
if not self._is_network_id_verifiable():
|
||||||
await layout.warn_tx_network_unverifiable(self.ctx)
|
await layout.warn_tx_network_unverifiable(self.ctx)
|
||||||
|
|
||||||
|
@ -553,6 +553,8 @@ async def should_show_more(
|
|||||||
br_code: ButtonRequestType = ButtonRequestType.Other,
|
br_code: ButtonRequestType = ButtonRequestType.Other,
|
||||||
icon: str = ui.ICON_DEFAULT,
|
icon: str = ui.ICON_DEFAULT,
|
||||||
icon_color: int = ui.ORANGE_ICON,
|
icon_color: int = ui.ORANGE_ICON,
|
||||||
|
confirm: ButtonContent = Confirm.DEFAULT_CONFIRM,
|
||||||
|
major_confirm: bool = False,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""Return True if the user wants to show more (they click a special button)
|
"""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.
|
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:
|
for font, text in para:
|
||||||
page.content.extend((font, text, "\n"))
|
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))
|
result = await raise_if_cancelled(interact(ctx, ask_dialog, br_type, br_code))
|
||||||
assert result in (SHOW_PAGINATED, CONFIRMED)
|
assert result in (SHOW_PAGINATED, CONFIRMED)
|
||||||
|
@ -6,6 +6,8 @@ from trezor.enums import ButtonRequestType
|
|||||||
|
|
||||||
import trezorui2
|
import trezorui2
|
||||||
|
|
||||||
|
from ...components.tt.button import ButtonContent
|
||||||
|
from ...components.tt.confirm import Confirm
|
||||||
from ...constants.tt import MONO_ADDR_PER_LINE
|
from ...constants.tt import MONO_ADDR_PER_LINE
|
||||||
from ..common import button_request, interact
|
from ..common import button_request, interact
|
||||||
|
|
||||||
@ -493,6 +495,8 @@ async def should_show_more(
|
|||||||
br_code: ButtonRequestType = ButtonRequestType.Other,
|
br_code: ButtonRequestType = ButtonRequestType.Other,
|
||||||
icon: str = ui.ICON_DEFAULT,
|
icon: str = ui.ICON_DEFAULT,
|
||||||
icon_color: int = ui.ORANGE_ICON,
|
icon_color: int = ui.ORANGE_ICON,
|
||||||
|
confirm: ButtonContent = Confirm.DEFAULT_CONFIRM,
|
||||||
|
major_confirm: bool = False,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user