Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions common/protob/messages-solana.proto
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ message SolanaSignTx {
required bytes serialized_tx = 2; // serialized tx to be signed
optional SolanaTxAdditionalInfo additional_info = 3;
optional common.PaymentRequest payment_req = 4; // SLIP-24 payment request
optional bool chunkify = 5; // display the address in chunks of 4 characters
}

/**
Expand Down
6 changes: 4 additions & 2 deletions common/tests/fixtures/solana/get_address.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@
},
{
"parameters": {
"path": "m/44'/501'/0'"
"path": "m/44'/501'/0'",
"chunkify": true
},
"result": {
"expected_address": "4UR47Kp4FxGJiJZZGSPAzXqRgMmZ27oVfGhHoLmcHakE"
}
},
{
"parameters": {
"path": "m/44'/501'/0'/0'"
"path": "m/44'/501'/0'/0'",
"chunkify": false
},
"result": {
"expected_address": "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"description": "Transfer With Compute Budget Without Heap Confirmation",
"parameters": {
"address": "m/44'/501'/0'/0'",
"chunkify": true,
Comment thread
PrisionMike marked this conversation as resolved.
"construct": {
"version": null,
"header": {
Expand Down Expand Up @@ -272,6 +273,7 @@
"description": "Create Stake Account With Compute Budget",
"parameters": {
"address": "m/44'/501'/0'/0'",
"chunkify": true,
"construct": {
"version": null,
"header": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"description": "Transfer Token - predefined",
"parameters": {
"address": "m/44'/501'/0'/0'",
"chunkify": false,
"construct": {
"version": null,
"header": {
Expand Down Expand Up @@ -61,6 +62,7 @@
"description": "Transfer Token - predefined - with definitions",
"parameters": {
"address": "m/44'/501'/0'/0'",
"chunkify": true,
"construct": {
"version": null,
"header": {
Expand Down Expand Up @@ -119,6 +121,7 @@
"description": "Create Token Account and Transfer Token - predefined",
"parameters": {
"address": "m/44'/501'/0'/0'",
"chunkify": true,
"construct": {
"version": null,
"header": {
Expand Down
2 changes: 2 additions & 0 deletions common/tests/fixtures/solana/sign_tx.stake_program.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"description": "Authorize",
"parameters": {
"address": "m/44'/501'/0'/0'",
"chunkify": true,
"construct": {
"version": null,
"header": {
Expand Down Expand Up @@ -90,6 +91,7 @@
{
"description": "Delegate",
"parameters": {
"chunkify": false,
"address": "m/44'/501'/0'/0'",
"construct": {
"version": null,
Expand Down
1 change: 1 addition & 0 deletions core/.changelog.d/3446.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow chunkified recipient address in Solana transactions.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Allow chunkified recipient address in Solana transactions.
Allow chunkified addresses in Solana transactions.

17 changes: 15 additions & 2 deletions core/src/apps/solana/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ async def confirm_system_transfer(
signer_path: list[int],
blockhash: bytes,
verified_payment_request: PaymentRequest | None,
chunkify: bool,
) -> None:
recipient_account = transfer_instruction.recipient_account
if verified_payment_request:
Expand All @@ -330,6 +331,7 @@ async def confirm_system_transfer(
recipient=base58.encode(recipient_account[0]),
title=TR.words__recipient,
items=[(TR.words__blockhash, base58.encode(blockhash), True)],
chunkify=chunkify,
)
else:
await confirm_properties(
Expand All @@ -350,6 +352,7 @@ async def confirm_token_transfer(
decimals: int,
fee: Fee,
blockhash: bytes,
chunkify: bool,
) -> None:
items: list[StrPropertyType] = []
if token_account != destination_account:
Expand All @@ -362,6 +365,7 @@ async def confirm_token_transfer(
recipient=base58.encode(destination_account),
title=TR.words__recipient,
items=items,
chunkify=chunkify,
)

if is_unknown:
Comment thread
PrisionMike marked this conversation as resolved.
Expand All @@ -373,6 +377,7 @@ async def confirm_token_transfer(
subtitle=TR.solana__unknown_token,
address=base58.encode(token.mint),
verb=TR.buttons__continue,
chunkify=chunkify,
br_name="confirm_token_address",
br_code=ButtonRequestType.ConfirmOutput,
)
Expand Down Expand Up @@ -416,7 +421,7 @@ async def confirm_custom_transaction(
)


async def confirm_stake_withdrawer(withdrawer_account: bytes) -> None:
async def confirm_stake_withdrawer(withdrawer_account: bytes, chunkify: bool) -> None:
await show_danger(
title=TR.words__important,
content=TR.solana__stake_withdrawal_warning,
Expand All @@ -427,10 +432,11 @@ async def confirm_stake_withdrawer(withdrawer_account: bytes) -> None:
title=TR.solana__stake_withdrawal_warning_title,
address=base58.encode(withdrawer_account),
br_name="confirm_stake_warning_address",
chunkify=chunkify,
)


async def confirm_claim_recipient(recipient_account: bytes) -> None:
async def confirm_claim_recipient(recipient_account: bytes, chunkify: bool) -> None:
await show_warning(
content=TR.solana__claim_recipient_warning,
br_name="confirm_claim_warning",
Expand All @@ -439,6 +445,7 @@ async def confirm_claim_recipient(recipient_account: bytes) -> None:
title=TR.address_details__title_receive_address,
address=base58.encode(recipient_account),
br_name="confirm_claim_warning_address",
chunkify=chunkify,
)


Expand All @@ -448,6 +455,7 @@ async def confirm_stake_transaction(
blockhash: bytes,
create: Instruction,
delegate: Instruction,
chunkify: bool,
) -> None:
from trezor.ui.layouts import confirm_solana_staking_tx

Expand Down Expand Up @@ -484,13 +492,15 @@ async def confirm_stake_transaction(
fee_item=(fee_title, fee_str, True),
fee_details=fee_items,
blockhash_item=(TR.words__blockhash, base58.encode(blockhash), True),
chunkify=chunkify,
)


async def confirm_unstake_transaction(
fee: Fee,
signer_path: list[int],
blockhash: bytes,
chunkify: bool,
) -> None:
from trezor.ui.layouts import confirm_solana_staking_tx

Expand All @@ -507,6 +517,7 @@ async def confirm_unstake_transaction(
fee_item=(fee_title, fee_str, True),
fee_details=fee_items,
blockhash_item=(TR.words__blockhash, base58.encode(blockhash), True),
chunkify=chunkify,
)


Expand All @@ -515,6 +526,7 @@ async def confirm_claim_transaction(
signer_path: list[int],
blockhash: bytes,
total_amount: int,
chunkify: bool,
) -> None:
from trezor.ui.layouts import confirm_solana_staking_tx

Expand All @@ -534,6 +546,7 @@ async def confirm_claim_transaction(
fee_item=(fee_title, fee_str, True),
fee_details=fee_items,
blockhash_item=(TR.words__blockhash, base58.encode(blockhash), True),
chunkify=chunkify,
)


Expand Down
21 changes: 17 additions & 4 deletions core/src/apps/solana/predefined_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ async def try_confirm_token_transfer_transaction(
blockhash: bytes,
additional_info: AdditionalTxInfo,
verified_payment_request: PaymentRequest | None,
chunkify: bool,
) -> bool:
from .definitions import unknown_token
from .layout import confirm_payment_request, confirm_token_transfer
Expand Down Expand Up @@ -199,6 +200,7 @@ async def try_confirm_token_transfer_transaction(
transfer_token_instructions[0].decimals,
fee,
blockhash,
chunkify,
)
return True

Expand All @@ -211,6 +213,7 @@ async def try_confirm_predefined_transaction(
blockhash: bytes,
additional_info: AdditionalTxInfo,
verified_payment_request: PaymentRequest | None,
chunkify: bool,
) -> bool:
from .layout import confirm_system_transfer
from .transaction.instructions import SystemProgramTransferInstruction
Expand All @@ -229,7 +232,12 @@ async def try_confirm_predefined_transaction(
if instructions_count == 1:
if SystemProgramTransferInstruction.is_type_of(instructions[0]):
await confirm_system_transfer(
instructions[0], fee, signer_path, blockhash, verified_payment_request
instructions[0],
fee,
signer_path,
blockhash,
verified_payment_request,
chunkify,
)
return True

Expand All @@ -239,6 +247,7 @@ async def try_confirm_predefined_transaction(
signer_path,
signer_public_key,
blockhash,
chunkify,
):
return True

Expand All @@ -249,6 +258,7 @@ async def try_confirm_predefined_transaction(
blockhash,
additional_info,
verified_payment_request,
chunkify,
)


Expand All @@ -258,6 +268,7 @@ async def try_confirm_staking_transaction(
signer_path: list[int],
signer_public_key: bytes,
blockhash: bytes,
chunkify: bool,
) -> bool:
from .transaction.instructions import (
StakeProgramDeactivateInstruction,
Expand Down Expand Up @@ -292,7 +303,7 @@ def _match_instructions(*expected_types: Type[Instruction]) -> bool:
if signer_public_key != create.base:
return False
if signer_public_key != init.withdrawer:
await confirm_stake_withdrawer(init.withdrawer)
await confirm_stake_withdrawer(init.withdrawer, chunkify)
if signer_public_key != init.staker:
return False
if signer_public_key != delegate.stake_authority[0]:
Expand All @@ -318,6 +329,7 @@ def _match_instructions(*expected_types: Type[Instruction]) -> bool:
blockhash=blockhash,
create=create,
delegate=delegate,
chunkify=chunkify,
)
return True

Expand All @@ -329,7 +341,7 @@ def _match_instructions(*expected_types: Type[Instruction]) -> bool:
return False

await confirm_unstake_transaction(
fee=fee, signer_path=signer_path, blockhash=blockhash
fee=fee, signer_path=signer_path, blockhash=blockhash, chunkify=chunkify
)
return True

Expand All @@ -343,14 +355,15 @@ def _match_instructions(*expected_types: Type[Instruction]) -> bool:
if is_address_reference(withdraw.recipient_account):
return False
if signer_public_key != withdraw.recipient_account[0]:
await confirm_claim_recipient(withdraw.recipient_account[0])
await confirm_claim_recipient(withdraw.recipient_account[0], chunkify)
total_amount += withdraw.lamports

await confirm_claim_transaction(
fee=fee,
signer_path=signer_path,
blockhash=blockhash,
total_amount=total_amount,
chunkify=chunkify,
)

return True
Expand Down
1 change: 1 addition & 0 deletions core/src/apps/solana/sign_tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ async def sign_tx(
transaction.blockhash,
additional_tx_info,
msg.payment_req,
bool(msg.chunkify),
):
await confirm_instructions(
address_n, signer_public_key, transaction, additional_tx_info
Expand Down
2 changes: 2 additions & 0 deletions core/src/trezor/messages.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions core/src/trezor/ui/layouts/bolt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1481,6 +1481,7 @@ def confirm_solana_recipient(
items: Iterable[StrPropertyType] = (),
br_name: str = "confirm_solana_recipient",
br_code: ButtonRequestType = ButtonRequestType.ConfirmOutput,
chunkify: bool = False,
) -> Awaitable[None]:
return confirm_value(
title=title,
Expand All @@ -1490,6 +1491,7 @@ def confirm_solana_recipient(
br_code=br_code,
verb=TR.buttons__continue,
info_items=items,
chunkify=chunkify,
)

def confirm_solana_tx(
Expand Down Expand Up @@ -1528,6 +1530,7 @@ async def confirm_solana_staking_tx(
fee_item: StrPropertyType,
fee_details: Iterable[StrPropertyType],
blockhash_item: StrPropertyType,
chunkify: bool,
br_name: str = "confirm_solana_staking_tx",
br_code: ButtonRequestType = ButtonRequestType.SignTx,
) -> None:
Expand All @@ -1543,6 +1546,7 @@ async def confirm_solana_staking_tx(
value=vote_account,
verb=TR.buttons__continue,
info=True,
chunkify=chunkify,
)

items: list[StrPropertyType] = [
Expand Down
Loading