Skip to content

Commit

Permalink
fix(solana): fix Memo, multisig and polish instructions UI
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielKerekes committed Dec 6, 2023
1 parent 20400bc commit bcaa944
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 74 deletions.
15 changes: 8 additions & 7 deletions core/src/apps/solana/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ async def confirm_instruction(
br_code=ButtonRequestType.Other,
)

if instruction.multisig_signers:
await confirm_metadata(
"confirm_multisig",
"Confirm multisig",
"The following instruction is a multisig instruction.",
br_code=ButtonRequestType.Other,
)

for ui_property in instruction.ui_properties:
if ui_property.parameter is not None:
property_template = instruction.get_property_template(ui_property.parameter)
Expand Down Expand Up @@ -124,13 +132,6 @@ async def confirm_instruction(
raise ValueError # Invalid ui property

if instruction.multisig_signers:
await confirm_metadata(
"confirm_multisig",
"Confirm multisig",
"The following instruction is a multisig instruction.",
br_code=ButtonRequestType.Other,
)

signers: list[tuple[str, str]] = []
for i, multisig_signer in enumerate(instruction.multisig_signers, 1):
multisig_signer_public_key = multisig_signer[0]
Expand Down
4 changes: 4 additions & 0 deletions core/src/apps/solana/predefined_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ async def try_confirm_predefined_transaction(
instructions = transaction.instructions
instructions_count = len(instructions)

for instruction in instructions:
if instruction.multisig_signers:
return False

if instructions_count == 1:
if SystemProgramTransferInstruction.is_type_of(instructions[0]):
await confirm_system_transfer(instructions[0], fee, signer_path, blockhash)
Expand Down
2 changes: 1 addition & 1 deletion core/src/apps/solana/transaction/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def _parse_instructions(self, serialized_tx_reader: BufferReader) -> None:
data_length = parse_var_int(serialized_tx_reader)

instruction_id_length = get_instruction_id_length(program_id)
if instruction_id_length <= data_length:
if 0 < instruction_id_length <= data_length:
instruction_id = int.from_bytes(
serialized_tx_reader.read_memoryview(instruction_id_length),
"little",
Expand Down
87 changes: 54 additions & 33 deletions core/src/apps/solana/transaction/instructions.py
Original file line number Diff line number Diff line change
Expand Up @@ -918,14 +918,14 @@ def get_instruction(
UIProperty(
None,
"assigned_account",
"Assigned account",
"Assign account",
False,
None,
),
UIProperty(
"owner",
None,
"To program",
"Assign account to program",
False,
None,
),
Expand Down Expand Up @@ -1411,7 +1411,7 @@ def get_instruction(
UIProperty(
None,
"allocated_account",
"Allocate account",
"Allocate data for account",
False,
None,
),
Expand Down Expand Up @@ -1474,14 +1474,14 @@ def get_instruction(
UIProperty(
None,
"assigned_account",
"Assigned account",
"Assign account",
False,
None,
),
UIProperty(
"owner",
None,
"To program",
"Assign account to program",
False,
None,
),
Expand Down Expand Up @@ -1763,7 +1763,7 @@ def get_instruction(
UIProperty(
None,
"stake_account",
"Set stake authority for",
"Set authority for",
False,
None,
),
Expand Down Expand Up @@ -1989,7 +1989,7 @@ def get_instruction(
UIProperty(
"lamports",
None,
"Stake withdraw",
"Withdraw stake",
False,
None,
),
Expand Down Expand Up @@ -2049,7 +2049,7 @@ def get_instruction(
UIProperty(
None,
"delegated_stake_account",
"Deactivate stake",
"Deactivate stake account",
False,
None,
),
Expand Down Expand Up @@ -2189,7 +2189,7 @@ def get_instruction(
UIProperty(
None,
"source_stake_account",
"Merge",
"Merge stake account",
False,
None,
),
Expand Down Expand Up @@ -2276,14 +2276,21 @@ def get_instruction(
UIProperty(
None,
"stake_account",
"Set stake auth",
"Set authority for",
False,
None,
),
UIProperty(
"new_authorized_pubkey",
None,
"New (stake/withdraw) auth",
"New authority",
False,
None,
),
UIProperty(
"stake_authorize",
None,
"Authority type",
False,
None,
),
Expand Down Expand Up @@ -2412,21 +2419,35 @@ def get_instruction(
UIProperty(
None,
"stake_account",
"Set stake auth",
"Set authority for",
False,
None,
),
UIProperty(
None,
"new_stake_or_withdraw_authority",
"New authority",
False,
None,
),
UIProperty(
"stake_authorize",
None,
"Authority type",
False,
None,
),
UIProperty(
None,
"stake_or_withdraw_authority",
"Stake or withdraw authority",
"Authorized by",
False,
None,
),
UIProperty(
None,
"new_stake_or_withdraw_authority",
"New stake or withdraw authority",
"lockup_authority",
"Custodian",
False,
None,
),
Expand Down Expand Up @@ -2497,7 +2518,7 @@ def get_instruction(
UIProperty(
None,
"stake_account",
"Set authority for stake account",
"Set authority for",
False,
None,
),
Expand Down Expand Up @@ -2772,7 +2793,7 @@ def get_instruction(
UIProperty(
None,
"account_to_initialize",
"Init account",
"Initialize account",
False,
None,
),
Expand All @@ -2786,7 +2807,7 @@ def get_instruction(
UIProperty(
None,
"mint_account",
"Mint",
"For token",
False,
None,
),
Expand Down Expand Up @@ -2833,7 +2854,7 @@ def get_instruction(
UIProperty(
None,
"multisig_account",
"Init multisig",
"Initialize multisig",
False,
None,
),
Expand Down Expand Up @@ -3003,7 +3024,7 @@ def get_instruction(
UIProperty(
None,
"source_account",
"Rewoke delegate",
"Revoke delegate",
False,
None,
),
Expand Down Expand Up @@ -3718,7 +3739,7 @@ def get_instruction(
UIProperty(
None,
"account_to_initialize",
"Init account",
"Initialize account",
False,
None,
),
Expand All @@ -3732,7 +3753,7 @@ def get_instruction(
UIProperty(
None,
"mint_account",
"Mint",
"For token",
False,
None,
),
Expand Down Expand Up @@ -3803,7 +3824,7 @@ def get_instruction(
UIProperty(
None,
"account_to_initialize",
"Init account",
"Initialize account",
False,
None,
),
Expand All @@ -3817,7 +3838,7 @@ def get_instruction(
UIProperty(
None,
"mint_account",
"Mint",
"For token",
False,
None,
),
Expand Down Expand Up @@ -3904,7 +3925,7 @@ def get_instruction(
UIProperty(
None,
"account_to_initialize",
"Init account",
"Initialize account",
False,
None,
),
Expand All @@ -3918,7 +3939,7 @@ def get_instruction(
UIProperty(
None,
"mint_account",
"Mint",
"For token",
False,
None,
),
Expand Down Expand Up @@ -4850,7 +4871,7 @@ def get_instruction(
UIProperty(
None,
"account_to_initialize",
"Init account",
"Initialize account",
False,
None,
),
Expand All @@ -4864,7 +4885,7 @@ def get_instruction(
UIProperty(
None,
"mint_account",
"Mint",
"For token",
False,
None,
),
Expand Down Expand Up @@ -4935,7 +4956,7 @@ def get_instruction(
UIProperty(
None,
"account_to_initialize",
"Init account",
"Initialize account",
False,
None,
),
Expand All @@ -4949,7 +4970,7 @@ def get_instruction(
UIProperty(
None,
"mint_account",
"Mint",
"For token",
False,
None,
),
Expand Down Expand Up @@ -4978,7 +4999,7 @@ def get_instruction(
UIProperty(
None,
"account_to_initialize",
"Init account",
"Initialize immutable owner extension for account",
False,
None,
),
Expand Down Expand Up @@ -5053,7 +5074,7 @@ def get_instruction(
UIProperty(
None,
"token_mint",
"From mint",
"For token",
False,
None,
),
Expand Down Expand Up @@ -5128,7 +5149,7 @@ def get_instruction(
UIProperty(
None,
"token_mint",
"From mint",
"For token",
False,
None,
),
Expand Down
Loading

0 comments on commit bcaa944

Please sign in to comment.