1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-06-26 01:42:34 +00:00

feat(core): add success screen to transactions' signature flow

This commit is contained in:
Roman Zeyde 2025-05-21 09:52:09 +03:00
parent 946fc89449
commit 1bdc48a73f
12 changed files with 3073 additions and 3023 deletions

View File

@ -1 +1 @@
[T3T1] Show confirmation layout after sending response to host.
[T3T1] Show confirmation layout after sending address, public key or signature to host.

View File

@ -17,6 +17,7 @@ if TYPE_CHECKING:
TxAckPrevOutput,
TxRequest,
)
from trezor.wire import EarlyResponse
from apps.common.coininfo import CoinInfo
from apps.common.keychain import Keychain
@ -51,9 +52,12 @@ async def sign_tx(
keychain: Keychain,
coin: CoinInfo,
authorization: CoinJoinAuthorization | None = None,
) -> TxRequest:
) -> EarlyResponse[TxRequest]:
from trezor import TR
from trezor.enums import RequestType
from trezor.messages import TxRequest
from trezor.ui.layouts import show_continue_in_app
from trezor.wire import early_response
from trezor.wire.context import call
from ..common import BITCOIN_NAMES
@ -93,7 +97,9 @@ async def sign_tx(
request_class, req = req
assert TxRequest.is_type_of(req)
if req.request_type == RequestType.TXFINISHED:
return req
return await early_response(
req, show_continue_in_app(TR.send__transaction_signed)
)
res = await call(req, request_class)
elif isinstance(req, helpers.UiConfirm):
res = await req.confirm_dialog()

View File

@ -6,15 +6,18 @@ if TYPE_CHECKING:
from typing import Type
from trezor.messages import CardanoSignTxFinished, CardanoSignTxInit
from trezor.wire import EarlyResponse
@seed.with_keychain
async def sign_tx(
msg: CardanoSignTxInit, keychain: seed.Keychain
) -> CardanoSignTxFinished:
from trezor import log, wire
) -> EarlyResponse[CardanoSignTxFinished]:
from trezor import TR, log, wire
from trezor.enums import CardanoTxSigningMode
from trezor.messages import CardanoSignTxFinished
from trezor.ui.layouts import show_continue_in_app
from trezor.wire import early_response
from .signer import Signer
@ -49,4 +52,5 @@ async def sign_tx(
log.exception(__name__, e)
raise wire.ProcessError("Signing failed")
return CardanoSignTxFinished()
resp = CardanoSignTxFinished()
return await early_response(resp, show_continue_in_app(TR.send__transaction_signed))

View File

@ -4,17 +4,20 @@ from apps.common.keychain import auto_keychain
if TYPE_CHECKING:
from trezor.messages import EosSignedTx, EosSignTx
from trezor.wire import EarlyResponse
from apps.common.keychain import Keychain
@auto_keychain(__name__)
async def sign_tx(msg: EosSignTx, keychain: Keychain) -> EosSignedTx:
async def sign_tx(msg: EosSignTx, keychain: Keychain) -> EarlyResponse[EosSignedTx]:
from trezor import TR
from trezor.crypto.curve import secp256k1
from trezor.crypto.hashlib import sha256
from trezor.messages import EosSignedTx, EosTxActionAck, EosTxActionRequest
from trezor.ui.layouts import show_continue_in_app
from trezor.utils import HashWriter
from trezor.wire import DataError
from trezor.wire import DataError, early_response
from trezor.wire.context import call
from apps.common import paths
@ -55,4 +58,5 @@ async def sign_tx(msg: EosSignTx, keychain: Keychain) -> EosSignedTx:
node.private_key(), digest, True, secp256k1.CANONICAL_SIG_EOS
)
return EosSignedTx(signature=base58_encode("SIG_", "K1", signature))
resp = EosSignedTx(signature=base58_encode("SIG_", "K1", signature))
return await early_response(resp, show_continue_in_app(TR.send__transaction_signed))

View File

@ -19,6 +19,7 @@ if TYPE_CHECKING:
EthereumTokenInfo,
EthereumTxAck,
)
from trezor.wire import EarlyResponse
from apps.common.keychain import Keychain
@ -37,11 +38,13 @@ async def sign_tx(
msg: EthereumSignTx,
keychain: Keychain,
defs: Definitions,
) -> EthereumTxRequest:
) -> EarlyResponse[EthereumTxRequest]:
from trezor import TR
from trezor.crypto.hashlib import sha3_256
from trezor.ui.layouts import show_continue_in_app
from trezor.ui.layouts.progress import progress
from trezor.utils import HashWriter
from trezor.wire import early_response
from apps.common import paths
@ -111,7 +114,9 @@ async def sign_tx(
progress_obj.stop()
return result
return await early_response(
result, show_continue_in_app(TR.send__transaction_signed)
)
async def confirm_tx_data(

View File

@ -2,6 +2,7 @@ from micropython import const
from typing import TYPE_CHECKING
from trezor.crypto import rlp
from trezor.wire import EarlyResponse
from .helpers import bytes_from_address
from .keychain import with_keychain_from_chain_id
@ -34,11 +35,13 @@ async def sign_tx_eip1559(
msg: EthereumSignTxEIP1559,
keychain: Keychain,
defs: Definitions,
) -> EthereumTxRequest:
from trezor import wire
) -> EarlyResponse[EthereumTxRequest]:
from trezor import TR, wire
from trezor.crypto import rlp # local_cache_global
from trezor.crypto.hashlib import sha3_256
from trezor.ui.layouts import show_continue_in_app
from trezor.utils import HashWriter
from trezor.wire import early_response
from apps.common import paths
@ -121,7 +124,9 @@ async def sign_tx_eip1559(
digest = sha.get_digest()
result = _sign_digest(msg, keychain, digest)
return result
return await early_response(
result, show_continue_in_app(TR.send__transaction_signed)
)
def _get_total_length(msg: EthereumSignTxEIP1559, data_total: int) -> int:

View File

@ -5,16 +5,21 @@ from apps.monero.layout import MoneroTransactionProgress
if TYPE_CHECKING:
from trezor.messages import MoneroTransactionFinalAck
from trezor.wire import EarlyResponse
from apps.common.keychain import Keychain
from apps.monero.signing.state import State
@auto_keychain(__name__)
async def sign_tx(received_msg, keychain: Keychain) -> MoneroTransactionFinalAck:
async def sign_tx(
received_msg, keychain: Keychain
) -> EarlyResponse[MoneroTransactionFinalAck]:
import gc
from trezor import log, utils
from trezor import TR, log, utils
from trezor.ui.layouts import show_continue_in_app
from trezor.wire import early_response
from trezor.wire.context import get_context
from apps.monero.signing.state import State
@ -45,7 +50,9 @@ async def sign_tx(received_msg, keychain: Keychain) -> MoneroTransactionFinalAck
received_msg = await ctx.read(accept_msgs)
utils.unimport_end(mods)
return result_msg
return await early_response(
result_msg, show_continue_in_app(TR.send__transaction_signed)
)
async def _sign_tx_dispatch(

View File

@ -4,18 +4,23 @@ from apps.common.keychain import auto_keychain
if TYPE_CHECKING:
from trezor.messages import RippleSignedTx, RippleSignTx
from trezor.wire import EarlyResponse
from apps.common.keychain import Keychain
# NOTE: it is one big function because that way it is the most flash-space-efficient
@auto_keychain(__name__)
async def sign_tx(msg: RippleSignTx, keychain: Keychain) -> RippleSignedTx:
async def sign_tx(
msg: RippleSignTx, keychain: Keychain
) -> EarlyResponse[RippleSignedTx]:
from trezor import TR
from trezor.crypto import der
from trezor.crypto.curve import secp256k1
from trezor.crypto.hashlib import sha512
from trezor.messages import RippleSignedTx
from trezor.wire import ProcessError
from trezor.ui.layouts import show_continue_in_app
from trezor.wire import ProcessError, early_response
from apps.common import paths
@ -58,4 +63,5 @@ async def sign_tx(msg: RippleSignTx, keychain: Keychain) -> RippleSignedTx:
sig_encoded = der.encode_seq((sig[1:33], sig[33:65]))
tx = serialize(msg, source_address, node.public_key(), sig_encoded)
return RippleSignedTx(signature=sig_encoded, serialized_tx=tx)
resp = RippleSignedTx(signature=sig_encoded, serialized_tx=tx)
return await early_response(resp, show_continue_in_app(TR.send__transaction_signed))

View File

@ -1,6 +1,6 @@
from typing import TYPE_CHECKING
from trezor.wire import DataError
from trezor.wire import DataError, EarlyResponse
from apps.common.keychain import with_slip44_keychain
@ -18,12 +18,13 @@ if TYPE_CHECKING:
async def sign_tx(
msg: SolanaSignTx,
keychain: Keychain,
) -> SolanaTxSignature:
) -> EarlyResponse[SolanaTxSignature]:
from trezor import TR
from trezor.crypto.curve import ed25519
from trezor.enums import ButtonRequestType
from trezor.messages import SolanaTxSignature
from trezor.ui.layouts import confirm_metadata, show_warning
from trezor.ui.layouts import confirm_metadata, show_continue_in_app, show_warning
from trezor.wire import early_response
from apps.common import seed
@ -80,7 +81,8 @@ async def sign_tx(
signature = ed25519.sign(node.private_key(), serialized_tx)
return SolanaTxSignature(signature=signature)
resp = SolanaTxSignature(signature=signature)
return await early_response(resp, show_continue_in_app(TR.send__transaction_signed))
def _has_unsupported_instructions(transaction: Transaction) -> bool:

View File

@ -4,19 +4,24 @@ from apps.common.keychain import auto_keychain
if TYPE_CHECKING:
from trezor.messages import StellarSignedTx, StellarSignTx
from trezor.wire import EarlyResponse
from apps.common.keychain import Keychain
@auto_keychain(__name__)
async def sign_tx(msg: StellarSignTx, keychain: Keychain) -> StellarSignedTx:
async def sign_tx(
msg: StellarSignTx, keychain: Keychain
) -> EarlyResponse[StellarSignedTx]:
from ubinascii import hexlify
from trezor import TR
from trezor.crypto.curve import ed25519
from trezor.crypto.hashlib import sha256
from trezor.enums import StellarMemoType
from trezor.messages import StellarSignedTx, StellarTxOpRequest
from trezor.wire import DataError, ProcessError
from trezor.ui.layouts import show_continue_in_app
from trezor.wire import DataError, ProcessError, early_response
from trezor.wire.context import call_any
from apps.common import paths, seed
@ -116,4 +121,5 @@ async def sign_tx(msg: StellarSignTx, keychain: Keychain) -> StellarSignedTx:
signature = ed25519.sign(node.private_key(), digest)
# Add the public key for verification that the right account was used for signing
return StellarSignedTx(public_key=pubkey, signature=signature)
resp = StellarSignedTx(public_key=pubkey, signature=signature)
return await early_response(resp, show_continue_in_app(TR.send__transaction_signed))

View File

@ -26,16 +26,20 @@ if TYPE_CHECKING:
TezosTransactionOp,
)
from trezor.utils import Writer
from trezor.wire import EarlyResponse
from apps.common.keychain import Keychain
@with_slip44_keychain(*PATTERNS, slip44_id=SLIP44_ID, curve=CURVE)
async def sign_tx(msg: TezosSignTx, keychain: Keychain) -> TezosSignedTx:
async def sign_tx(msg: TezosSignTx, keychain: Keychain) -> EarlyResponse[TezosSignedTx]:
from trezor import TR
from trezor.crypto import hashlib
from trezor.crypto.curve import ed25519
from trezor.enums import TezosBallotType
from trezor.messages import TezosSignedTx
from trezor.ui.layouts import show_continue_in_app
from trezor.wire import early_response
from apps.common.paths import validate_path
@ -155,9 +159,10 @@ async def sign_tx(msg: TezosSignTx, keychain: Keychain) -> TezosSignedTx:
sig_prefixed = base58_encode_check(signature, helpers.TEZOS_SIGNATURE_PREFIX)
return TezosSignedTx(
resp = TezosSignedTx(
signature=sig_prefixed, sig_op_contents=sig_op_contents, operation_hash=ophash
)
return await early_response(resp, show_continue_in_app(TR.send__transaction_signed))
def _get_address_by_tag(address_hash: bytes) -> str:

File diff suppressed because it is too large Load Diff