Skip to content

Commit b685298

Browse files
overcatibz
authored andcommitted
refactor(core): improved Stellar transaction signing interface for a more streamlined user experience.
1 parent 76a9b91 commit b685298

File tree

18 files changed

+9290
-169
lines changed

18 files changed

+9290
-169
lines changed

common/tests/fixtures/stellar/sign_tx.json

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,79 @@
10021002
"public_key": "2f22b9c62f08b774f3ebe6dd6e7db93c3ec2cbde0279561a3d9c5225b8c32292",
10031003
"signature": "6OL75JoHdYg5eomt6fXmLffqYwix+jwd1RzOq7M2I+/7obUgdtZPYBm5Cjnhov5wAlWPHE2seQ/BuEZMrZUJCA=="
10041004
}
1005+
},
1006+
{
1007+
"name": "all_sending_like_operations",
1008+
"parameters": {
1009+
"xdr": "AAAAAgAAAAAvIrnGLwi3dPPr5t1ufbk8PsLL3gJ5Vho9nFIluMMikgAAAfQAAAAAAAAD6AAAAAEAAAAAG4J3zQAAAABd5CqEAAAAAAAAAAUAAAAAAAAAAAAAAABdVWQkZrGFuEMVLp4hkVHbxYkgJ+xAEBpRe+1coDDC4AAAAAAF9eEAAAAAAAAAAAEAAAAAXVVkJGaxhbhDFS6eIZFR28WJICfsQBAaUXvtXKAwwuAAAAABWAAAAAAAAAAphJYCwg5YNl8SPBLYehykVQ0QzSGwrg4Y1E4+Vv1qFQAAAAAdzxaYAAAAAAAAAA0AAAABWAAAAAAAAABwi6oxX35cFm2EtGS/s4/WJXj+OtJyJ+dsy7ehecRRIQAAAAAdzxaYAAAAAF1VZCRmsYW4QxUuniGRUdvFiSAn7EAQGlF77VygMMLgAAAAAkFCQ0RFRkdISUpLTAAAAAAphJYCwg5YNl8SPBLYehykVQ0QzSGwrg4Y1E4+Vv1qFQAAAAAAAeJAAAAAAAAAAAAAAAACAAAAAVgAAAAAAAAAcIuqMV9+XBZthLRkv7OP1iV4/jrScifnbMu3oXnEUSEAAAAAHc8WmAAAAABdVWQkZrGFuEMVLp4hkVHbxYkgJ+xAEBpRe+1coDDC4AAAAAJBQkNERUZHSElKS0wAAAAAKYSWAsIOWDZfEjwS2HocpFUNEM0hsK4OGNROPlb9ahUAAAAAAAHiQAAAAAAAAAAAAAAACAAAAABdVWQkZrGFuEMVLp4hkVHbxYkgJ+xAEBpRe+1coDDC4AAAAAAAAAAA",
1010+
"address_n": "m/44'/148'/0'",
1011+
"network_passphrase": "Test SDF Network ; September 2015",
1012+
"tx": {
1013+
"source_account": "GAXSFOOGF4ELO5HT5PTN23T5XE6D5QWL3YBHSVQ2HWOFEJNYYMRJENBV",
1014+
"fee": 500,
1015+
"sequence_number": 1000,
1016+
"timebounds_start": 461535181,
1017+
"timebounds_end": 1575234180,
1018+
"memo_type": "NONE"
1019+
},
1020+
"operations": [
1021+
{
1022+
"_message_type": "StellarCreateAccountOp",
1023+
"new_account": "GBOVKZBEM2YYLOCDCUXJ4IMRKHN4LCJAE7WEAEA2KF562XFAGDBOB64V",
1024+
"starting_balance": 100000000
1025+
},
1026+
{
1027+
"_message_type": "StellarPaymentOp",
1028+
"destination_account": "GBOVKZBEM2YYLOCDCUXJ4IMRKHN4LCJAE7WEAEA2KF562XFAGDBOB64V",
1029+
"asset": {
1030+
"type": "ALPHANUM4",
1031+
"code": "X",
1032+
"issuer": "GAUYJFQCYIHFQNS7CI6BFWD2DSSFKDIQZUQ3BLQODDKE4PSW7VVBKENC"
1033+
},
1034+
"amount": 500111000
1035+
},
1036+
{
1037+
"_message_type": "StellarPathPaymentStrictSendOp",
1038+
"send_asset": {
1039+
"type": "ALPHANUM4",
1040+
"code": "X",
1041+
"issuer": "GBYIXKRRL57FYFTNQS2GJP5TR7LCK6H6HLJHEJ7HNTF3PILZYRISDLNQ"
1042+
},
1043+
"send_amount": 500111000,
1044+
"destination_account": "GBOVKZBEM2YYLOCDCUXJ4IMRKHN4LCJAE7WEAEA2KF562XFAGDBOB64V",
1045+
"destination_asset": {
1046+
"type": "ALPHANUM12",
1047+
"code": "ABCDEFGHIJKL",
1048+
"issuer": "GAUYJFQCYIHFQNS7CI6BFWD2DSSFKDIQZUQ3BLQODDKE4PSW7VVBKENC"
1049+
},
1050+
"destination_min": 123456
1051+
},
1052+
{
1053+
"_message_type": "StellarPathPaymentStrictReceiveOp",
1054+
"send_asset": {
1055+
"type": "ALPHANUM4",
1056+
"code": "X",
1057+
"issuer": "GBYIXKRRL57FYFTNQS2GJP5TR7LCK6H6HLJHEJ7HNTF3PILZYRISDLNQ"
1058+
},
1059+
"send_max": 500111000,
1060+
"destination_account": "GBOVKZBEM2YYLOCDCUXJ4IMRKHN4LCJAE7WEAEA2KF562XFAGDBOB64V",
1061+
"destination_asset": {
1062+
"type": "ALPHANUM12",
1063+
"code": "ABCDEFGHIJKL",
1064+
"issuer": "GAUYJFQCYIHFQNS7CI6BFWD2DSSFKDIQZUQ3BLQODDKE4PSW7VVBKENC"
1065+
},
1066+
"destination_amount": 123456
1067+
},
1068+
{
1069+
"_message_type": "StellarAccountMergeOp",
1070+
"destination_account": "GBOVKZBEM2YYLOCDCUXJ4IMRKHN4LCJAE7WEAEA2KF562XFAGDBOB64V"
1071+
}
1072+
]
1073+
},
1074+
"result": {
1075+
"public_key": "2f22b9c62f08b774f3ebe6dd6e7db93c3ec2cbde0279561a3d9c5225b8c32292",
1076+
"signature": "ooAYonekHwUqyAahFkVoHL811S0z22sJ8Wqe277RqBnTillDRtIk3uqi0KsLZYJyeC8Ln7J0ZaXAtGPwIYoKCg=="
1077+
}
10051078
}
10061079
]
10071080
}

core/.changelog.d/5148.changed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improved Stellar transaction signing interface for a more streamlined user experience.

core/embed/rust/librust_qstr.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,8 +1322,13 @@ static void _librust_qstrs(void) {
13221322
MP_QSTR_stellar__set_sequence_to_template;
13231323
MP_QSTR_stellar__sign_tx_count_template;
13241324
MP_QSTR_stellar__sign_tx_fee_template;
1325+
MP_QSTR_stellar__sign_with;
13251326
MP_QSTR_stellar__source_account;
13261327
MP_QSTR_stellar__testnet_network;
1328+
MP_QSTR_stellar__timebounds;
1329+
MP_QSTR_stellar__token_info;
1330+
MP_QSTR_stellar__transaction_source;
1331+
MP_QSTR_stellar__transaction_source_diff_warning;
13271332
MP_QSTR_stellar__trusted_account;
13281333
MP_QSTR_stellar__update;
13291334
MP_QSTR_stellar__valid_from;

core/embed/rust/src/translations/generated/translated_string.rs

Lines changed: 32 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/mocks/trezortranslate_keys.pyi

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ class TR:
854854
stellar__delete_passive_offer: str = "Delete Passive Offer"
855855
stellar__delete_trust: str = "Delete trust"
856856
stellar__destination: str = "Destination"
857-
stellar__exchanges_require_memo: str = "Important: Many exchanges require a memo when depositing"
857+
stellar__exchanges_require_memo: str = "Memo is not set.\nTypically needed when sending to exchanges."
858858
stellar__final_confirm: str = "Final confirm"
859859
stellar__hash: str = "Hash"
860860
stellar__high: str = "High:"
@@ -888,8 +888,13 @@ class TR:
888888
stellar__set_sequence_to_template: str = "Set sequence to {0}?"
889889
stellar__sign_tx_count_template: str = "Sign this transaction made up of {0}"
890890
stellar__sign_tx_fee_template: str = "and pay {0}\nfor fee?"
891+
stellar__sign_with: str = "Sign with"
891892
stellar__source_account: str = "Source account"
892893
stellar__testnet_network: str = "testnet network"
894+
stellar__timebounds: str = "Timebounds"
895+
stellar__token_info: str = "Token info"
896+
stellar__transaction_source: str = "Transaction source"
897+
stellar__transaction_source_diff_warning: str = "Transaction source does not belong to this Trezor."
893898
stellar__trusted_account: str = "Trusted Account"
894899
stellar__update: str = "Update"
895900
stellar__valid_from: str = "Valid from (UTC)"

core/src/apps/stellar/get_address.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ async def get_address(msg: StellarGetAddress, keychain: Keychain) -> StellarAddr
3131
if msg.show_display:
3232
from . import PATTERN
3333

34-
coin = "XLM"
34+
coin = "Stellar"
3535
await show_address(
3636
address,
3737
subtitle=TR.address__coin_address_template.format(coin),

core/src/apps/stellar/layout.py

Lines changed: 58 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -11,65 +11,18 @@
1111
from trezor.messages import StellarAsset
1212

1313

14-
async def require_confirm_init(
15-
address: str,
16-
network_passphrase: str,
17-
accounts_match: bool,
18-
) -> None:
19-
description = (
20-
TR.stellar__initialize_signing_with + TR.stellar__your_account
21-
if accounts_match
22-
else ""
23-
)
24-
await layouts.confirm_address(
25-
TR.stellar__confirm_stellar,
26-
address,
27-
description=description,
28-
br_name="confirm_init",
14+
async def require_confirm_tx_source(tx_source: str) -> None:
15+
await layouts.show_warning(
16+
br_name="confirm_tx_source",
17+
content=TR.stellar__transaction_source_diff_warning,
18+
br_code=ButtonRequestType.Warning,
2919
)
3020

31-
# get_network_warning
32-
if network_passphrase == consts.NETWORK_PASSPHRASE_PUBLIC:
33-
network = None
34-
elif network_passphrase == consts.NETWORK_PASSPHRASE_TESTNET:
35-
network = TR.stellar__testnet_network
36-
else:
37-
network = TR.stellar__private_network
38-
39-
if network:
40-
await layouts.confirm_metadata(
41-
"confirm_init_network",
42-
TR.stellar__confirm_network,
43-
TR.stellar__on_network_template,
44-
network,
45-
ButtonRequestType.ConfirmOutput,
46-
)
47-
48-
49-
async def require_confirm_timebounds(start: int, end: int) -> None:
50-
await layouts.confirm_properties(
51-
"confirm_timebounds",
52-
TR.stellar__confirm_timebounds,
53-
(
54-
(
55-
TR.stellar__valid_from,
56-
(
57-
strings.format_timestamp(start)
58-
if start > 0
59-
else TR.stellar__no_restriction
60-
),
61-
False,
62-
),
63-
(
64-
TR.stellar__valid_to,
65-
(
66-
strings.format_timestamp(end)
67-
if end > 0
68-
else TR.stellar__no_restriction
69-
),
70-
False,
71-
),
72-
),
21+
await layouts.confirm_address(
22+
title=TR.stellar__transaction_source,
23+
address=tx_source,
24+
br_name="confirm_tx_source",
25+
br_code=ButtonRequestType.ConfirmOutput,
7326
)
7427

7528

@@ -85,38 +38,65 @@ async def require_confirm_memo(memo_type: StellarMemoType, memo_text: str) -> No
8538
elif memo_type == StellarMemoType.RETURN:
8639
description = "Memo (RETURN)"
8740
else:
88-
return await layouts.confirm_action(
89-
"confirm_memo",
90-
TR.stellar__confirm_memo,
91-
TR.stellar__no_memo_set,
92-
TR.stellar__exchanges_require_memo,
41+
return await layouts.show_warning(
42+
br_name="confirm_memo",
43+
content=TR.stellar__exchanges_require_memo,
9344
br_code=ButtonRequestType.ConfirmOutput,
94-
prompt_screen=True,
9545
)
9646

97-
await layouts.confirm_blob(
47+
await layouts.confirm_text(
9848
"confirm_memo",
9949
TR.stellar__confirm_memo,
10050
memo_text,
10151
description,
52+
ButtonRequestType.ConfirmOutput,
10253
)
10354

10455

105-
async def require_confirm_final(fee: int, num_operations: int) -> None:
106-
op_str = strings.format_plural(
107-
"{count} {plural}", num_operations, TR.plurals__transaction_of_x_operations
108-
)
109-
text = (
110-
TR.stellar__sign_tx_count_template.format(op_str)
111-
+ " "
112-
+ TR.stellar__sign_tx_fee_template
113-
)
114-
await layouts.confirm_metadata(
115-
"confirm_final",
116-
TR.stellar__final_confirm,
117-
text,
56+
async def require_confirm_final(
57+
address_n: list[int],
58+
fee: int,
59+
timebonuds: tuple[int, int],
60+
is_sending_from_trezor_account: bool,
61+
) -> None:
62+
from trezor.wire import DataError
63+
64+
from apps.common import paths
65+
66+
from . import PATTERN, SLIP44_ID
67+
68+
timebonuds_start, timebonuds_end = timebonuds
69+
extra_items = [
70+
(
71+
TR.stellar__valid_from,
72+
(
73+
strings.format_timestamp(timebonuds_start)
74+
if timebonuds_start > 0
75+
else TR.stellar__no_restriction
76+
),
77+
),
78+
(
79+
TR.stellar__valid_to,
80+
(
81+
strings.format_timestamp(timebonuds_end)
82+
if timebonuds_end > 0
83+
else TR.stellar__no_restriction
84+
),
85+
),
86+
]
87+
88+
account_name = paths.get_account_name("Stellar", address_n, PATTERN, SLIP44_ID)
89+
account_path = paths.address_n_to_str(address_n)
90+
91+
if account_name is None:
92+
raise DataError("Stellar: Invalid account name")
93+
94+
await layouts.confirm_stellar_tx(
11895
format_amount(fee),
119-
hold=True,
96+
account_name,
97+
account_path,
98+
is_sending_from_trezor_account,
99+
extra_items,
120100
)
121101

122102

0 commit comments

Comments
 (0)