From 8b485de173ec80c86f2855531ff18d7d827a7428 Mon Sep 17 00:00:00 2001 From: RostarMarek Date: Wed, 20 Mar 2024 18:52:45 +0100 Subject: [PATCH] feat(solana): Hidden flag functionality for instructions --- .../sign_tx.compute_budget_program.json | 283 ++++++++++++++++++ .../src/apps/solana/predefined_transaction.py | 9 +- core/src/apps/solana/sign_tx.py | 6 +- core/src/apps/solana/transaction/__init__.py | 7 + .../apps/solana/transaction/instruction.py | 3 + .../apps/solana/transaction/instructions.py | 81 +++++ .../solana/transaction/instructions.py.mako | 4 +- .../src/apps/solana/transaction/programs.json | 2 + ...test_apps.solana.predefined_transaction.py | 1 + tests/ui_tests/fixtures.json | 6 +- 10 files changed, 393 insertions(+), 9 deletions(-) diff --git a/common/tests/fixtures/solana/sign_tx.compute_budget_program.json b/common/tests/fixtures/solana/sign_tx.compute_budget_program.json index 86004be79..09b8c0888 100644 --- a/common/tests/fixtures/solana/sign_tx.compute_budget_program.json +++ b/common/tests/fixtures/solana/sign_tx.compute_budget_program.json @@ -65,6 +65,289 @@ "result": { "expected_signature": "682ba0889bcf9061ce0560fb7f300bfce25ff8ecdc65f1904a3fced1895de5145cf3c73352a811021d930bd224d4789b3c263acc1f1ae0fb48959d8332cc1702" } + }, + { + "description": "Transfer With Compute Budget Without Heap Confirmation", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 2 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "ETxHeBBcuw9Yu4dGuP3oXrD12V5RECvmi8ogQ9PkjyVF", + "11111111111111111111111111111111", + "ComputeBudget111111111111111111111111111111" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 3, + "accounts": {}, + "data": { + "instruction_id": 2, + "units": 200000 + } + }, + { + "program_index": 3, + "accounts": {}, + "data": { + "instruction_id": 3, + "lamports": 8000 + } + }, + { + "program_index": 2, + "accounts": { + "funding_account": 0, + "recipient_account": 1 + }, + "data": { + "instruction_id": 2, + "lamports": 20000000 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "742baf7a4e92f2d8e617512cb75b8698dd44cff6568a29c288767b31403879424ec16c0642b12081995a727f4a936ba49fc1797e900431a8c66297ba0da3c708" + } + }, + { + "description": "Transfer Token With Compute Budget", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 2 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "74pZnim7gywyschy4MGkW6eZURv1DBXqwHTCqLRk63wz", + "92YgwqTtTWB7qY92JT6mbL2WCmhAs7LPZL4jLcizNfwx", + "GHArwcWCuk9WkUG4XKUbt935rKfmBmywbEWyFxdH3mou", + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", + "ComputeBudget111111111111111111111111111111" + ], + "blockhash": "26kt5r94ZYdTZY27nAHqjropeDf7dPS19VkZJrta7duL", + "instructions": [ + { + "program_index": 5, + "accounts": {}, + "data": { + "instruction_id": 1, + "bytes": 2048 + } + }, + { + "program_index": 5, + "accounts": {}, + "data": { + "instruction_id": 2, + "units": 200000 + } + }, + { + "program_index": 5, + "accounts": {}, + "data": { + "instruction_id": 3, + "lamports": 8000 + } + }, + { + "program_index": 4, + "accounts": { + "source_account": 1, + "token_mint": 3, + "destination_account": 2, + "owner": 0, + "multisig_signers": [] + }, + "data": { + "instruction_id": 12, + "amount": 11, + "decimals": 9 + } + } + ], + "luts": [] + }, + "additional_info": { + "token_accounts_infos": [ + { + "base_address": "BkoECWJYM7w9qNZ6EGCoBtnkphWau6nZMPbPqvm4eYF4", + "token_program": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", + "token_mint": "GHArwcWCuk9WkUG4XKUbt935rKfmBmywbEWyFxdH3mou", + "token_account": "92YgwqTtTWB7qY92JT6mbL2WCmhAs7LPZL4jLcizNfwx" + } + ] + } + }, + "result": { + "expected_signature": "72fd7f8653661847387363f1c3a0ae48edd488b655861b67062678ffc9f0b1153ceabb9494dec8bb0a897f2a1cc94130f5a64af9b270d0c9a1c93c5efd269a06" + } + }, + { + "description": "Transfer Token With Compute Budget Without Heap Confrimation", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 2 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "74pZnim7gywyschy4MGkW6eZURv1DBXqwHTCqLRk63wz", + "92YgwqTtTWB7qY92JT6mbL2WCmhAs7LPZL4jLcizNfwx", + "GHArwcWCuk9WkUG4XKUbt935rKfmBmywbEWyFxdH3mou", + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", + "ComputeBudget111111111111111111111111111111" + ], + "blockhash": "26kt5r94ZYdTZY27nAHqjropeDf7dPS19VkZJrta7duL", + "instructions": [ + { + "program_index": 5, + "accounts": {}, + "data": { + "instruction_id": 2, + "units": 200000 + } + }, + { + "program_index": 5, + "accounts": {}, + "data": { + "instruction_id": 3, + "lamports": 8000 + } + }, + { + "program_index": 4, + "accounts": { + "source_account": 1, + "token_mint": 3, + "destination_account": 2, + "owner": 0, + "multisig_signers": [] + }, + "data": { + "instruction_id": 12, + "amount": 11, + "decimals": 9 + } + } + ], + "luts": [] + }, + "additional_info": { + "token_accounts_infos": [ + { + "base_address": "BkoECWJYM7w9qNZ6EGCoBtnkphWau6nZMPbPqvm4eYF4", + "token_program": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", + "token_mint": "GHArwcWCuk9WkUG4XKUbt935rKfmBmywbEWyFxdH3mou", + "token_account": "92YgwqTtTWB7qY92JT6mbL2WCmhAs7LPZL4jLcizNfwx" + } + ] + } + }, + "result": { + "expected_signature": "1eae0dca0209903a44e38964566c87c6db4f60c68067d8e6dec22c2dfb085f98147eb8e29fbf0e1bff390730e76eadf492cc5dd916b564ae892069b3fe485c09" + } + }, + { + "description": "Create Stake Account With Compute Budget", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 2, + "readonly_signers": 0, + "readonly_non_signers": 3 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "ATFXMD5cYiw9yHkvexgx3nf9LNSouEViB5BZBsgwunAv", + "11111111111111111111111111111111", + "Stake11111111111111111111111111111111111111", + "SysvarRent111111111111111111111111111111111", + "ComputeBudget111111111111111111111111111111" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 5, + "accounts": {}, + "data": { + "instruction_id": 1, + "bytes": 2048 + } + }, + { + "program_index": 5, + "accounts": {}, + "data": { + "instruction_id": 2, + "units": 200000 + } + }, + { + "program_index": 5, + "accounts": {}, + "data": { + "instruction_id": 3, + "lamports": 8000 + } + }, + { + "program_index": 2, + "accounts": { + "funding_account": 0, + "new_account": 1 + }, + "data": { + "instruction_id": 0, + "lamports": 20000000, + "space": 1000, + "owner": "Stake11111111111111111111111111111111111111" + } + }, + { + "program_index": 3, + "accounts": { + "uninitialized_stake_account": 1, + "rent_sysvar": 4 + }, + "data": { + "instruction_id": 0, + "staker": "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "withdrawer": "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "unix_timestamp": 0, + "epoch": 0, + "custodian": "11111111111111111111111111111111" + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "28ea83fcee7c5e51678e04aa72d37018fd41240ec0c3262268b2dc449971bcc2705ac7d9d24515b9a2c23fe59343d9732466a2207a30ca4f4d84c0ee31451f00" + } } ] } diff --git a/core/src/apps/solana/predefined_transaction.py b/core/src/apps/solana/predefined_transaction.py index aeac58a67..3534d9008 100644 --- a/core/src/apps/solana/predefined_transaction.py +++ b/core/src/apps/solana/predefined_transaction.py @@ -122,14 +122,13 @@ async def try_confirm_token_transfer_transaction( from .layout import confirm_token_transfer from .token_account import try_get_token_account_base_address + visible_instructions = transaction.get_visible_instructions() if not is_predefined_token_transfer( - transaction.instructions, + visible_instructions, ): return False - transfer_token_instructions = get_token_transfer_instructions( - transaction.instructions - ) + transfer_token_instructions = get_token_transfer_instructions(visible_instructions) # in is_predefined_token_transfer we made sure that these values are the same # for all the transfer token instructions @@ -178,7 +177,7 @@ async def try_confirm_predefined_transaction( from .layout import confirm_system_transfer from .transaction.instructions import SystemProgramTransferInstruction - instructions = transaction.instructions + instructions = transaction.get_visible_instructions() instructions_count = len(instructions) for instruction in instructions: diff --git a/core/src/apps/solana/sign_tx.py b/core/src/apps/solana/sign_tx.py index c1e824a23..298360861 100644 --- a/core/src/apps/solana/sign_tx.py +++ b/core/src/apps/solana/sign_tx.py @@ -76,8 +76,10 @@ async def sign_tx( async def confirm_instructions( signer_path: list[int], signer_public_key: bytes, transaction: Transaction ) -> None: - instructions_count = len(transaction.instructions) - for instruction_index, instruction in enumerate(transaction.instructions, 1): + + visible_instructions = transaction.get_visible_instructions() + instructions_count = len(visible_instructions) + for instruction_index, instruction in enumerate(visible_instructions, 1): if not instruction.is_program_supported: from .layout import confirm_unsupported_program_confirm diff --git a/core/src/apps/solana/transaction/__init__.py b/core/src/apps/solana/transaction/__init__.py index 7182d5e00..d09b9c72b 100644 --- a/core/src/apps/solana/transaction/__init__.py +++ b/core/src/apps/solana/transaction/__init__.py @@ -202,3 +202,10 @@ class Transaction: ): self.blind_signing = True break + + def get_visible_instructions(self) -> list[Instruction]: + return [ + instruction + for instruction in self.instructions + if not instruction.is_ui_hidden + ] diff --git a/core/src/apps/solana/transaction/instruction.py b/core/src/apps/solana/transaction/instruction.py index 77320f897..c108c35fb 100644 --- a/core/src/apps/solana/transaction/instruction.py +++ b/core/src/apps/solana/transaction/instruction.py @@ -30,6 +30,7 @@ class Instruction: is_program_supported: bool is_instruction_supported: bool + is_ui_hidden: bool instruction_data: InstructionData accounts: list[Account] @@ -88,6 +89,7 @@ class Instruction: ui_name: str, is_program_supported: bool = True, is_instruction_supported: bool = True, + is_ui_hidden: bool = False, supports_multisig: bool = False, is_deprecated_warning: str | None = None, ) -> None: @@ -101,6 +103,7 @@ class Instruction: self.ui_properties = ui_properties + self.is_ui_hidden = is_ui_hidden self.is_program_supported = is_program_supported self.is_instruction_supported = is_instruction_supported diff --git a/core/src/apps/solana/transaction/instructions.py b/core/src/apps/solana/transaction/instructions.py index 07c4a07d3..835324942 100644 --- a/core/src/apps/solana/transaction/instructions.py +++ b/core/src/apps/solana/transaction/instructions.py @@ -890,6 +890,7 @@ def get_instruction( True, True, False, + False, None, ) if instruction_id == SYSTEM_PROGRAM_ID_INS_ASSIGN: @@ -934,6 +935,7 @@ def get_instruction( True, True, False, + False, None, ) if instruction_id == SYSTEM_PROGRAM_ID_INS_TRANSFER: @@ -990,6 +992,7 @@ def get_instruction( True, True, False, + False, None, ) if instruction_id == SYSTEM_PROGRAM_ID_INS_CREATE_ACCOUNT_WITH_SEED: @@ -1079,6 +1082,7 @@ def get_instruction( True, True, False, + False, None, ) if instruction_id == SYSTEM_PROGRAM_ID_INS_ADVANCE_NONCE_ACCOUNT: @@ -1125,6 +1129,7 @@ def get_instruction( True, True, False, + False, None, ) if instruction_id == SYSTEM_PROGRAM_ID_INS_WITHDRAW_NONCE_ACCOUNT: @@ -1203,6 +1208,7 @@ def get_instruction( True, True, False, + False, None, ) if instruction_id == SYSTEM_PROGRAM_ID_INS_INITIALIZE_NONCE_ACCOUNT: @@ -1257,6 +1263,7 @@ def get_instruction( True, True, False, + False, None, ) if instruction_id == SYSTEM_PROGRAM_ID_INS_AUTHORIZE_NONCE_ACCOUNT: @@ -1313,6 +1320,7 @@ def get_instruction( True, True, False, + False, None, ) if instruction_id == SYSTEM_PROGRAM_ID_INS_ALLOCATE: @@ -1357,6 +1365,7 @@ def get_instruction( True, True, False, + False, None, ) if instruction_id == SYSTEM_PROGRAM_ID_INS_ALLOCATE_WITH_SEED: @@ -1427,6 +1436,7 @@ def get_instruction( True, True, False, + False, None, ) if instruction_id == SYSTEM_PROGRAM_ID_INS_ASSIGN_WITH_SEED: @@ -1490,6 +1500,7 @@ def get_instruction( True, True, False, + False, None, ) if instruction_id == SYSTEM_PROGRAM_ID_INS_TRANSFER_WITH_SEED: @@ -1565,6 +1576,7 @@ def get_instruction( True, True, False, + False, None, ) if instruction_id == SYSTEM_PROGRAM_ID_INS_UPGRADE_NONCE_ACCOUNT: @@ -1594,6 +1606,7 @@ def get_instruction( True, True, False, + False, None, ) return Instruction( @@ -1608,6 +1621,7 @@ def get_instruction( True, False, False, + False, ) if program_id == STAKE_PROGRAM_ID: if instruction_id == STAKE_PROGRAM_ID_INS_INITIALIZE: @@ -1713,6 +1727,7 @@ def get_instruction( True, True, False, + False, None, ) if instruction_id == STAKE_PROGRAM_ID_INS_AUTHORIZE: @@ -1800,6 +1815,7 @@ def get_instruction( True, True, False, + False, None, ) if instruction_id == STAKE_PROGRAM_ID_INS_DELEGATE_STAKE: @@ -1868,6 +1884,7 @@ def get_instruction( True, True, False, + False, None, ) if instruction_id == STAKE_PROGRAM_ID_INS_SPLIT: @@ -1936,6 +1953,7 @@ def get_instruction( True, True, False, + False, None, ) if instruction_id == STAKE_PROGRAM_ID_INS_WITHDRAW: @@ -2019,6 +2037,7 @@ def get_instruction( True, True, False, + False, None, ) if instruction_id == STAKE_PROGRAM_ID_INS_DEACTIVATE: @@ -2065,6 +2084,7 @@ def get_instruction( True, True, False, + False, None, ) if instruction_id == STAKE_PROGRAM_ID_INS_SET_LOCKUP: @@ -2149,6 +2169,7 @@ def get_instruction( True, True, False, + False, None, ) if instruction_id == STAKE_PROGRAM_ID_INS_MERGE: @@ -2212,6 +2233,7 @@ def get_instruction( True, True, False, + False, None, ) if instruction_id == STAKE_PROGRAM_ID_INS_AUTHORIZE_WITH_SEED: @@ -2313,6 +2335,7 @@ def get_instruction( True, True, False, + False, None, ) if instruction_id == STAKE_PROGRAM_ID_INS_INITIALIZE_CHECKED: @@ -2371,6 +2394,7 @@ def get_instruction( True, True, False, + False, None, ) if instruction_id == STAKE_PROGRAM_ID_INS_AUTHORIZE_CHECKED: @@ -2456,6 +2480,7 @@ def get_instruction( True, True, False, + False, None, ) if instruction_id == STAKE_PROGRAM_ID_INS_AUTHORIZE_CHECKED_WITH_SEED: @@ -2555,6 +2580,7 @@ def get_instruction( True, True, False, + False, None, ) if instruction_id == STAKE_PROGRAM_ID_INS_SET_LOCKUP_CHECKED: @@ -2637,6 +2663,7 @@ def get_instruction( True, True, False, + False, None, ) return Instruction( @@ -2651,6 +2678,7 @@ def get_instruction( True, False, False, + False, ) if program_id == COMPUTE_BUDGET_PROGRAM_ID: if instruction_id == COMPUTE_BUDGET_PROGRAM_ID_INS_REQUEST_HEAP_FRAME: @@ -2682,6 +2710,7 @@ def get_instruction( True, True, False, + False, None, ) if instruction_id == COMPUTE_BUDGET_PROGRAM_ID_INS_SET_COMPUTE_UNIT_LIMIT: @@ -2712,6 +2741,7 @@ def get_instruction( "Compute Budget Program: Set Compute Unit Limit", True, True, + True, False, None, ) @@ -2743,6 +2773,7 @@ def get_instruction( "Compute Budget Program: Set Compute Unit Price", True, True, + True, False, None, ) @@ -2758,6 +2789,7 @@ def get_instruction( True, False, False, + False, ) if program_id == TOKEN_PROGRAM_ID: if instruction_id == TOKEN_PROGRAM_ID_INS_INITIALIZE_ACCOUNT: @@ -2816,6 +2848,7 @@ def get_instruction( True, True, False, + False, None, ) if instruction_id == TOKEN_PROGRAM_ID_INS_INITIALIZE_MULTISIG: @@ -2869,6 +2902,7 @@ def get_instruction( "Token Program: Initialize Multisig", True, True, + False, True, None, ) @@ -2937,6 +2971,7 @@ def get_instruction( "Token Program: Transfer", True, True, + False, True, "Warning: Instruction is deprecated. Token decimals unknown.", ) @@ -2998,6 +3033,7 @@ def get_instruction( "Token Program: Approve", True, True, + False, True, "Warning: Instruction is deprecated. Token decimals unknown.", ) @@ -3039,6 +3075,7 @@ def get_instruction( "Token Program: Revoke", True, True, + False, True, None, ) @@ -3109,6 +3146,7 @@ def get_instruction( "Token Program: Set Authority", True, True, + False, True, None, ) @@ -3170,6 +3208,7 @@ def get_instruction( "Token Program: Mint To", True, True, + False, True, "Warning: Instruction is deprecated. Token decimals unknown.", ) @@ -3231,6 +3270,7 @@ def get_instruction( "Token Program: Burn", True, True, + False, True, "Warning: Instruction is deprecated. Token decimals unknown.", ) @@ -3284,6 +3324,7 @@ def get_instruction( "Token Program: Close Account", True, True, + False, True, None, ) @@ -3330,6 +3371,7 @@ def get_instruction( "Token Program: Freeze Account", True, True, + False, True, None, ) @@ -3376,6 +3418,7 @@ def get_instruction( "Token Program: Thaw Account", True, True, + False, True, None, ) @@ -3463,6 +3506,7 @@ def get_instruction( "Token Program: Transfer Checked", True, True, + False, True, None, ) @@ -3550,6 +3594,7 @@ def get_instruction( "Token Program: Approve Checked", True, True, + False, True, None, ) @@ -3625,6 +3670,7 @@ def get_instruction( "Token Program: Mint to Checked", True, True, + False, True, None, ) @@ -3700,6 +3746,7 @@ def get_instruction( "Token Program: Burn Checked", True, True, + False, True, None, ) @@ -3762,6 +3809,7 @@ def get_instruction( True, True, False, + False, None, ) if instruction_id == TOKEN_PROGRAM_ID_INS_SYNC_NATIVE: @@ -3791,6 +3839,7 @@ def get_instruction( True, True, False, + False, None, ) if instruction_id == TOKEN_PROGRAM_ID_INS_INITIALIZE_ACCOUNT_3: @@ -3847,6 +3896,7 @@ def get_instruction( True, True, False, + False, None, ) if instruction_id == TOKEN_PROGRAM_ID_INS_INITIALIZE_IMMUTABLE_OWNER: @@ -3876,6 +3926,7 @@ def get_instruction( True, True, False, + False, None, ) return Instruction( @@ -3890,6 +3941,7 @@ def get_instruction( True, False, False, + False, ) if program_id == TOKEN_2022_PROGRAM_ID: if instruction_id == TOKEN_2022_PROGRAM_ID_INS_INITIALIZE_ACCOUNT: @@ -3948,6 +4000,7 @@ def get_instruction( True, True, False, + False, None, ) if instruction_id == TOKEN_2022_PROGRAM_ID_INS_INITIALIZE_MULTISIG: @@ -4001,6 +4054,7 @@ def get_instruction( "Token 2022 Program: Initialize Multisig", True, True, + False, True, None, ) @@ -4069,6 +4123,7 @@ def get_instruction( "Token 2022 Program: Transfer", True, True, + False, True, "Warning: Instruction is deprecated. Token decimals unknown.", ) @@ -4130,6 +4185,7 @@ def get_instruction( "Token 2022 Program: Approve", True, True, + False, True, "Warning: Instruction is deprecated. Token decimals unknown.", ) @@ -4171,6 +4227,7 @@ def get_instruction( "Token 2022 Program: Revoke", True, True, + False, True, None, ) @@ -4241,6 +4298,7 @@ def get_instruction( "Token 2022 Program: Set Authority", True, True, + False, True, None, ) @@ -4302,6 +4360,7 @@ def get_instruction( "Token 2022 Program: Mint to", True, True, + False, True, "Warning: Instruction is deprecated. Token decimals unknown.", ) @@ -4363,6 +4422,7 @@ def get_instruction( "Token 2022 Program: Burn", True, True, + False, True, "Warning: Instruction is deprecated. Token decimals unknown.", ) @@ -4416,6 +4476,7 @@ def get_instruction( "Token 2022 Program: Close Account", True, True, + False, True, None, ) @@ -4462,6 +4523,7 @@ def get_instruction( "Token 2022 Program: Freeze Account", True, True, + False, True, None, ) @@ -4508,6 +4570,7 @@ def get_instruction( "Token 2022 Program: Thaw Account", True, True, + False, True, None, ) @@ -4595,6 +4658,7 @@ def get_instruction( "Token 2022 Program: Transfer Checked", True, True, + False, True, None, ) @@ -4682,6 +4746,7 @@ def get_instruction( "Token 2022 Program: Approve Checked", True, True, + False, True, None, ) @@ -4757,6 +4822,7 @@ def get_instruction( "Token 2022 Program: Mint to Checked", True, True, + False, True, None, ) @@ -4832,6 +4898,7 @@ def get_instruction( "Token 2022 Program: Burn Checked", True, True, + False, True, None, ) @@ -4894,6 +4961,7 @@ def get_instruction( True, True, False, + False, None, ) if instruction_id == TOKEN_2022_PROGRAM_ID_INS_SYNC_NATIVE: @@ -4923,6 +4991,7 @@ def get_instruction( True, True, False, + False, None, ) if instruction_id == TOKEN_2022_PROGRAM_ID_INS_INITIALIZE_ACCOUNT_3: @@ -4979,6 +5048,7 @@ def get_instruction( True, True, False, + False, None, ) if instruction_id == TOKEN_2022_PROGRAM_ID_INS_INITIALIZE_IMMUTABLE_OWNER: @@ -5008,6 +5078,7 @@ def get_instruction( True, True, False, + False, None, ) return Instruction( @@ -5022,6 +5093,7 @@ def get_instruction( True, False, False, + False, ) if program_id == ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID: if instruction_id == ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID_INS_CREATE: @@ -5097,6 +5169,7 @@ def get_instruction( True, True, False, + False, None, ) if instruction_id == ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID_INS_CREATE_IDEMPOTENT: @@ -5172,6 +5245,7 @@ def get_instruction( True, True, False, + False, None, ) if instruction_id == ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID_INS_RECOVER_NESTED: @@ -5245,6 +5319,7 @@ def get_instruction( True, True, False, + False, None, ) return Instruction( @@ -5259,6 +5334,7 @@ def get_instruction( True, False, False, + False, ) if program_id == MEMO_PROGRAM_ID: if instruction_id == MEMO_PROGRAM_ID_INS_MEMO: @@ -5303,6 +5379,7 @@ def get_instruction( True, True, False, + False, None, ) return Instruction( @@ -5317,6 +5394,7 @@ def get_instruction( True, False, False, + False, ) if program_id == MEMO_LEGACY_PROGRAM_ID: if instruction_id == MEMO_LEGACY_PROGRAM_ID_INS_MEMO: @@ -5361,6 +5439,7 @@ def get_instruction( True, True, False, + False, None, ) return Instruction( @@ -5375,6 +5454,7 @@ def get_instruction( True, False, False, + False, ) return Instruction( instruction_data, @@ -5388,4 +5468,5 @@ def get_instruction( False, False, False, + False, ) diff --git a/core/src/apps/solana/transaction/instructions.py.mako b/core/src/apps/solana/transaction/instructions.py.mako index bbf6dd03d..5877a2062 100644 --- a/core/src/apps/solana/transaction/instructions.py.mako +++ b/core/src/apps/solana/transaction/instructions.py.mako @@ -130,7 +130,6 @@ def ${type["format"]}(_: Instruction, value: int) -> str: None\ % endif \ - <% # Make sure that all required parameters are present in the instruction. for program in programs["programs"]: @@ -190,6 +189,7 @@ def get_instruction( "${program["name"]}: ${instruction["name"]}", True, True, + ${instruction.get("is_ui_hidden", False)}, ${instruction["is_multisig"]}, ${getOptionalString(instruction, "is_deprecated_warning")}, ) @@ -205,6 +205,7 @@ def get_instruction( "${program["name"]}", True, False, + False, False ) % endif @@ -220,6 +221,7 @@ def get_instruction( "Unsupported program", False, False, + False, False ) diff --git a/core/src/apps/solana/transaction/programs.json b/core/src/apps/solana/transaction/programs.json index 867c928a3..7f176edc5 100644 --- a/core/src/apps/solana/transaction/programs.json +++ b/core/src/apps/solana/transaction/programs.json @@ -1315,6 +1315,7 @@ { "id": 2, "name": "Set Compute Unit Limit", + "is_ui_hidden": true, "is_multisig": false, "parameters": [ { @@ -1334,6 +1335,7 @@ { "id": 3, "name": "Set Compute Unit Price", + "is_ui_hidden": true, "is_multisig": false, "parameters": [ { diff --git a/core/tests/test_apps.solana.predefined_transaction.py b/core/tests/test_apps.solana.predefined_transaction.py index 9d0984a0e..307bf0abc 100644 --- a/core/tests/test_apps.solana.predefined_transaction.py +++ b/core/tests/test_apps.solana.predefined_transaction.py @@ -30,6 +30,7 @@ def create_mock_instruction( ui_name="", is_program_supported=True, is_instruction_supported=True, + is_ui_hidden=False, supports_multisig=False, is_deprecated_warning=None, ) diff --git a/tests/ui_tests/fixtures.json b/tests/ui_tests/fixtures.json index b13b2711f..9f7a68ab3 100644 --- a/tests/ui_tests/fixtures.json +++ b/tests/ui_tests/fixtures.json @@ -19387,6 +19387,7 @@ "TT_en_solana-test_sign_tx.py::test_solana_sign_tx[create_associated_token_account]": "524a9d4ab0406cce8c7c8165c8eef706656bd44de6f5bf29124db6a98b33c612", "TT_en_solana-test_sign_tx.py::test_solana_sign_tx[create_associated_token_account_idempotent]": "8664c38ef71ce627dd11efb64b0df244ef9da0932f806bbfd284ad7687e8a72c", "TT_en_solana-test_sign_tx.py::test_solana_sign_tx[create_stake_account]": "4897dc73849f7e7787de0a5f2dce4973bff127c173a09cd054bdbf68c3f02ece", +"TT_en_solana-test_sign_tx.py::test_solana_sign_tx[create_stake_account_with_compute_budget]": "bbee0856297cb8abe986c1832e4020c02c3f172463e369b577f2c662e72974f8", "TT_en_solana-test_sign_tx.py::test_solana_sign_tx[create_token_account_and_transfer_token_-_predefined]": "a9a47846ba32a38d250aab36fd6ae12915343f49b40dd17ef808da8e4c7c485e", "TT_en_solana-test_sign_tx.py::test_solana_sign_tx[deactivate]": "0ba810277887b2c7b1821c8eef4f483c143bb1448ef71a34d0474c6a0afedc7d", "TT_en_solana-test_sign_tx.py::test_solana_sign_tx[delegate]": "09b60fa7a047497229eee817684881c85d3360e710b1b917d0d288ae12aa3459", @@ -19423,7 +19424,10 @@ "TT_en_solana-test_sign_tx.py::test_solana_sign_tx[transfer_checked]": "0b2d55ccbcfd78972e080b6a72d16ed000207c796ac7d81e8f2dc7ce6f5a7048", "TT_en_solana-test_sign_tx.py::test_solana_sign_tx[transfer_checked_-_multisig]": "6545aafb0f5ec3f7703a5006995b4aa1dd7f70f54113ff871f19da13baaaa1c1", "TT_en_solana-test_sign_tx.py::test_solana_sign_tx[transfer_token_-_predefined]": "a9a47846ba32a38d250aab36fd6ae12915343f49b40dd17ef808da8e4c7c485e", -"TT_en_solana-test_sign_tx.py::test_solana_sign_tx[transfer_with_compute_budget]": "2d7f30fdc029ddeeccc405ee7314ac0eb04b3be71593ee2d4e1adc174c483ca5", +"TT_en_solana-test_sign_tx.py::test_solana_sign_tx[transfer_token_with_compute_budget]": "3faa43bbc5f22d550fa523e34c7bd239f9448a9bc3ea2cbbb9516794dc2973cf", +"TT_en_solana-test_sign_tx.py::test_solana_sign_tx[transfer_token_with_compute_budget_without_heap-9ae0985e": "ef12c38cc08c2a0cceffc79ca75263cbecabcc500f11ac373ee3e58f18549f78", +"TT_en_solana-test_sign_tx.py::test_solana_sign_tx[transfer_with_compute_budget]": "52010e3d3e71af3494ebdd43f1f69e11bee65d0e209f75c95690a40da3f81fd1", +"TT_en_solana-test_sign_tx.py::test_solana_sign_tx[transfer_with_compute_budget_without_heap_confirmation]": "84bac830801fb596c563d2704247bebd92e777ae5008a2f34fe89a38114bc1a1", "TT_en_solana-test_sign_tx.py::test_solana_sign_tx[transfer_with_seed]": "f4e95cb91b71f9bbc64749ec062d944fabf4e59d44753b7c4f71755f5e37cf88", "TT_en_solana-test_sign_tx.py::test_solana_sign_tx[unknown_instruction]": "b610b5c902ee60ad14c76f81bcb9144ac20806b63856054e9efd4ef36c5755fd", "TT_en_solana-test_sign_tx.py::test_solana_sign_tx[upgrade_nonce]": "255fb82c371edfa0c8a0b93751f9994784913afa12d6cc85b99a26eaab12874b",