diff --git a/Makefile b/Makefile index 602aab91d..fe99a3b7d 100644 --- a/Makefile +++ b/Makefile @@ -112,6 +112,12 @@ templates: icons ## rebuild coin lists from definitions in common templates_check: ## check that coin lists are up to date ./core/tools/build_templates --check +solana_templates: ## rebuild Solana instruction template file + ./core/tools/build_solana_templates + +solana_templates_check: ## check that Solana instruction template file is up to date + ./core/tools/build_solana_templates --check + icons: ## generate FIDO service icons python3 core/tools/build_icons.py @@ -138,6 +144,6 @@ vendorheader: ## generate vendor header vendorheader_check: ## check that vendor header is up to date ./core/embed/vendorheader/generate.sh --quiet --check -gen: mocks icons templates protobuf ci_docs vendorheader ## regenerate auto-generated files from sources +gen: mocks icons templates protobuf ci_docs vendorheader solana_templates ## regenerate auto-generated files from sources -gen_check: mocks_check icons_check templates_check protobuf_check ci_docs_check vendorheader_check ## check validity of auto-generated files +gen_check: mocks_check icons_check templates_check protobuf_check ci_docs_check vendorheader_check solana_templates_check ## check validity of auto-generated files diff --git a/core/Makefile b/core/Makefile index ddae3d331..a2742ea37 100644 --- a/core/Makefile +++ b/core/Makefile @@ -166,6 +166,12 @@ templates: ## render Mako templates (for lists of coins, tokens, etc.) templates_check: ## check that Mako-rendered files match their templates ./tools/build_templates --check +solana_templates: ## rebuild Solana instruction template file + ./tools/build_solana_templates + +solana_templates_check: ## check that Solana instruction template file is up to date + ./tools/build_solana_templates --check + ## build commands: build: build_boardloader build_bootloader build_firmware build_prodtest build_unix ## build all diff --git a/core/src/all_modules.py b/core/src/all_modules.py index 6be0c01cd..58278aa7e 100644 --- a/core/src/all_modules.py +++ b/core/src/all_modules.py @@ -689,6 +689,8 @@ if not utils.BITCOIN_ONLY: import apps.solana.get_public_key apps.solana.sign_tx import apps.solana.sign_tx + apps.solana.transaction.instructions + import apps.solana.transaction.instructions apps.stellar import apps.stellar apps.stellar.consts diff --git a/core/src/apps/solana/transaction/instructions.py b/core/src/apps/solana/transaction/instructions.py new file mode 100644 index 000000000..3eb9226a7 --- /dev/null +++ b/core/src/apps/solana/transaction/instructions.py @@ -0,0 +1,5370 @@ +# generated from instructions.py.mako +# do not edit manually! +from typing import TYPE_CHECKING + +from trezor.wire import DataError + +from apps.common.readers import read_uint32_le, read_uint64_le + +from ..format import ( + format_identity, + format_int, + format_lamports, + format_pubkey, + format_token_amount, + format_unix_timestamp, +) +from ..types import AccountTemplate, PropertyTemplate, UIProperty +from .instruction import Instruction +from .parse import parse_byte, parse_memo, parse_pubkey, parse_string + +if TYPE_CHECKING: + from typing import Any, Type + + from ..types import Account, InstructionData, InstructionId + +SYSTEM_PROGRAM_ID = "11111111111111111111111111111111" +STAKE_PROGRAM_ID = "Stake11111111111111111111111111111111111111" +COMPUTE_BUDGET_PROGRAM_ID = "ComputeBudget111111111111111111111111111111" +TOKEN_PROGRAM_ID = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" +TOKEN_2022_PROGRAM_ID = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" +ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" +MEMO_PROGRAM_ID = "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" +MEMO_LEGACY_PROGRAM_ID = "Memo1UhkJRfHyvLMcVucJwxXeuD728EqVDDwQDxFMNo" + +SYSTEM_PROGRAM_ID_INS_CREATE_ACCOUNT = 0 +SYSTEM_PROGRAM_ID_INS_ASSIGN = 1 +SYSTEM_PROGRAM_ID_INS_TRANSFER = 2 +SYSTEM_PROGRAM_ID_INS_CREATE_ACCOUNT_WITH_SEED = 3 +SYSTEM_PROGRAM_ID_INS_ADVANCE_NONCE_ACCOUNT = 4 +SYSTEM_PROGRAM_ID_INS_WITHDRAW_NONCE_ACCOUNT = 5 +SYSTEM_PROGRAM_ID_INS_INITIALIZE_NONCE_ACCOUNT = 6 +SYSTEM_PROGRAM_ID_INS_AUTHORIZE_NONCE_ACCOUNT = 7 +SYSTEM_PROGRAM_ID_INS_ALLOCATE = 8 +SYSTEM_PROGRAM_ID_INS_ALLOCATE_WITH_SEED = 9 +SYSTEM_PROGRAM_ID_INS_ASSIGN_WITH_SEED = 10 +SYSTEM_PROGRAM_ID_INS_TRANSFER_WITH_SEED = 11 +SYSTEM_PROGRAM_ID_INS_UPGRADE_NONCE_ACCOUNT = 12 +STAKE_PROGRAM_ID_INS_INITIALIZE = 0 +STAKE_PROGRAM_ID_INS_AUTHORIZE = 1 +STAKE_PROGRAM_ID_INS_DELEGATE_STAKE = 2 +STAKE_PROGRAM_ID_INS_SPLIT = 3 +STAKE_PROGRAM_ID_INS_WITHDRAW = 4 +STAKE_PROGRAM_ID_INS_DEACTIVATE = 5 +STAKE_PROGRAM_ID_INS_SET_LOCKUP = 6 +STAKE_PROGRAM_ID_INS_MERGE = 7 +STAKE_PROGRAM_ID_INS_AUTHORIZE_WITH_SEED = 8 +STAKE_PROGRAM_ID_INS_INITIALIZE_CHECKED = 9 +STAKE_PROGRAM_ID_INS_AUTHORIZE_CHECKED = 10 +STAKE_PROGRAM_ID_INS_AUTHORIZE_CHECKED_WITH_SEED = 11 +STAKE_PROGRAM_ID_INS_SET_LOCKUP_CHECKED = 12 +COMPUTE_BUDGET_PROGRAM_ID_INS_REQUEST_HEAP_FRAME = 1 +COMPUTE_BUDGET_PROGRAM_ID_INS_SET_COMPUTE_UNIT_LIMIT = 2 +COMPUTE_BUDGET_PROGRAM_ID_INS_SET_COMPUTE_UNIT_PRICE = 3 +TOKEN_PROGRAM_ID_INS_INITIALIZE_ACCOUNT = 1 +TOKEN_PROGRAM_ID_INS_INITIALIZE_MULTISIG = 2 +TOKEN_PROGRAM_ID_INS_TRANSFER = 3 +TOKEN_PROGRAM_ID_INS_APPROVE = 4 +TOKEN_PROGRAM_ID_INS_REVOKE = 5 +TOKEN_PROGRAM_ID_INS_SET_AUTHORITY = 6 +TOKEN_PROGRAM_ID_INS_MINT_TO = 7 +TOKEN_PROGRAM_ID_INS_BURN = 8 +TOKEN_PROGRAM_ID_INS_CLOSE_ACCOUNT = 9 +TOKEN_PROGRAM_ID_INS_FREEZE_ACCOUNT = 10 +TOKEN_PROGRAM_ID_INS_THAW_ACCOUNT = 11 +TOKEN_PROGRAM_ID_INS_TRANSFER_CHECKED = 12 +TOKEN_PROGRAM_ID_INS_APPROVE_CHECKED = 13 +TOKEN_PROGRAM_ID_INS_MINT_TO_CHECKED = 14 +TOKEN_PROGRAM_ID_INS_BURN_CHECKED = 15 +TOKEN_PROGRAM_ID_INS_INITIALIZE_ACCOUNT_2 = 16 +TOKEN_PROGRAM_ID_INS_SYNC_NATIVE = 17 +TOKEN_PROGRAM_ID_INS_INITIALIZE_ACCOUNT_3 = 18 +TOKEN_PROGRAM_ID_INS_INITIALIZE_IMMUTABLE_OWNER = 22 +TOKEN_2022_PROGRAM_ID_INS_INITIALIZE_ACCOUNT = 1 +TOKEN_2022_PROGRAM_ID_INS_INITIALIZE_MULTISIG = 2 +TOKEN_2022_PROGRAM_ID_INS_TRANSFER = 3 +TOKEN_2022_PROGRAM_ID_INS_APPROVE = 4 +TOKEN_2022_PROGRAM_ID_INS_REVOKE = 5 +TOKEN_2022_PROGRAM_ID_INS_SET_AUTHORITY = 6 +TOKEN_2022_PROGRAM_ID_INS_MINT_TO = 7 +TOKEN_2022_PROGRAM_ID_INS_BURN = 8 +TOKEN_2022_PROGRAM_ID_INS_CLOSE_ACCOUNT = 9 +TOKEN_2022_PROGRAM_ID_INS_FREEZE_ACCOUNT = 10 +TOKEN_2022_PROGRAM_ID_INS_THAW_ACCOUNT = 11 +TOKEN_2022_PROGRAM_ID_INS_TRANSFER_CHECKED = 12 +TOKEN_2022_PROGRAM_ID_INS_APPROVE_CHECKED = 13 +TOKEN_2022_PROGRAM_ID_INS_MINT_TO_CHECKED = 14 +TOKEN_2022_PROGRAM_ID_INS_BURN_CHECKED = 15 +TOKEN_2022_PROGRAM_ID_INS_INITIALIZE_ACCOUNT_2 = 16 +TOKEN_2022_PROGRAM_ID_INS_SYNC_NATIVE = 17 +TOKEN_2022_PROGRAM_ID_INS_INITIALIZE_ACCOUNT_3 = 18 +TOKEN_2022_PROGRAM_ID_INS_INITIALIZE_IMMUTABLE_OWNER = 22 +ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID_INS_CREATE = None +ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID_INS_CREATE_IDEMPOTENT = 1 +ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID_INS_RECOVER_NESTED = 2 +MEMO_PROGRAM_ID_INS_MEMO = None +MEMO_LEGACY_PROGRAM_ID_INS_MEMO = None + + +def __getattr__(name: str) -> Type[Instruction]: + def get_id(name: str) -> tuple[str, InstructionId]: + if name == "SystemProgramCreateAccountInstruction": + return ("11111111111111111111111111111111", 0) + if name == "SystemProgramAssignInstruction": + return ("11111111111111111111111111111111", 1) + if name == "SystemProgramTransferInstruction": + return ("11111111111111111111111111111111", 2) + if name == "SystemProgramCreateAccountWithSeedInstruction": + return ("11111111111111111111111111111111", 3) + if name == "SystemProgramAdvanceNonceAccountInstruction": + return ("11111111111111111111111111111111", 4) + if name == "SystemProgramWithdrawNonceAccountInstruction": + return ("11111111111111111111111111111111", 5) + if name == "SystemProgramInitializeNonceAccountInstruction": + return ("11111111111111111111111111111111", 6) + if name == "SystemProgramAuthorizeNonceAccountInstruction": + return ("11111111111111111111111111111111", 7) + if name == "SystemProgramAllocateInstruction": + return ("11111111111111111111111111111111", 8) + if name == "SystemProgramAllocateWithSeedInstruction": + return ("11111111111111111111111111111111", 9) + if name == "SystemProgramAssignWithSeedInstruction": + return ("11111111111111111111111111111111", 10) + if name == "SystemProgramTransferWithSeedInstruction": + return ("11111111111111111111111111111111", 11) + if name == "SystemProgramUpgradeNonceAccountInstruction": + return ("11111111111111111111111111111111", 12) + if name == "StakeProgramInitializeInstruction": + return ("Stake11111111111111111111111111111111111111", 0) + if name == "StakeProgramAuthorizeInstruction": + return ("Stake11111111111111111111111111111111111111", 1) + if name == "StakeProgramDelegateStakeInstruction": + return ("Stake11111111111111111111111111111111111111", 2) + if name == "StakeProgramSplitInstruction": + return ("Stake11111111111111111111111111111111111111", 3) + if name == "StakeProgramWithdrawInstruction": + return ("Stake11111111111111111111111111111111111111", 4) + if name == "StakeProgramDeactivateInstruction": + return ("Stake11111111111111111111111111111111111111", 5) + if name == "StakeProgramSetLockupInstruction": + return ("Stake11111111111111111111111111111111111111", 6) + if name == "StakeProgramMergeInstruction": + return ("Stake11111111111111111111111111111111111111", 7) + if name == "StakeProgramAuthorizeWithSeedInstruction": + return ("Stake11111111111111111111111111111111111111", 8) + if name == "StakeProgramInitializeCheckedInstruction": + return ("Stake11111111111111111111111111111111111111", 9) + if name == "StakeProgramAuthorizeCheckedInstruction": + return ("Stake11111111111111111111111111111111111111", 10) + if name == "StakeProgramAuthorizeCheckedWithSeedInstruction": + return ("Stake11111111111111111111111111111111111111", 11) + if name == "StakeProgramSetLockupCheckedInstruction": + return ("Stake11111111111111111111111111111111111111", 12) + if name == "ComputeBudgetProgramRequestHeapFrameInstruction": + return ("ComputeBudget111111111111111111111111111111", 1) + if name == "ComputeBudgetProgramSetComputeUnitLimitInstruction": + return ("ComputeBudget111111111111111111111111111111", 2) + if name == "ComputeBudgetProgramSetComputeUnitPriceInstruction": + return ("ComputeBudget111111111111111111111111111111", 3) + if name == "TokenProgramInitializeAccountInstruction": + return ("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", 1) + if name == "TokenProgramInitializeMultisigInstruction": + return ("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", 2) + if name == "TokenProgramTransferInstruction": + return ("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", 3) + if name == "TokenProgramApproveInstruction": + return ("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", 4) + if name == "TokenProgramRevokeInstruction": + return ("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", 5) + if name == "TokenProgramSetAuthorityInstruction": + return ("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", 6) + if name == "TokenProgramMintToInstruction": + return ("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", 7) + if name == "TokenProgramBurnInstruction": + return ("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", 8) + if name == "TokenProgramCloseAccountInstruction": + return ("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", 9) + if name == "TokenProgramFreezeAccountInstruction": + return ("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", 10) + if name == "TokenProgramThawAccountInstruction": + return ("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", 11) + if name == "TokenProgramTransferCheckedInstruction": + return ("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", 12) + if name == "TokenProgramApproveCheckedInstruction": + return ("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", 13) + if name == "TokenProgramMinttoCheckedInstruction": + return ("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", 14) + if name == "TokenProgramBurnCheckedInstruction": + return ("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", 15) + if name == "TokenProgramInitializeAccount2Instruction": + return ("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", 16) + if name == "TokenProgramSyncNativeInstruction": + return ("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", 17) + if name == "TokenProgramInitializeAccount3Instruction": + return ("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", 18) + if name == "TokenProgramInitializeImmutableOwnerInstruction": + return ("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", 22) + if name == "Token2022ProgramInitializeAccountInstruction": + return ("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb", 1) + if name == "Token2022ProgramInitializeMultisigInstruction": + return ("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb", 2) + if name == "Token2022ProgramTransferInstruction": + return ("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb", 3) + if name == "Token2022ProgramApproveInstruction": + return ("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb", 4) + if name == "Token2022ProgramRevokeInstruction": + return ("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb", 5) + if name == "Token2022ProgramSetAuthorityInstruction": + return ("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb", 6) + if name == "Token2022ProgramMinttoInstruction": + return ("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb", 7) + if name == "Token2022ProgramBurnInstruction": + return ("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb", 8) + if name == "Token2022ProgramCloseAccountInstruction": + return ("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb", 9) + if name == "Token2022ProgramFreezeAccountInstruction": + return ("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb", 10) + if name == "Token2022ProgramThawAccountInstruction": + return ("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb", 11) + if name == "Token2022ProgramTransferCheckedInstruction": + return ("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb", 12) + if name == "Token2022ProgramApproveCheckedInstruction": + return ("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb", 13) + if name == "Token2022ProgramMinttoCheckedInstruction": + return ("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb", 14) + if name == "Token2022ProgramBurnCheckedInstruction": + return ("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb", 15) + if name == "Token2022ProgramInitializeAccount2Instruction": + return ("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb", 16) + if name == "Token2022ProgramSyncNativeInstruction": + return ("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb", 17) + if name == "Token2022ProgramInitializeAccount3Instruction": + return ("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb", 18) + if name == "Token2022ProgramInitializeImmutableOwnerInstruction": + return ("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb", 22) + if name == "AssociatedTokenAccountProgramCreateInstruction": + return ("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL", None) + if name == "AssociatedTokenAccountProgramCreateIdempotentInstruction": + return ("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL", 1) + if name == "AssociatedTokenAccountProgramRecoverNestedInstruction": + return ("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL", 2) + if name == "MemoProgramMemoInstruction": + return ("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr", None) + if name == "MemoLegacyProgramMemoInstruction": + return ("Memo1UhkJRfHyvLMcVucJwxXeuD728EqVDDwQDxFMNo", None) + raise AttributeError # Unknown instruction + + id = get_id(name) + + class FakeClass(Instruction): + @classmethod + def is_type_of(cls, ins: Any): + return ins.program_id == id[0] and ins.instruction_id == id[1] + + return FakeClass + + +if TYPE_CHECKING: + + class SystemProgramCreateAccountInstruction(Instruction): + lamports: int + space: int + owner: Account + + funding_account: Account + new_account: Account + + class SystemProgramAssignInstruction(Instruction): + owner: Account + + assigned_account: Account + + class SystemProgramTransferInstruction(Instruction): + lamports: int + + funding_account: Account + recipient_account: Account + + class SystemProgramCreateAccountWithSeedInstruction(Instruction): + base: int + seed: str + lamports: int + space: int + owner: int + + funding_account: Account + created_account: Account + base_account: Account | None + + class SystemProgramAdvanceNonceAccountInstruction(Instruction): + + nonce_account: Account + recent_blockhashes_sysvar: Account + nonce_authority: Account + + class SystemProgramWithdrawNonceAccountInstruction(Instruction): + lamports: int + + nonce_account: Account + recipient_account: Account + recent_blockhashes_sysvar: Account + rent_sysvar: Account + nonce_authority: Account + + class SystemProgramInitializeNonceAccountInstruction(Instruction): + nonce_authority: Account + + nonce_account: Account + recent_blockhashes_sysvar: Account + rent_sysvar: Account + + class SystemProgramAuthorizeNonceAccountInstruction(Instruction): + nonce_authority: Account + + nonce_account: Account + nonce_authority: Account + + class SystemProgramAllocateInstruction(Instruction): + space: int + + new_account: Account + + class SystemProgramAllocateWithSeedInstruction(Instruction): + base: int + seed: str + space: int + owner: int + + allocated_account: Account + base_account: Account + + class SystemProgramAssignWithSeedInstruction(Instruction): + base: int + seed: str + owner: int + + assigned_account: Account + base_account: Account + + class SystemProgramTransferWithSeedInstruction(Instruction): + lamports: int + from_seed: str + from_owner: int + + funding_account: Account + base_account: Account + recipient_account: Account + + class SystemProgramUpgradeNonceAccountInstruction(Instruction): + + nonce_account: Account + + class StakeProgramInitializeInstruction(Instruction): + staker: Account + withdrawer: Account + unix_timestamp: int + epoch: int + custodian: Account + + uninitialized_stake_account: Account + rent_sysvar: Account + + class StakeProgramAuthorizeInstruction(Instruction): + pubkey: int + stake_authorize: int + + stake_account: Account + clock_sysvar: Account + stake_or_withdraw_authority: Account + lockup_authority: Account | None + + class StakeProgramDelegateStakeInstruction(Instruction): + + initialized_stake_account: Account + vote_account: Account + clock_sysvar: Account + stake_history_sysvar: Account + config_account: Account + stake_authority: Account + + class StakeProgramSplitInstruction(Instruction): + lamports: int + + stake_account: Account + uninitialized_stake_account: Account + stake_authority: Account + + class StakeProgramWithdrawInstruction(Instruction): + lamports: int + + stake_account: Account + recipient_account: Account + clock_sysvar: Account + stake_history_sysvar: Account + withdrawal_authority: Account + lockup_authority: Account | None + + class StakeProgramDeactivateInstruction(Instruction): + + delegated_stake_account: Account + clock_sysvar: Account + stake_authority: Account + + class StakeProgramSetLockupInstruction(Instruction): + unix_timestamp: int + epoch: int + custodian: int + + initialized_stake_account: Account + lockup_or_withdraw_authority: Account + + class StakeProgramMergeInstruction(Instruction): + + destination_stake_account: Account + source_stake_account: Account + clock_sysvar: Account + stake_history_sysvar: Account + stake_authority: Account + + class StakeProgramAuthorizeWithSeedInstruction(Instruction): + new_authorized_pubkey: int + stake_authorize: int + authority_seed: str + authority_owner: int + + stake_account: Account + stake_or_withdraw_authority: Account + clock_sysvar: Account + lockup_authority: Account | None + + class StakeProgramInitializeCheckedInstruction(Instruction): + + uninitialized_stake_account: Account + rent_sysvar: Account + stake_authority: Account + withdrawal_authority: Account + + class StakeProgramAuthorizeCheckedInstruction(Instruction): + stake_authorize: int + + stake_account: Account + clock_sysvar: Account + stake_or_withdraw_authority: Account + new_stake_or_withdraw_authority: Account + lockup_authority: Account | None + + class StakeProgramAuthorizeCheckedWithSeedInstruction(Instruction): + stake_authorize: int + authority_seed: str + authority_owner: int + + stake_account: Account + stake_or_withdraw_authority: Account + clock_sysvar: Account + new_stake_or_withdraw_authority: Account + lockup_authority: Account | None + + class StakeProgramSetLockupCheckedInstruction(Instruction): + unix_timestamp: int + epoch: int + + stake_account: Account + lockup_or_withdraw_authority: Account + new_lockup_authority: Account | None + + class ComputeBudgetProgramRequestHeapFrameInstruction(Instruction): + bytes: int + + class ComputeBudgetProgramSetComputeUnitLimitInstruction(Instruction): + units: int + + class ComputeBudgetProgramSetComputeUnitPriceInstruction(Instruction): + lamports: int + + class TokenProgramInitializeAccountInstruction(Instruction): + + account_to_initialize: Account + mint_account: Account + owner: Account + rent_sysvar: Account + + class TokenProgramInitializeMultisigInstruction(Instruction): + number_of_signers: int + + multisig_account: Account + rent_sysvar: Account + signer_accounts: Account + + class TokenProgramTransferInstruction(Instruction): + amount: int + + source_account: Account + destination_account: Account + owner: Account + + class TokenProgramApproveInstruction(Instruction): + amount: int + + source_account: Account + delegate_account: Account + owner: Account + + class TokenProgramRevokeInstruction(Instruction): + + source_account: Account + owner: Account + + class TokenProgramSetAuthorityInstruction(Instruction): + authority_type: int + new_authority: Account + + mint_account: Account + current_authority: Account + + class TokenProgramMintToInstruction(Instruction): + amount: int + + mint: Account + account_to_mint: Account + minting_authority: Account + + class TokenProgramBurnInstruction(Instruction): + amount: int + + account_to_burn_from: Account + token_mint: Account + owner: Account + + class TokenProgramCloseAccountInstruction(Instruction): + + account_to_close: Account + destination_account: Account + owner: Account + + class TokenProgramFreezeAccountInstruction(Instruction): + + account_to_freeze: Account + token_mint: Account + freeze_authority: Account + + class TokenProgramThawAccountInstruction(Instruction): + + account_to_freeze: Account + token_mint: Account + freeze_authority: Account + + class TokenProgramTransferCheckedInstruction(Instruction): + amount: int + decimals: int + + source_account: Account + token_mint: Account + destination_account: Account + owner: Account + + class TokenProgramApproveCheckedInstruction(Instruction): + amount: int + decimals: int + + source_account: Account + token_mint: Account + delegate: Account + owner: Account + + class TokenProgramMinttoCheckedInstruction(Instruction): + amount: int + decimals: int + + mint: Account + account_to_mint: Account + minting_authority: Account + + class TokenProgramBurnCheckedInstruction(Instruction): + amount: int + decimals: int + + account_to_burn_from: Account + token_mint: Account + owner: Account + + class TokenProgramInitializeAccount2Instruction(Instruction): + owner: int + + account_to_initialize: Account + mint_account: Account + rent_sysvar: Account + + class TokenProgramSyncNativeInstruction(Instruction): + + token_account: Account + + class TokenProgramInitializeAccount3Instruction(Instruction): + owner: int + + account_to_initialize: Account + mint_account: Account + + class TokenProgramInitializeImmutableOwnerInstruction(Instruction): + + account_to_initialize: Account + + class Token2022ProgramInitializeAccountInstruction(Instruction): + + account_to_initialize: Account + mint_account: Account + owner: Account + rent_sysvar: Account + + class Token2022ProgramInitializeMultisigInstruction(Instruction): + number_of_signers: int + + multisig_account: Account + rent_sysvar: Account + signer_accounts: Account + + class Token2022ProgramTransferInstruction(Instruction): + amount: int + + source_account: Account + destination_account: Account + owner: Account + + class Token2022ProgramApproveInstruction(Instruction): + amount: int + + source_account: Account + delegate_account: Account + owner: Account + + class Token2022ProgramRevokeInstruction(Instruction): + + source_account: Account + owner: Account + + class Token2022ProgramSetAuthorityInstruction(Instruction): + authority_type: int + new_authority: Account + + mint_account: Account + current_authority: Account + + class Token2022ProgramMinttoInstruction(Instruction): + amount: int + + mint: Account + account_to_mint: Account + minting_authority: Account + + class Token2022ProgramBurnInstruction(Instruction): + amount: int + + account_to_burn_from: Account + token_mint: Account + owner: Account + + class Token2022ProgramCloseAccountInstruction(Instruction): + + account_to_close: Account + destination_account: Account + owner: Account + + class Token2022ProgramFreezeAccountInstruction(Instruction): + + account_to_freeze: Account + token_mint: Account + freeze_authority: Account + + class Token2022ProgramThawAccountInstruction(Instruction): + + account_to_freeze: Account + token_mint: Account + freeze_authority: Account + + class Token2022ProgramTransferCheckedInstruction(Instruction): + amount: int + decimals: int + + source_account: Account + token_mint: Account + destination_account: Account + owner: Account + + class Token2022ProgramApproveCheckedInstruction(Instruction): + amount: int + decimals: int + + source_account: Account + token_mint: Account + delegate: Account + owner: Account + + class Token2022ProgramMinttoCheckedInstruction(Instruction): + amount: int + decimals: int + + mint: Account + account_to_mint: Account + minting_authority: Account + + class Token2022ProgramBurnCheckedInstruction(Instruction): + amount: int + decimals: int + + account_to_burn_from: Account + token_mint: Account + owner: Account + + class Token2022ProgramInitializeAccount2Instruction(Instruction): + owner: int + + account_to_initialize: Account + mint_account: Account + rent_sysvar: Account + + class Token2022ProgramSyncNativeInstruction(Instruction): + + token_account: Account + + class Token2022ProgramInitializeAccount3Instruction(Instruction): + owner: int + + account_to_initialize: Account + mint_account: Account + + class Token2022ProgramInitializeImmutableOwnerInstruction(Instruction): + + account_to_initialize: Account + + class AssociatedTokenAccountProgramCreateInstruction(Instruction): + + funding_account: Account + associated_token_account: Account + wallet_address: Account + token_mint: Account + system_program: Account + spl_token: Account + + class AssociatedTokenAccountProgramCreateIdempotentInstruction(Instruction): + + funding_account: Account + associated_token_account: Account + wallet_addr: Account + token_mint: Account + system_program: Account + spl_token: Account + + class AssociatedTokenAccountProgramRecoverNestedInstruction(Instruction): + + nested_account: Account + token_mint_nested: Account + associated_token_account: Account + owner: Account + token_mint_owner: Account + wallet_address: Account + spl_token: Account + + class MemoProgramMemoInstruction(Instruction): + memo: str + + signer_accounts: Account | None + + class MemoLegacyProgramMemoInstruction(Instruction): + memo: str + + signer_accounts: Account | None + + +def get_instruction_id_length(program_id: str) -> int: + if program_id == SYSTEM_PROGRAM_ID: + return 4 + if program_id == STAKE_PROGRAM_ID: + return 4 + if program_id == COMPUTE_BUDGET_PROGRAM_ID: + return 1 + if program_id == TOKEN_PROGRAM_ID: + return 1 + if program_id == TOKEN_2022_PROGRAM_ID: + return 1 + if program_id == ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID: + return 1 + if program_id == MEMO_PROGRAM_ID: + return 0 + if program_id == MEMO_LEGACY_PROGRAM_ID: + return 0 + + return 0 + + +def format_StakeAuthorize(_: Instruction, value: int) -> str: + if value == 0: + return "Stake" + if value == 1: + return "Withdraw" + raise DataError("Unknown value") + + +def format_AuthorityType(_: Instruction, value: int) -> str: + if value == 0: + return "Mint tokens" + if value == 1: + return "Freeze account" + if value == 2: + return "Account owner" + if value == 3: + return "Close account" + raise DataError("Unknown value") + + +def get_instruction( + program_id: str, + instruction_id: InstructionId, + instruction_accounts: list[Account], + instruction_data: InstructionData, +) -> Instruction: + if program_id == SYSTEM_PROGRAM_ID: + if instruction_id == SYSTEM_PROGRAM_ID_INS_CREATE_ACCOUNT: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + SYSTEM_PROGRAM_ID_INS_CREATE_ACCOUNT, + [ + PropertyTemplate( + "lamports", + False, + False, + read_uint64_le, + format_lamports, + ), + PropertyTemplate( + "space", + False, + False, + read_uint64_le, + format_int, + ), + PropertyTemplate( + "owner", + True, + False, + parse_pubkey, + format_pubkey, + ), + ], + [ + AccountTemplate( + "funding_account", + True, + False, + ), + AccountTemplate( + "new_account", + False, + False, + ), + ], + [ + UIProperty( + None, + "new_account", + "Create account", + False, + None, + ), + UIProperty( + "lamports", + None, + "Deposit", + False, + None, + ), + UIProperty( + None, + "funding_account", + "From", + False, + None, + ), + ], + "System Program: Create Account", + True, + True, + False, + None, + ) + if instruction_id == SYSTEM_PROGRAM_ID_INS_ASSIGN: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + SYSTEM_PROGRAM_ID_INS_ASSIGN, + [ + PropertyTemplate( + "owner", + True, + False, + parse_pubkey, + format_pubkey, + ), + ], + [ + AccountTemplate( + "assigned_account", + True, + False, + ), + ], + [ + UIProperty( + None, + "assigned_account", + "Assigned account", + False, + None, + ), + UIProperty( + "owner", + None, + "To program", + False, + None, + ), + ], + "System Program: Assign", + True, + True, + False, + None, + ) + if instruction_id == SYSTEM_PROGRAM_ID_INS_TRANSFER: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + SYSTEM_PROGRAM_ID_INS_TRANSFER, + [ + PropertyTemplate( + "lamports", + False, + False, + read_uint64_le, + format_lamports, + ), + ], + [ + AccountTemplate( + "funding_account", + True, + False, + ), + AccountTemplate( + "recipient_account", + False, + False, + ), + ], + [ + UIProperty( + None, + "recipient_account", + "Recipient", + False, + None, + ), + UIProperty( + "lamports", + None, + "Amount", + False, + None, + ), + UIProperty( + None, + "funding_account", + "Sender", + False, + None, + ), + ], + "System Program: Transfer", + True, + True, + False, + None, + ) + if instruction_id == SYSTEM_PROGRAM_ID_INS_CREATE_ACCOUNT_WITH_SEED: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + SYSTEM_PROGRAM_ID_INS_CREATE_ACCOUNT_WITH_SEED, + [ + PropertyTemplate( + "base", + False, + False, + parse_pubkey, + format_pubkey, + ), + PropertyTemplate( + "seed", + False, + False, + parse_string, + format_identity, + ), + PropertyTemplate( + "lamports", + False, + False, + read_uint64_le, + format_lamports, + ), + PropertyTemplate( + "space", + False, + False, + read_uint64_le, + format_int, + ), + PropertyTemplate( + "owner", + False, + False, + parse_pubkey, + format_pubkey, + ), + ], + [ + AccountTemplate( + "funding_account", + True, + False, + ), + AccountTemplate( + "created_account", + False, + False, + ), + AccountTemplate( + "base_account", + True, + True, + ), + ], + [ + UIProperty( + None, + "created_account", + "Create account", + False, + None, + ), + UIProperty( + "lamports", + None, + "Deposit", + False, + None, + ), + UIProperty( + None, + "funding_account", + "From", + False, + None, + ), + ], + "System Program: Create Account With Seed", + True, + True, + False, + None, + ) + if instruction_id == SYSTEM_PROGRAM_ID_INS_ADVANCE_NONCE_ACCOUNT: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + SYSTEM_PROGRAM_ID_INS_ADVANCE_NONCE_ACCOUNT, + [], + [ + AccountTemplate( + "nonce_account", + False, + False, + ), + AccountTemplate( + "recent_blockhashes_sysvar", + False, + False, + ), + AccountTemplate( + "nonce_authority", + True, + False, + ), + ], + [ + UIProperty( + None, + "nonce_account", + "Advance nonce", + False, + None, + ), + UIProperty( + None, + "nonce_authority", + "Authorized by", + False, + None, + ), + ], + "System Program: Advance Nonce Account", + True, + True, + False, + None, + ) + if instruction_id == SYSTEM_PROGRAM_ID_INS_WITHDRAW_NONCE_ACCOUNT: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + SYSTEM_PROGRAM_ID_INS_WITHDRAW_NONCE_ACCOUNT, + [ + PropertyTemplate( + "lamports", + False, + False, + read_uint64_le, + format_lamports, + ), + ], + [ + AccountTemplate( + "nonce_account", + False, + False, + ), + AccountTemplate( + "recipient_account", + False, + False, + ), + AccountTemplate( + "recent_blockhashes_sysvar", + False, + False, + ), + AccountTemplate( + "rent_sysvar", + False, + False, + ), + AccountTemplate( + "nonce_authority", + True, + False, + ), + ], + [ + UIProperty( + "lamports", + None, + "Nonce withdraw", + False, + None, + ), + UIProperty( + None, + "nonce_account", + "From", + False, + None, + ), + UIProperty( + None, + "recipient_account", + "To", + False, + None, + ), + UIProperty( + None, + "nonce_authority", + "Authorized by", + False, + None, + ), + ], + "System Program: Withdraw Nonce Account", + True, + True, + False, + None, + ) + if instruction_id == SYSTEM_PROGRAM_ID_INS_INITIALIZE_NONCE_ACCOUNT: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + SYSTEM_PROGRAM_ID_INS_INITIALIZE_NONCE_ACCOUNT, + [ + PropertyTemplate( + "nonce_authority", + True, + False, + parse_pubkey, + format_pubkey, + ), + ], + [ + AccountTemplate( + "nonce_account", + False, + False, + ), + AccountTemplate( + "recent_blockhashes_sysvar", + False, + False, + ), + AccountTemplate( + "rent_sysvar", + False, + False, + ), + ], + [ + UIProperty( + None, + "nonce_account", + "Initialize nonce account", + False, + None, + ), + UIProperty( + "nonce_authority", + None, + "New authority", + False, + None, + ), + ], + "System Program: Initialize Nonce Account", + True, + True, + False, + None, + ) + if instruction_id == SYSTEM_PROGRAM_ID_INS_AUTHORIZE_NONCE_ACCOUNT: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + SYSTEM_PROGRAM_ID_INS_AUTHORIZE_NONCE_ACCOUNT, + [ + PropertyTemplate( + "nonce_authority", + True, + False, + parse_pubkey, + format_pubkey, + ), + ], + [ + AccountTemplate( + "nonce_account", + False, + False, + ), + AccountTemplate( + "nonce_authority", + True, + False, + ), + ], + [ + UIProperty( + None, + "nonce_account", + "Set nonce authority", + False, + None, + ), + UIProperty( + "nonce_authority", + None, + "New authority", + False, + None, + ), + UIProperty( + None, + "nonce_authority", + "Authorized by", + False, + None, + ), + ], + "System Program: Authorize Nonce Account", + True, + True, + False, + None, + ) + if instruction_id == SYSTEM_PROGRAM_ID_INS_ALLOCATE: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + SYSTEM_PROGRAM_ID_INS_ALLOCATE, + [ + PropertyTemplate( + "space", + False, + False, + read_uint64_le, + format_int, + ), + ], + [ + AccountTemplate( + "new_account", + True, + False, + ), + ], + [ + UIProperty( + None, + "new_account", + "Allocate account", + False, + None, + ), + UIProperty( + "space", + None, + "Data size", + False, + None, + ), + ], + "System Program: Allocate", + True, + True, + False, + None, + ) + if instruction_id == SYSTEM_PROGRAM_ID_INS_ALLOCATE_WITH_SEED: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + SYSTEM_PROGRAM_ID_INS_ALLOCATE_WITH_SEED, + [ + PropertyTemplate( + "base", + False, + False, + parse_pubkey, + format_pubkey, + ), + PropertyTemplate( + "seed", + False, + False, + parse_string, + format_identity, + ), + PropertyTemplate( + "space", + False, + False, + read_uint64_le, + format_int, + ), + PropertyTemplate( + "owner", + False, + False, + parse_pubkey, + format_pubkey, + ), + ], + [ + AccountTemplate( + "allocated_account", + False, + False, + ), + AccountTemplate( + "base_account", + True, + False, + ), + ], + [ + UIProperty( + None, + "allocated_account", + "Allocate account", + False, + None, + ), + UIProperty( + "space", + None, + "Data size", + False, + None, + ), + ], + "System Program: Allocate With Seed", + True, + True, + False, + None, + ) + if instruction_id == SYSTEM_PROGRAM_ID_INS_ASSIGN_WITH_SEED: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + SYSTEM_PROGRAM_ID_INS_ASSIGN_WITH_SEED, + [ + PropertyTemplate( + "base", + False, + False, + parse_pubkey, + format_pubkey, + ), + PropertyTemplate( + "seed", + False, + False, + parse_string, + format_identity, + ), + PropertyTemplate( + "owner", + False, + False, + parse_pubkey, + format_pubkey, + ), + ], + [ + AccountTemplate( + "assigned_account", + False, + False, + ), + AccountTemplate( + "base_account", + True, + False, + ), + ], + [ + UIProperty( + None, + "assigned_account", + "Assigned account", + False, + None, + ), + UIProperty( + "owner", + None, + "To program", + False, + None, + ), + ], + "System Program: Assign With Seed", + True, + True, + False, + None, + ) + if instruction_id == SYSTEM_PROGRAM_ID_INS_TRANSFER_WITH_SEED: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + SYSTEM_PROGRAM_ID_INS_TRANSFER_WITH_SEED, + [ + PropertyTemplate( + "lamports", + False, + False, + read_uint64_le, + format_lamports, + ), + PropertyTemplate( + "from_seed", + False, + False, + parse_string, + format_identity, + ), + PropertyTemplate( + "from_owner", + False, + False, + parse_pubkey, + format_pubkey, + ), + ], + [ + AccountTemplate( + "funding_account", + False, + False, + ), + AccountTemplate( + "base_account", + True, + False, + ), + AccountTemplate( + "recipient_account", + False, + False, + ), + ], + [ + UIProperty( + None, + "recipient_account", + "Recipient", + False, + None, + ), + UIProperty( + "lamports", + None, + "Amount", + False, + None, + ), + UIProperty( + None, + "funding_account", + "Sender", + False, + None, + ), + ], + "System Program: Transfer With Seed", + True, + True, + False, + None, + ) + if instruction_id == SYSTEM_PROGRAM_ID_INS_UPGRADE_NONCE_ACCOUNT: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + SYSTEM_PROGRAM_ID_INS_UPGRADE_NONCE_ACCOUNT, + [], + [ + AccountTemplate( + "nonce_account", + False, + False, + ), + ], + [ + UIProperty( + None, + "nonce_account", + "Upgrade nonce account", + False, + None, + ), + ], + "System Program: Upgrade Nonce Account", + True, + True, + False, + None, + ) + return Instruction( + instruction_data, + program_id, + instruction_accounts, + instruction_id, + [], + [], + [], + "System Program", + True, + False, + False, + ) + if program_id == STAKE_PROGRAM_ID: + if instruction_id == STAKE_PROGRAM_ID_INS_INITIALIZE: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + STAKE_PROGRAM_ID_INS_INITIALIZE, + [ + PropertyTemplate( + "staker", + True, + False, + parse_pubkey, + format_pubkey, + ), + PropertyTemplate( + "withdrawer", + True, + False, + parse_pubkey, + format_pubkey, + ), + PropertyTemplate( + "unix_timestamp", + False, + False, + read_uint64_le, + format_unix_timestamp, + ), + PropertyTemplate( + "epoch", + False, + False, + read_uint64_le, + format_int, + ), + PropertyTemplate( + "custodian", + True, + False, + parse_pubkey, + format_pubkey, + ), + ], + [ + AccountTemplate( + "uninitialized_stake_account", + False, + False, + ), + AccountTemplate( + "rent_sysvar", + False, + False, + ), + ], + [ + UIProperty( + None, + "uninitialized_stake_account", + "Initialize stake account", + False, + None, + ), + UIProperty( + "staker", + None, + "New stake authority", + False, + None, + ), + UIProperty( + "withdrawer", + None, + "New withdraw authority", + False, + None, + ), + UIProperty( + "unix_timestamp", + None, + "Lockup time", + False, + 0, + ), + UIProperty( + "epoch", + None, + "Lockup epoch", + False, + 0, + ), + UIProperty( + "custodian", + None, + "Lockup authority", + False, + None, + ), + ], + "Stake Program: Initialize", + True, + True, + False, + None, + ) + if instruction_id == STAKE_PROGRAM_ID_INS_AUTHORIZE: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + STAKE_PROGRAM_ID_INS_AUTHORIZE, + [ + PropertyTemplate( + "pubkey", + False, + False, + parse_pubkey, + format_pubkey, + ), + PropertyTemplate( + "stake_authorize", + False, + False, + read_uint32_le, + format_StakeAuthorize, + ), + ], + [ + AccountTemplate( + "stake_account", + False, + False, + ), + AccountTemplate( + "clock_sysvar", + False, + False, + ), + AccountTemplate( + "stake_or_withdraw_authority", + True, + False, + ), + AccountTemplate( + "lockup_authority", + True, + True, + ), + ], + [ + UIProperty( + None, + "stake_account", + "Set stake authority for", + False, + None, + ), + UIProperty( + "pubkey", + None, + "New authority", + False, + None, + ), + UIProperty( + "stake_authorize", + None, + "Authority type", + False, + None, + ), + UIProperty( + None, + "stake_or_withdraw_authority", + "Authorized by", + False, + None, + ), + UIProperty( + None, + "lockup_authority", + "Custodian", + False, + None, + ), + ], + "Stake Program: Authorize", + True, + True, + False, + None, + ) + if instruction_id == STAKE_PROGRAM_ID_INS_DELEGATE_STAKE: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + STAKE_PROGRAM_ID_INS_DELEGATE_STAKE, + [], + [ + AccountTemplate( + "initialized_stake_account", + False, + False, + ), + AccountTemplate( + "vote_account", + False, + False, + ), + AccountTemplate( + "clock_sysvar", + False, + False, + ), + AccountTemplate( + "stake_history_sysvar", + False, + False, + ), + AccountTemplate( + "config_account", + False, + False, + ), + AccountTemplate( + "stake_authority", + True, + False, + ), + ], + [ + UIProperty( + None, + "initialized_stake_account", + "Delegate from", + False, + None, + ), + UIProperty( + None, + "stake_authority", + "Authorized by", + False, + None, + ), + UIProperty( + None, + "vote_account", + "Vote account", + False, + None, + ), + ], + "Stake Program: Delegate Stake", + True, + True, + False, + None, + ) + if instruction_id == STAKE_PROGRAM_ID_INS_SPLIT: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + STAKE_PROGRAM_ID_INS_SPLIT, + [ + PropertyTemplate( + "lamports", + False, + False, + read_uint64_le, + format_lamports, + ), + ], + [ + AccountTemplate( + "stake_account", + False, + False, + ), + AccountTemplate( + "uninitialized_stake_account", + False, + False, + ), + AccountTemplate( + "stake_authority", + True, + False, + ), + ], + [ + UIProperty( + "lamports", + None, + "Split stake", + False, + None, + ), + UIProperty( + None, + "stake_account", + "From", + False, + None, + ), + UIProperty( + None, + "uninitialized_stake_account", + "To", + False, + None, + ), + UIProperty( + None, + "stake_authority", + "Authorized by", + False, + None, + ), + ], + "Stake Program: Split", + True, + True, + False, + None, + ) + if instruction_id == STAKE_PROGRAM_ID_INS_WITHDRAW: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + STAKE_PROGRAM_ID_INS_WITHDRAW, + [ + PropertyTemplate( + "lamports", + False, + False, + read_uint64_le, + format_lamports, + ), + ], + [ + AccountTemplate( + "stake_account", + False, + False, + ), + AccountTemplate( + "recipient_account", + False, + False, + ), + AccountTemplate( + "clock_sysvar", + False, + False, + ), + AccountTemplate( + "stake_history_sysvar", + False, + False, + ), + AccountTemplate( + "withdrawal_authority", + True, + False, + ), + AccountTemplate( + "lockup_authority", + True, + True, + ), + ], + [ + UIProperty( + "lamports", + None, + "Stake withdraw", + False, + None, + ), + UIProperty( + None, + "stake_account", + "From", + False, + None, + ), + UIProperty( + None, + "recipient_account", + "To", + False, + None, + ), + UIProperty( + None, + "withdrawal_authority", + "Authorized by", + False, + None, + ), + ], + "Stake Program: Withdraw", + True, + True, + False, + None, + ) + if instruction_id == STAKE_PROGRAM_ID_INS_DEACTIVATE: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + STAKE_PROGRAM_ID_INS_DEACTIVATE, + [], + [ + AccountTemplate( + "delegated_stake_account", + False, + False, + ), + AccountTemplate( + "clock_sysvar", + False, + False, + ), + AccountTemplate( + "stake_authority", + True, + False, + ), + ], + [ + UIProperty( + None, + "delegated_stake_account", + "Deactivate stake", + False, + None, + ), + UIProperty( + None, + "stake_authority", + "Authorized by", + False, + None, + ), + ], + "Stake Program: Deactivate", + True, + True, + False, + None, + ) + if instruction_id == STAKE_PROGRAM_ID_INS_SET_LOCKUP: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + STAKE_PROGRAM_ID_INS_SET_LOCKUP, + [ + PropertyTemplate( + "unix_timestamp", + False, + True, + read_uint64_le, + format_unix_timestamp, + ), + PropertyTemplate( + "epoch", + False, + True, + read_uint64_le, + format_int, + ), + PropertyTemplate( + "custodian", + False, + True, + parse_pubkey, + format_pubkey, + ), + ], + [ + AccountTemplate( + "initialized_stake_account", + False, + False, + ), + AccountTemplate( + "lockup_or_withdraw_authority", + True, + False, + ), + ], + [ + UIProperty( + None, + "initialized_stake_account", + "Set lockup for account", + False, + None, + ), + UIProperty( + "unix_timestamp", + None, + "Time", + False, + 0, + ), + UIProperty( + "epoch", + None, + "Epoch", + False, + 0, + ), + UIProperty( + "custodian", + None, + "New lockup authority", + False, + None, + ), + UIProperty( + None, + "lockup_or_withdraw_authority", + "Authorized by", + False, + None, + ), + ], + "Stake Program: Set Lockup", + True, + True, + False, + None, + ) + if instruction_id == STAKE_PROGRAM_ID_INS_MERGE: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + STAKE_PROGRAM_ID_INS_MERGE, + [], + [ + AccountTemplate( + "destination_stake_account", + False, + False, + ), + AccountTemplate( + "source_stake_account", + False, + False, + ), + AccountTemplate( + "clock_sysvar", + False, + False, + ), + AccountTemplate( + "stake_history_sysvar", + False, + False, + ), + AccountTemplate( + "stake_authority", + True, + False, + ), + ], + [ + UIProperty( + None, + "source_stake_account", + "Merge", + False, + None, + ), + UIProperty( + None, + "destination_stake_account", + "Into", + False, + None, + ), + UIProperty( + None, + "stake_authority", + "Authorized by", + False, + None, + ), + ], + "Stake Program: Merge", + True, + True, + False, + None, + ) + if instruction_id == STAKE_PROGRAM_ID_INS_AUTHORIZE_WITH_SEED: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + STAKE_PROGRAM_ID_INS_AUTHORIZE_WITH_SEED, + [ + PropertyTemplate( + "new_authorized_pubkey", + False, + False, + parse_pubkey, + format_pubkey, + ), + PropertyTemplate( + "stake_authorize", + False, + False, + read_uint32_le, + format_StakeAuthorize, + ), + PropertyTemplate( + "authority_seed", + False, + False, + parse_string, + format_identity, + ), + PropertyTemplate( + "authority_owner", + False, + False, + parse_pubkey, + format_pubkey, + ), + ], + [ + AccountTemplate( + "stake_account", + False, + False, + ), + AccountTemplate( + "stake_or_withdraw_authority", + True, + False, + ), + AccountTemplate( + "clock_sysvar", + False, + False, + ), + AccountTemplate( + "lockup_authority", + True, + True, + ), + ], + [ + UIProperty( + None, + "stake_account", + "Set stake auth", + False, + None, + ), + UIProperty( + "new_authorized_pubkey", + None, + "New (stake/withdraw) auth", + False, + None, + ), + UIProperty( + None, + "stake_or_withdraw_authority", + "Authorized by", + False, + None, + ), + UIProperty( + None, + "lockup_authority", + "Custodian", + False, + None, + ), + ], + "Stake Program: Authorize With Seed", + True, + True, + False, + None, + ) + if instruction_id == STAKE_PROGRAM_ID_INS_INITIALIZE_CHECKED: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + STAKE_PROGRAM_ID_INS_INITIALIZE_CHECKED, + [], + [ + AccountTemplate( + "uninitialized_stake_account", + False, + False, + ), + AccountTemplate( + "rent_sysvar", + False, + False, + ), + AccountTemplate( + "stake_authority", + False, + False, + ), + AccountTemplate( + "withdrawal_authority", + True, + False, + ), + ], + [ + UIProperty( + None, + "uninitialized_stake_account", + "Uninitialized stake account", + False, + None, + ), + UIProperty( + None, + "stake_authority", + "New stake authority", + False, + None, + ), + UIProperty( + None, + "withdrawal_authority", + "New withdraw authority", + False, + None, + ), + ], + "Stake Program: Initialize Checked", + True, + True, + False, + None, + ) + if instruction_id == STAKE_PROGRAM_ID_INS_AUTHORIZE_CHECKED: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + STAKE_PROGRAM_ID_INS_AUTHORIZE_CHECKED, + [ + PropertyTemplate( + "stake_authorize", + False, + False, + read_uint32_le, + format_StakeAuthorize, + ), + ], + [ + AccountTemplate( + "stake_account", + False, + False, + ), + AccountTemplate( + "clock_sysvar", + False, + False, + ), + AccountTemplate( + "stake_or_withdraw_authority", + True, + False, + ), + AccountTemplate( + "new_stake_or_withdraw_authority", + True, + False, + ), + AccountTemplate( + "lockup_authority", + True, + True, + ), + ], + [ + UIProperty( + None, + "stake_account", + "Set stake auth", + False, + None, + ), + UIProperty( + None, + "stake_or_withdraw_authority", + "Stake or withdraw authority", + False, + None, + ), + UIProperty( + None, + "new_stake_or_withdraw_authority", + "New stake or withdraw authority", + False, + None, + ), + ], + "Stake Program: Authorize Checked", + True, + True, + False, + None, + ) + if instruction_id == STAKE_PROGRAM_ID_INS_AUTHORIZE_CHECKED_WITH_SEED: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + STAKE_PROGRAM_ID_INS_AUTHORIZE_CHECKED_WITH_SEED, + [ + PropertyTemplate( + "stake_authorize", + False, + False, + read_uint32_le, + format_StakeAuthorize, + ), + PropertyTemplate( + "authority_seed", + False, + False, + parse_string, + format_identity, + ), + PropertyTemplate( + "authority_owner", + False, + False, + parse_pubkey, + format_pubkey, + ), + ], + [ + AccountTemplate( + "stake_account", + False, + False, + ), + AccountTemplate( + "stake_or_withdraw_authority", + True, + False, + ), + AccountTemplate( + "clock_sysvar", + False, + False, + ), + AccountTemplate( + "new_stake_or_withdraw_authority", + True, + False, + ), + AccountTemplate( + "lockup_authority", + True, + True, + ), + ], + [ + UIProperty( + None, + "stake_account", + "Set authority for stake account", + 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", + "Authorized by", + False, + None, + ), + UIProperty( + None, + "lockup_authority", + "Custodian", + False, + None, + ), + ], + "Stake Program: Authorize Checked With Seed", + True, + True, + False, + None, + ) + if instruction_id == STAKE_PROGRAM_ID_INS_SET_LOCKUP_CHECKED: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + STAKE_PROGRAM_ID_INS_SET_LOCKUP_CHECKED, + [ + PropertyTemplate( + "unix_timestamp", + False, + True, + read_uint64_le, + format_unix_timestamp, + ), + PropertyTemplate( + "epoch", + False, + True, + read_uint64_le, + format_int, + ), + ], + [ + AccountTemplate( + "stake_account", + False, + False, + ), + AccountTemplate( + "lockup_or_withdraw_authority", + True, + False, + ), + AccountTemplate( + "new_lockup_authority", + True, + True, + ), + ], + [ + UIProperty( + None, + "stake_account", + "Set lockup for stake account", + False, + None, + ), + UIProperty( + "unix_timestamp", + None, + "Time", + False, + 0, + ), + UIProperty( + "epoch", + None, + "Epoch", + False, + 0, + ), + UIProperty( + None, + "new_lockup_authority", + "New lockup authority", + False, + None, + ), + UIProperty( + None, + "lockup_or_withdraw_authority", + "Authorized by", + False, + None, + ), + ], + "Stake Program: Set Lockup Checked", + True, + True, + False, + None, + ) + return Instruction( + instruction_data, + program_id, + instruction_accounts, + instruction_id, + [], + [], + [], + "Stake Program", + True, + False, + False, + ) + if program_id == COMPUTE_BUDGET_PROGRAM_ID: + if instruction_id == COMPUTE_BUDGET_PROGRAM_ID_INS_REQUEST_HEAP_FRAME: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + COMPUTE_BUDGET_PROGRAM_ID_INS_REQUEST_HEAP_FRAME, + [ + PropertyTemplate( + "bytes", + False, + False, + read_uint32_le, + format_int, + ), + ], + [], + [ + UIProperty( + "bytes", + None, + "Bytes", + False, + None, + ), + ], + "Compute Budget Program: Request Heap Frame", + True, + True, + False, + None, + ) + if instruction_id == COMPUTE_BUDGET_PROGRAM_ID_INS_SET_COMPUTE_UNIT_LIMIT: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + COMPUTE_BUDGET_PROGRAM_ID_INS_SET_COMPUTE_UNIT_LIMIT, + [ + PropertyTemplate( + "units", + False, + False, + read_uint32_le, + format_int, + ), + ], + [], + [ + UIProperty( + "units", + None, + "Units", + False, + None, + ), + ], + "Compute Budget Program: Set Compute Unit Limit", + True, + True, + False, + None, + ) + if instruction_id == COMPUTE_BUDGET_PROGRAM_ID_INS_SET_COMPUTE_UNIT_PRICE: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + COMPUTE_BUDGET_PROGRAM_ID_INS_SET_COMPUTE_UNIT_PRICE, + [ + PropertyTemplate( + "lamports", + False, + False, + read_uint64_le, + format_int, + ), + ], + [], + [ + UIProperty( + "lamports", + None, + "Compute unit price", + False, + None, + ), + ], + "Compute Budget Program: Set Compute Unit Price", + True, + True, + False, + None, + ) + return Instruction( + instruction_data, + program_id, + instruction_accounts, + instruction_id, + [], + [], + [], + "Compute Budget Program", + True, + False, + False, + ) + if program_id == TOKEN_PROGRAM_ID: + if instruction_id == TOKEN_PROGRAM_ID_INS_INITIALIZE_ACCOUNT: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_PROGRAM_ID_INS_INITIALIZE_ACCOUNT, + [], + [ + AccountTemplate( + "account_to_initialize", + False, + False, + ), + AccountTemplate( + "mint_account", + False, + False, + ), + AccountTemplate( + "owner", + False, + False, + ), + AccountTemplate( + "rent_sysvar", + False, + False, + ), + ], + [ + UIProperty( + None, + "account_to_initialize", + "Init account", + False, + None, + ), + UIProperty( + None, + "owner", + "Owner", + False, + None, + ), + UIProperty( + None, + "mint_account", + "Mint", + False, + None, + ), + ], + "Token Program: Initialize Account", + True, + True, + False, + None, + ) + if instruction_id == TOKEN_PROGRAM_ID_INS_INITIALIZE_MULTISIG: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_PROGRAM_ID_INS_INITIALIZE_MULTISIG, + [ + PropertyTemplate( + "number_of_signers", + False, + False, + parse_byte, + format_int, + ), + ], + [ + AccountTemplate( + "multisig_account", + False, + False, + ), + AccountTemplate( + "rent_sysvar", + False, + False, + ), + AccountTemplate( + "signer_accounts", + False, + False, + ), + ], + [ + UIProperty( + None, + "multisig_account", + "Init multisig", + False, + None, + ), + UIProperty( + None, + "signer_accounts", + "Required signers", + False, + None, + ), + ], + "Token Program: Initialize Multisig", + True, + True, + True, + None, + ) + if instruction_id == TOKEN_PROGRAM_ID_INS_TRANSFER: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_PROGRAM_ID_INS_TRANSFER, + [ + PropertyTemplate( + "amount", + False, + False, + read_uint64_le, + format_int, + ), + ], + [ + AccountTemplate( + "source_account", + False, + False, + ), + AccountTemplate( + "destination_account", + False, + False, + ), + AccountTemplate( + "owner", + True, + False, + ), + ], + [ + UIProperty( + None, + "destination_account", + "Recipient", + False, + None, + ), + UIProperty( + "amount", + None, + "Amount", + False, + None, + ), + UIProperty( + None, + "source_account", + "From", + False, + None, + ), + UIProperty( + None, + "owner", + "Owner", + False, + None, + ), + ], + "Token Program: Transfer", + True, + True, + True, + "Warning: Instruction is deprecated. Token decimals unknown.", + ) + if instruction_id == TOKEN_PROGRAM_ID_INS_APPROVE: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_PROGRAM_ID_INS_APPROVE, + [ + PropertyTemplate( + "amount", + False, + False, + read_uint64_le, + format_int, + ), + ], + [ + AccountTemplate( + "source_account", + False, + False, + ), + AccountTemplate( + "delegate_account", + False, + False, + ), + AccountTemplate( + "owner", + True, + False, + ), + ], + [ + UIProperty( + None, + "delegate_account", + "Approve delegate", + False, + None, + ), + UIProperty( + "amount", + None, + "Allowance", + False, + None, + ), + UIProperty( + None, + "owner", + "Owner", + False, + None, + ), + ], + "Token Program: Approve", + True, + True, + True, + "Warning: Instruction is deprecated. Token decimals unknown.", + ) + if instruction_id == TOKEN_PROGRAM_ID_INS_REVOKE: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_PROGRAM_ID_INS_REVOKE, + [], + [ + AccountTemplate( + "source_account", + False, + False, + ), + AccountTemplate( + "owner", + True, + False, + ), + ], + [ + UIProperty( + None, + "source_account", + "Rewoke delegate", + False, + None, + ), + UIProperty( + None, + "owner", + "Owner", + False, + None, + ), + ], + "Token Program: Revoke", + True, + True, + True, + None, + ) + if instruction_id == TOKEN_PROGRAM_ID_INS_SET_AUTHORITY: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_PROGRAM_ID_INS_SET_AUTHORITY, + [ + PropertyTemplate( + "authority_type", + False, + False, + parse_byte, + format_AuthorityType, + ), + PropertyTemplate( + "new_authority", + True, + True, + parse_pubkey, + format_pubkey, + ), + ], + [ + AccountTemplate( + "mint_account", + False, + False, + ), + AccountTemplate( + "current_authority", + True, + False, + ), + ], + [ + UIProperty( + None, + "mint_account", + "Set authority for", + False, + None, + ), + UIProperty( + "new_authority", + None, + "New authority", + False, + None, + ), + UIProperty( + "authority_type", + None, + "Authority type", + False, + None, + ), + UIProperty( + None, + "current_authority", + "Current authority", + False, + None, + ), + ], + "Token Program: Set Authority", + True, + True, + True, + None, + ) + if instruction_id == TOKEN_PROGRAM_ID_INS_MINT_TO: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_PROGRAM_ID_INS_MINT_TO, + [ + PropertyTemplate( + "amount", + False, + False, + read_uint64_le, + format_int, + ), + ], + [ + AccountTemplate( + "mint", + False, + False, + ), + AccountTemplate( + "account_to_mint", + False, + False, + ), + AccountTemplate( + "minting_authority", + True, + False, + ), + ], + [ + UIProperty( + "amount", + None, + "Mint tokens", + False, + None, + ), + UIProperty( + None, + "account_to_mint", + "To", + False, + None, + ), + UIProperty( + None, + "minting_authority", + "Mint authority", + False, + None, + ), + ], + "Token Program: Mint To", + True, + True, + True, + "Warning: Instruction is deprecated. Token decimals unknown.", + ) + if instruction_id == TOKEN_PROGRAM_ID_INS_BURN: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_PROGRAM_ID_INS_BURN, + [ + PropertyTemplate( + "amount", + False, + False, + read_uint64_le, + format_int, + ), + ], + [ + AccountTemplate( + "account_to_burn_from", + False, + False, + ), + AccountTemplate( + "token_mint", + False, + False, + ), + AccountTemplate( + "owner", + True, + False, + ), + ], + [ + UIProperty( + "amount", + None, + "Burn tokens", + False, + None, + ), + UIProperty( + None, + "account_to_burn_from", + "From", + False, + None, + ), + UIProperty( + None, + "owner", + "Mint authority", + False, + None, + ), + ], + "Token Program: Burn", + True, + True, + True, + "Warning: Instruction is deprecated. Token decimals unknown.", + ) + if instruction_id == TOKEN_PROGRAM_ID_INS_CLOSE_ACCOUNT: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_PROGRAM_ID_INS_CLOSE_ACCOUNT, + [], + [ + AccountTemplate( + "account_to_close", + False, + False, + ), + AccountTemplate( + "destination_account", + False, + False, + ), + AccountTemplate( + "owner", + True, + False, + ), + ], + [ + UIProperty( + None, + "account_to_close", + "Close account", + False, + None, + ), + UIProperty( + None, + "destination_account", + "Withdraw to", + False, + None, + ), + UIProperty( + None, + "owner", + "Owner", + False, + None, + ), + ], + "Token Program: Close Account", + True, + True, + True, + None, + ) + if instruction_id == TOKEN_PROGRAM_ID_INS_FREEZE_ACCOUNT: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_PROGRAM_ID_INS_FREEZE_ACCOUNT, + [], + [ + AccountTemplate( + "account_to_freeze", + False, + False, + ), + AccountTemplate( + "token_mint", + False, + False, + ), + AccountTemplate( + "freeze_authority", + True, + False, + ), + ], + [ + UIProperty( + None, + "account_to_freeze", + "Freeze account", + False, + None, + ), + UIProperty( + None, + "freeze_authority", + "Owner", + False, + None, + ), + ], + "Token Program: Freeze Account", + True, + True, + True, + None, + ) + if instruction_id == TOKEN_PROGRAM_ID_INS_THAW_ACCOUNT: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_PROGRAM_ID_INS_THAW_ACCOUNT, + [], + [ + AccountTemplate( + "account_to_freeze", + False, + False, + ), + AccountTemplate( + "token_mint", + False, + False, + ), + AccountTemplate( + "freeze_authority", + True, + False, + ), + ], + [ + UIProperty( + None, + "account_to_freeze", + "Thaw account", + False, + None, + ), + UIProperty( + None, + "freeze_authority", + "Owner", + False, + None, + ), + ], + "Token Program: Thaw Account", + True, + True, + True, + None, + ) + if instruction_id == TOKEN_PROGRAM_ID_INS_TRANSFER_CHECKED: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_PROGRAM_ID_INS_TRANSFER_CHECKED, + [ + PropertyTemplate( + "amount", + False, + False, + read_uint64_le, + format_token_amount, + ), + PropertyTemplate( + "decimals", + False, + False, + parse_byte, + format_int, + ), + ], + [ + AccountTemplate( + "source_account", + False, + False, + ), + AccountTemplate( + "token_mint", + False, + False, + ), + AccountTemplate( + "destination_account", + False, + False, + ), + AccountTemplate( + "owner", + True, + False, + ), + ], + [ + UIProperty( + None, + "token_mint", + "Token", + False, + None, + ), + UIProperty( + None, + "destination_account", + "Recipient", + False, + None, + ), + UIProperty( + "amount", + None, + "Amount", + False, + None, + ), + UIProperty( + None, + "source_account", + "From", + False, + None, + ), + UIProperty( + None, + "owner", + "Owner", + False, + None, + ), + ], + "Token Program: Transfer Checked", + True, + True, + True, + None, + ) + if instruction_id == TOKEN_PROGRAM_ID_INS_APPROVE_CHECKED: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_PROGRAM_ID_INS_APPROVE_CHECKED, + [ + PropertyTemplate( + "amount", + False, + False, + read_uint64_le, + format_token_amount, + ), + PropertyTemplate( + "decimals", + False, + False, + parse_byte, + format_int, + ), + ], + [ + AccountTemplate( + "source_account", + False, + False, + ), + AccountTemplate( + "token_mint", + False, + False, + ), + AccountTemplate( + "delegate", + False, + False, + ), + AccountTemplate( + "owner", + True, + False, + ), + ], + [ + UIProperty( + None, + "token_mint", + "Approve token", + False, + None, + ), + UIProperty( + None, + "delegate", + "Approve delegate", + False, + None, + ), + UIProperty( + "amount", + None, + "Allowance", + False, + None, + ), + UIProperty( + None, + "source_account", + "From", + False, + None, + ), + UIProperty( + None, + "owner", + "Owner", + False, + None, + ), + ], + "Token Program: Approve Checked", + True, + True, + True, + None, + ) + if instruction_id == TOKEN_PROGRAM_ID_INS_MINT_TO_CHECKED: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_PROGRAM_ID_INS_MINT_TO_CHECKED, + [ + PropertyTemplate( + "amount", + False, + False, + read_uint64_le, + format_token_amount, + ), + PropertyTemplate( + "decimals", + False, + False, + parse_byte, + format_int, + ), + ], + [ + AccountTemplate( + "mint", + False, + False, + ), + AccountTemplate( + "account_to_mint", + False, + False, + ), + AccountTemplate( + "minting_authority", + True, + False, + ), + ], + [ + UIProperty( + None, + "mint", + "Mint token", + False, + None, + ), + UIProperty( + "amount", + None, + "Mint amount", + False, + None, + ), + UIProperty( + None, + "account_to_mint", + "To", + False, + None, + ), + UIProperty( + None, + "minting_authority", + "Owner", + False, + None, + ), + ], + "Token Program: Mint to Checked", + True, + True, + True, + None, + ) + if instruction_id == TOKEN_PROGRAM_ID_INS_BURN_CHECKED: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_PROGRAM_ID_INS_BURN_CHECKED, + [ + PropertyTemplate( + "amount", + False, + False, + read_uint64_le, + format_token_amount, + ), + PropertyTemplate( + "decimals", + False, + False, + parse_byte, + format_int, + ), + ], + [ + AccountTemplate( + "account_to_burn_from", + False, + False, + ), + AccountTemplate( + "token_mint", + False, + False, + ), + AccountTemplate( + "owner", + True, + False, + ), + ], + [ + UIProperty( + None, + "token_mint", + "Burn token", + False, + None, + ), + UIProperty( + "amount", + None, + "Burn amount", + False, + None, + ), + UIProperty( + None, + "account_to_burn_from", + "From", + False, + None, + ), + UIProperty( + None, + "owner", + "Owner", + False, + None, + ), + ], + "Token Program: Burn Checked", + True, + True, + True, + None, + ) + if instruction_id == TOKEN_PROGRAM_ID_INS_INITIALIZE_ACCOUNT_2: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_PROGRAM_ID_INS_INITIALIZE_ACCOUNT_2, + [ + PropertyTemplate( + "owner", + False, + False, + parse_pubkey, + format_pubkey, + ), + ], + [ + AccountTemplate( + "account_to_initialize", + False, + False, + ), + AccountTemplate( + "mint_account", + False, + False, + ), + AccountTemplate( + "rent_sysvar", + False, + False, + ), + ], + [ + UIProperty( + None, + "account_to_initialize", + "Init account", + False, + None, + ), + UIProperty( + "owner", + None, + "Owner", + False, + None, + ), + UIProperty( + None, + "mint_account", + "Mint", + False, + None, + ), + ], + "Token Program: Initialize Account 2", + True, + True, + False, + None, + ) + if instruction_id == TOKEN_PROGRAM_ID_INS_SYNC_NATIVE: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_PROGRAM_ID_INS_SYNC_NATIVE, + [], + [ + AccountTemplate( + "token_account", + False, + False, + ), + ], + [ + UIProperty( + None, + "token_account", + "Sync native account", + False, + None, + ), + ], + "Token Program: Sync Native", + True, + True, + False, + None, + ) + if instruction_id == TOKEN_PROGRAM_ID_INS_INITIALIZE_ACCOUNT_3: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_PROGRAM_ID_INS_INITIALIZE_ACCOUNT_3, + [ + PropertyTemplate( + "owner", + False, + False, + parse_pubkey, + format_pubkey, + ), + ], + [ + AccountTemplate( + "account_to_initialize", + False, + False, + ), + AccountTemplate( + "mint_account", + False, + False, + ), + ], + [ + UIProperty( + None, + "account_to_initialize", + "Init account", + False, + None, + ), + UIProperty( + "owner", + None, + "Owner", + False, + None, + ), + UIProperty( + None, + "mint_account", + "Mint", + False, + None, + ), + ], + "Token Program: Initialize Account 3", + True, + True, + False, + None, + ) + if instruction_id == TOKEN_PROGRAM_ID_INS_INITIALIZE_IMMUTABLE_OWNER: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_PROGRAM_ID_INS_INITIALIZE_IMMUTABLE_OWNER, + [], + [ + AccountTemplate( + "account_to_initialize", + False, + False, + ), + ], + [ + UIProperty( + None, + "account_to_initialize", + "Init account", + False, + None, + ), + ], + "Token Program: Initialize Immutable Owner", + True, + True, + False, + None, + ) + return Instruction( + instruction_data, + program_id, + instruction_accounts, + instruction_id, + [], + [], + [], + "Token Program", + True, + False, + False, + ) + if program_id == TOKEN_2022_PROGRAM_ID: + if instruction_id == TOKEN_2022_PROGRAM_ID_INS_INITIALIZE_ACCOUNT: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_2022_PROGRAM_ID_INS_INITIALIZE_ACCOUNT, + [], + [ + AccountTemplate( + "account_to_initialize", + False, + False, + ), + AccountTemplate( + "mint_account", + False, + False, + ), + AccountTemplate( + "owner", + False, + False, + ), + AccountTemplate( + "rent_sysvar", + False, + False, + ), + ], + [ + UIProperty( + None, + "account_to_initialize", + "Init account", + False, + None, + ), + UIProperty( + None, + "owner", + "Owner", + False, + None, + ), + UIProperty( + None, + "mint_account", + "Mint", + False, + None, + ), + ], + "Token 2022 Program: Initialize Account", + True, + True, + False, + None, + ) + if instruction_id == TOKEN_2022_PROGRAM_ID_INS_INITIALIZE_MULTISIG: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_2022_PROGRAM_ID_INS_INITIALIZE_MULTISIG, + [ + PropertyTemplate( + "number_of_signers", + False, + False, + parse_byte, + format_int, + ), + ], + [ + AccountTemplate( + "multisig_account", + False, + False, + ), + AccountTemplate( + "rent_sysvar", + False, + False, + ), + AccountTemplate( + "signer_accounts", + False, + False, + ), + ], + [ + UIProperty( + None, + "multisig_account", + "Init multisig", + False, + None, + ), + UIProperty( + None, + "signer_accounts", + "Required signers", + False, + None, + ), + ], + "Token 2022 Program: Initialize Multisig", + True, + True, + True, + None, + ) + if instruction_id == TOKEN_2022_PROGRAM_ID_INS_TRANSFER: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_2022_PROGRAM_ID_INS_TRANSFER, + [ + PropertyTemplate( + "amount", + False, + False, + read_uint64_le, + format_int, + ), + ], + [ + AccountTemplate( + "source_account", + False, + False, + ), + AccountTemplate( + "destination_account", + False, + False, + ), + AccountTemplate( + "owner", + True, + False, + ), + ], + [ + UIProperty( + None, + "destination_account", + "Recipient", + False, + None, + ), + UIProperty( + "amount", + None, + "Amount", + False, + None, + ), + UIProperty( + None, + "source_account", + "From", + False, + None, + ), + UIProperty( + None, + "owner", + "Owner", + False, + None, + ), + ], + "Token 2022 Program: Transfer", + True, + True, + True, + "Warning: Instruction is deprecated. Token decimals unknown.", + ) + if instruction_id == TOKEN_2022_PROGRAM_ID_INS_APPROVE: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_2022_PROGRAM_ID_INS_APPROVE, + [ + PropertyTemplate( + "amount", + False, + False, + read_uint64_le, + format_int, + ), + ], + [ + AccountTemplate( + "source_account", + False, + False, + ), + AccountTemplate( + "delegate_account", + False, + False, + ), + AccountTemplate( + "owner", + True, + False, + ), + ], + [ + UIProperty( + None, + "delegate_account", + "Approve delegate", + False, + None, + ), + UIProperty( + "amount", + None, + "Allowance", + False, + None, + ), + UIProperty( + None, + "owner", + "Owner", + False, + None, + ), + ], + "Token 2022 Program: Approve", + True, + True, + True, + "Warning: Instruction is deprecated. Token decimals unknown.", + ) + if instruction_id == TOKEN_2022_PROGRAM_ID_INS_REVOKE: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_2022_PROGRAM_ID_INS_REVOKE, + [], + [ + AccountTemplate( + "source_account", + False, + False, + ), + AccountTemplate( + "owner", + True, + False, + ), + ], + [ + UIProperty( + None, + "source_account", + "Rewoke delegate", + False, + None, + ), + UIProperty( + None, + "owner", + "Owner", + False, + None, + ), + ], + "Token 2022 Program: Revoke", + True, + True, + True, + None, + ) + if instruction_id == TOKEN_2022_PROGRAM_ID_INS_SET_AUTHORITY: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_2022_PROGRAM_ID_INS_SET_AUTHORITY, + [ + PropertyTemplate( + "authority_type", + False, + False, + parse_byte, + format_AuthorityType, + ), + PropertyTemplate( + "new_authority", + True, + True, + parse_pubkey, + format_pubkey, + ), + ], + [ + AccountTemplate( + "mint_account", + False, + False, + ), + AccountTemplate( + "current_authority", + True, + False, + ), + ], + [ + UIProperty( + None, + "mint_account", + "Set authority for", + False, + None, + ), + UIProperty( + "new_authority", + None, + "New authority", + False, + None, + ), + UIProperty( + "authority_type", + None, + "Authority type", + False, + None, + ), + UIProperty( + None, + "current_authority", + "Current authority", + False, + None, + ), + ], + "Token 2022 Program: Set Authority", + True, + True, + True, + None, + ) + if instruction_id == TOKEN_2022_PROGRAM_ID_INS_MINT_TO: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_2022_PROGRAM_ID_INS_MINT_TO, + [ + PropertyTemplate( + "amount", + False, + False, + read_uint64_le, + format_int, + ), + ], + [ + AccountTemplate( + "mint", + False, + False, + ), + AccountTemplate( + "account_to_mint", + False, + False, + ), + AccountTemplate( + "minting_authority", + True, + False, + ), + ], + [ + UIProperty( + "amount", + None, + "Mint tokens", + False, + None, + ), + UIProperty( + None, + "account_to_mint", + "To", + False, + None, + ), + UIProperty( + None, + "minting_authority", + "Mint authority", + False, + None, + ), + ], + "Token 2022 Program: Mint to", + True, + True, + True, + "Warning: Instruction is deprecated. Token decimals unknown.", + ) + if instruction_id == TOKEN_2022_PROGRAM_ID_INS_BURN: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_2022_PROGRAM_ID_INS_BURN, + [ + PropertyTemplate( + "amount", + False, + False, + read_uint64_le, + format_int, + ), + ], + [ + AccountTemplate( + "account_to_burn_from", + False, + False, + ), + AccountTemplate( + "token_mint", + False, + False, + ), + AccountTemplate( + "owner", + True, + False, + ), + ], + [ + UIProperty( + "amount", + None, + "Burn tokens", + False, + None, + ), + UIProperty( + None, + "account_to_burn_from", + "From", + False, + None, + ), + UIProperty( + None, + "owner", + "Mint authority", + False, + None, + ), + ], + "Token 2022 Program: Burn", + True, + True, + True, + "Warning: Instruction is deprecated. Token decimals unknown.", + ) + if instruction_id == TOKEN_2022_PROGRAM_ID_INS_CLOSE_ACCOUNT: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_2022_PROGRAM_ID_INS_CLOSE_ACCOUNT, + [], + [ + AccountTemplate( + "account_to_close", + False, + False, + ), + AccountTemplate( + "destination_account", + False, + False, + ), + AccountTemplate( + "owner", + True, + False, + ), + ], + [ + UIProperty( + None, + "account_to_close", + "Close account", + False, + None, + ), + UIProperty( + None, + "destination_account", + "Withdraw to", + False, + None, + ), + UIProperty( + None, + "owner", + "Owner", + False, + None, + ), + ], + "Token 2022 Program: Close Account", + True, + True, + True, + None, + ) + if instruction_id == TOKEN_2022_PROGRAM_ID_INS_FREEZE_ACCOUNT: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_2022_PROGRAM_ID_INS_FREEZE_ACCOUNT, + [], + [ + AccountTemplate( + "account_to_freeze", + False, + False, + ), + AccountTemplate( + "token_mint", + False, + False, + ), + AccountTemplate( + "freeze_authority", + True, + False, + ), + ], + [ + UIProperty( + None, + "account_to_freeze", + "Freeze account", + False, + None, + ), + UIProperty( + None, + "freeze_authority", + "Owner", + False, + None, + ), + ], + "Token 2022 Program: Freeze Account", + True, + True, + True, + None, + ) + if instruction_id == TOKEN_2022_PROGRAM_ID_INS_THAW_ACCOUNT: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_2022_PROGRAM_ID_INS_THAW_ACCOUNT, + [], + [ + AccountTemplate( + "account_to_freeze", + False, + False, + ), + AccountTemplate( + "token_mint", + False, + False, + ), + AccountTemplate( + "freeze_authority", + True, + False, + ), + ], + [ + UIProperty( + None, + "account_to_freeze", + "Thaw account", + False, + None, + ), + UIProperty( + None, + "freeze_authority", + "Owner", + False, + None, + ), + ], + "Token 2022 Program: Thaw Account", + True, + True, + True, + None, + ) + if instruction_id == TOKEN_2022_PROGRAM_ID_INS_TRANSFER_CHECKED: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_2022_PROGRAM_ID_INS_TRANSFER_CHECKED, + [ + PropertyTemplate( + "amount", + False, + False, + read_uint64_le, + format_token_amount, + ), + PropertyTemplate( + "decimals", + False, + False, + parse_byte, + format_int, + ), + ], + [ + AccountTemplate( + "source_account", + False, + False, + ), + AccountTemplate( + "token_mint", + False, + False, + ), + AccountTemplate( + "destination_account", + False, + False, + ), + AccountTemplate( + "owner", + True, + False, + ), + ], + [ + UIProperty( + None, + "token_mint", + "Token", + False, + None, + ), + UIProperty( + None, + "destination_account", + "Recipient", + False, + None, + ), + UIProperty( + "amount", + None, + "Amount", + False, + None, + ), + UIProperty( + None, + "source_account", + "From", + False, + None, + ), + UIProperty( + None, + "owner", + "Owner", + False, + None, + ), + ], + "Token 2022 Program: Transfer Checked", + True, + True, + True, + None, + ) + if instruction_id == TOKEN_2022_PROGRAM_ID_INS_APPROVE_CHECKED: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_2022_PROGRAM_ID_INS_APPROVE_CHECKED, + [ + PropertyTemplate( + "amount", + False, + False, + read_uint64_le, + format_token_amount, + ), + PropertyTemplate( + "decimals", + False, + False, + parse_byte, + format_int, + ), + ], + [ + AccountTemplate( + "source_account", + False, + False, + ), + AccountTemplate( + "token_mint", + False, + False, + ), + AccountTemplate( + "delegate", + False, + False, + ), + AccountTemplate( + "owner", + True, + False, + ), + ], + [ + UIProperty( + None, + "token_mint", + "Approve token", + False, + None, + ), + UIProperty( + None, + "delegate", + "Approve delegate", + False, + None, + ), + UIProperty( + "amount", + None, + "Allowance", + False, + None, + ), + UIProperty( + None, + "source_account", + "From", + False, + None, + ), + UIProperty( + None, + "owner", + "Owner", + False, + None, + ), + ], + "Token 2022 Program: Approve Checked", + True, + True, + True, + None, + ) + if instruction_id == TOKEN_2022_PROGRAM_ID_INS_MINT_TO_CHECKED: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_2022_PROGRAM_ID_INS_MINT_TO_CHECKED, + [ + PropertyTemplate( + "amount", + False, + False, + read_uint64_le, + format_token_amount, + ), + PropertyTemplate( + "decimals", + False, + False, + parse_byte, + format_int, + ), + ], + [ + AccountTemplate( + "mint", + False, + False, + ), + AccountTemplate( + "account_to_mint", + False, + False, + ), + AccountTemplate( + "minting_authority", + True, + False, + ), + ], + [ + UIProperty( + None, + "mint", + "Mint token", + False, + None, + ), + UIProperty( + "amount", + None, + "Mint amount", + False, + None, + ), + UIProperty( + None, + "account_to_mint", + "To", + False, + None, + ), + UIProperty( + None, + "minting_authority", + "Owner", + False, + None, + ), + ], + "Token 2022 Program: Mint to Checked", + True, + True, + True, + None, + ) + if instruction_id == TOKEN_2022_PROGRAM_ID_INS_BURN_CHECKED: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_2022_PROGRAM_ID_INS_BURN_CHECKED, + [ + PropertyTemplate( + "amount", + False, + False, + read_uint64_le, + format_token_amount, + ), + PropertyTemplate( + "decimals", + False, + False, + parse_byte, + format_int, + ), + ], + [ + AccountTemplate( + "account_to_burn_from", + False, + False, + ), + AccountTemplate( + "token_mint", + False, + False, + ), + AccountTemplate( + "owner", + True, + False, + ), + ], + [ + UIProperty( + None, + "token_mint", + "Burn token", + False, + None, + ), + UIProperty( + "amount", + None, + "Burn amount", + False, + None, + ), + UIProperty( + None, + "account_to_burn_from", + "From", + False, + None, + ), + UIProperty( + None, + "owner", + "Owner", + False, + None, + ), + ], + "Token 2022 Program: Burn Checked", + True, + True, + True, + None, + ) + if instruction_id == TOKEN_2022_PROGRAM_ID_INS_INITIALIZE_ACCOUNT_2: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_2022_PROGRAM_ID_INS_INITIALIZE_ACCOUNT_2, + [ + PropertyTemplate( + "owner", + False, + False, + parse_pubkey, + format_pubkey, + ), + ], + [ + AccountTemplate( + "account_to_initialize", + False, + False, + ), + AccountTemplate( + "mint_account", + False, + False, + ), + AccountTemplate( + "rent_sysvar", + False, + False, + ), + ], + [ + UIProperty( + None, + "account_to_initialize", + "Init account", + False, + None, + ), + UIProperty( + "owner", + None, + "Owner", + False, + None, + ), + UIProperty( + None, + "mint_account", + "Mint", + False, + None, + ), + ], + "Token 2022 Program: Initialize Account 2", + True, + True, + False, + None, + ) + if instruction_id == TOKEN_2022_PROGRAM_ID_INS_SYNC_NATIVE: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_2022_PROGRAM_ID_INS_SYNC_NATIVE, + [], + [ + AccountTemplate( + "token_account", + False, + False, + ), + ], + [ + UIProperty( + None, + "token_account", + "Sync native account", + False, + None, + ), + ], + "Token 2022 Program: Sync Native", + True, + True, + False, + None, + ) + if instruction_id == TOKEN_2022_PROGRAM_ID_INS_INITIALIZE_ACCOUNT_3: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_2022_PROGRAM_ID_INS_INITIALIZE_ACCOUNT_3, + [ + PropertyTemplate( + "owner", + False, + False, + parse_pubkey, + format_pubkey, + ), + ], + [ + AccountTemplate( + "account_to_initialize", + False, + False, + ), + AccountTemplate( + "mint_account", + False, + False, + ), + ], + [ + UIProperty( + None, + "account_to_initialize", + "Init account", + False, + None, + ), + UIProperty( + "owner", + None, + "Owner", + False, + None, + ), + UIProperty( + None, + "mint_account", + "Mint", + False, + None, + ), + ], + "Token 2022 Program: Initialize Account 3", + True, + True, + False, + None, + ) + if instruction_id == TOKEN_2022_PROGRAM_ID_INS_INITIALIZE_IMMUTABLE_OWNER: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + TOKEN_2022_PROGRAM_ID_INS_INITIALIZE_IMMUTABLE_OWNER, + [], + [ + AccountTemplate( + "account_to_initialize", + False, + False, + ), + ], + [ + UIProperty( + None, + "account_to_initialize", + "Init account", + False, + None, + ), + ], + "Token 2022 Program: Initialize Immutable Owner", + True, + True, + False, + None, + ) + return Instruction( + instruction_data, + program_id, + instruction_accounts, + instruction_id, + [], + [], + [], + "Token 2022 Program", + True, + False, + False, + ) + if program_id == ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID: + if instruction_id == ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID_INS_CREATE: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID_INS_CREATE, + [], + [ + AccountTemplate( + "funding_account", + True, + False, + ), + AccountTemplate( + "associated_token_account", + False, + False, + ), + AccountTemplate( + "wallet_address", + False, + False, + ), + AccountTemplate( + "token_mint", + False, + False, + ), + AccountTemplate( + "system_program", + False, + False, + ), + AccountTemplate( + "spl_token", + False, + False, + ), + ], + [ + UIProperty( + None, + "associated_token_account", + "Create token account", + False, + None, + ), + UIProperty( + None, + "token_mint", + "From mint", + False, + None, + ), + UIProperty( + None, + "wallet_address", + "Owned by", + False, + None, + ), + UIProperty( + None, + "funding_account", + "Funded by", + False, + None, + ), + ], + "Associated Token Account Program: Create", + True, + True, + False, + None, + ) + if instruction_id == ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID_INS_CREATE_IDEMPOTENT: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID_INS_CREATE_IDEMPOTENT, + [], + [ + AccountTemplate( + "funding_account", + True, + False, + ), + AccountTemplate( + "associated_token_account", + False, + False, + ), + AccountTemplate( + "wallet_addr", + False, + False, + ), + AccountTemplate( + "token_mint", + False, + False, + ), + AccountTemplate( + "system_program", + False, + False, + ), + AccountTemplate( + "spl_token", + False, + False, + ), + ], + [ + UIProperty( + None, + "associated_token_account", + "Create token account", + False, + None, + ), + UIProperty( + None, + "token_mint", + "From mint", + False, + None, + ), + UIProperty( + None, + "wallet_addr", + "Owned by", + False, + None, + ), + UIProperty( + None, + "funding_account", + "Funded by", + False, + None, + ), + ], + "Associated Token Account Program: Create Idempotent", + True, + True, + False, + None, + ) + if instruction_id == ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID_INS_RECOVER_NESTED: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID_INS_RECOVER_NESTED, + [], + [ + AccountTemplate( + "nested_account", + True, + False, + ), + AccountTemplate( + "token_mint_nested", + False, + False, + ), + AccountTemplate( + "associated_token_account", + False, + False, + ), + AccountTemplate( + "owner", + False, + False, + ), + AccountTemplate( + "token_mint_owner", + False, + False, + ), + AccountTemplate( + "wallet_address", + True, + False, + ), + AccountTemplate( + "spl_token", + False, + False, + ), + ], + [ + UIProperty( + None, + "nested_account", + "Recover nested token account", + False, + None, + ), + UIProperty( + None, + "associated_token_account", + "Transfer recovered tokens to", + False, + None, + ), + UIProperty( + None, + "wallet_address", + "Transfer recovered SOL to", + False, + None, + ), + ], + "Associated Token Account Program: Recover Nested", + True, + True, + False, + None, + ) + return Instruction( + instruction_data, + program_id, + instruction_accounts, + instruction_id, + [], + [], + [], + "Associated Token Account Program", + True, + False, + False, + ) + if program_id == MEMO_PROGRAM_ID: + if instruction_id == MEMO_PROGRAM_ID_INS_MEMO: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + MEMO_PROGRAM_ID_INS_MEMO, + [ + PropertyTemplate( + "memo", + False, + False, + parse_memo, + format_identity, + ), + ], + [ + AccountTemplate( + "signer_accounts", + True, + True, + ), + ], + [ + UIProperty( + "memo", + None, + "Memo", + False, + None, + ), + UIProperty( + None, + "signer_accounts", + "Signer accounts", + False, + None, + ), + ], + "Memo Program: Memo", + True, + True, + False, + None, + ) + return Instruction( + instruction_data, + program_id, + instruction_accounts, + instruction_id, + [], + [], + [], + "Memo Program", + True, + False, + False, + ) + if program_id == MEMO_LEGACY_PROGRAM_ID: + if instruction_id == MEMO_LEGACY_PROGRAM_ID_INS_MEMO: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + MEMO_LEGACY_PROGRAM_ID_INS_MEMO, + [ + PropertyTemplate( + "memo", + False, + False, + parse_memo, + format_identity, + ), + ], + [ + AccountTemplate( + "signer_accounts", + True, + True, + ), + ], + [ + UIProperty( + "memo", + None, + "Memo", + False, + None, + ), + UIProperty( + None, + "signer_accounts", + "Signer accounts", + False, + None, + ), + ], + "Memo Legacy Program: Memo", + True, + True, + False, + None, + ) + return Instruction( + instruction_data, + program_id, + instruction_accounts, + instruction_id, + [], + [], + [], + "Memo Legacy Program", + True, + False, + False, + ) + return Instruction( + instruction_data, + program_id, + instruction_accounts, + 0, + [], + [], + [], + "Unsupported program", + False, + False, + False, + ) diff --git a/core/src/apps/solana/transaction/instructions.py.mako b/core/src/apps/solana/transaction/instructions.py.mako new file mode 100644 index 000000000..bbf6dd03d --- /dev/null +++ b/core/src/apps/solana/transaction/instructions.py.mako @@ -0,0 +1,225 @@ +# generated from instructions.py.mako +# do not edit manually! +<%def name="getProgramId(program)">${"_".join(program["name"].upper().split(" ") + ["ID"])}\ +<%def name="getInstructionIdText(program, instruction)">${"_".join([getProgramId(program)] + ["INS"] + instruction["name"].upper().split(" "))}\ +<%def name="getClassName(program, instruction)">${program["name"].replace(" ", "")}${instruction["name"].replace(" ", "")}Instruction\ +<%def name="getReferenceName(reference)">${"_".join(reference["name"].lower().split(" "))}\ +<%def name="getReferenceOptionalType(reference)">\ +% if reference["optional"]: + | None\ +% endif +\ +<%def name="getReferenceOptionalTemplate(reference)">\ +% if reference["optional"]: +, True\ +% else: +, False\ +% endif +\ +<%def name="getPythonType(type)">\ +% if type in ("u32", "u64", "i32", "i64", "timestamp", "lamports", "token_amount"): +int\ +% elif type in ("pubKey", "authority"): +Account\ +% elif type in ("string", "memo"): +str\ +% else: +int\ +% endif +\ +from typing import TYPE_CHECKING + +from trezor.wire import DataError + +from apps.common.readers import read_uint32_le, read_uint64_le + +from ..types import AccountTemplate, PropertyTemplate, UIProperty +from ..format import ( + format_int, + format_lamports, + format_pubkey, + format_identity, + format_token_amount, + format_unix_timestamp, +) +from .instruction import Instruction +from .parse import ( + parse_byte, + parse_memo, + parse_pubkey, + parse_string, +) + +if TYPE_CHECKING: + from typing import Any, Type + + from ..types import Account, InstructionId, InstructionData + +% for program in programs["programs"]: +${getProgramId(program)} = "${program["id"]}" +% endfor + +% for program in programs["programs"]: + % for instruction in program["instructions"]: +${getInstructionIdText(program, instruction)} = ${instruction["id"]} + % endfor +% endfor + +def __getattr__(name: str) -> Type[Instruction]: + def get_id(name: str) -> tuple[str, InstructionId]: + %for program in programs["programs"]: + %for instruction in program["instructions"]: + if name == "${getClassName(program, instruction)}": + return ("${program["id"]}", ${instruction["id"]}) + %endfor + %endfor + raise AttributeError # Unknown instruction + + id = get_id(name) + + class FakeClass(Instruction): + @classmethod + def is_type_of(cls, ins: Any): + return ins.program_id == id[0] and ins.instruction_id == id[1] + + return FakeClass + + +if TYPE_CHECKING: + +% for program in programs["programs"]: + ## generates classes for instructions + % for instruction in program["instructions"]: + class ${getClassName(program, instruction)}(Instruction): + ## generates properties for instruction parameters + % for parameter in instruction["parameters"]: + ${parameter["name"]}: ${getPythonType(parameter["type"])} + % endfor + + ## generates properties for reference accounts + % for reference in instruction["references"]: + ${getReferenceName(reference)}: Account${getReferenceOptionalType(reference)} + % endfor + % endfor +% endfor + +def get_instruction_id_length(program_id: str) -> int: +% for program in programs["programs"]: + if program_id == ${getProgramId(program)}: + return ${program["instruction_id_length"]} +% endfor + + return 0 + + +% for _, type in programs["types"].items(): + % if "is_enum" in type and type["is_enum"]: +def ${type["format"]}(_: Instruction, value: int) -> str: + % for variant in type["fields"]: + if value == ${variant["value"]}: + return "${variant["name"]}" + % endfor + raise DataError("Unknown value") + % endif +% endfor + +<%def name="getOptionalString(obj, string)">\ +% if string in obj: +"${obj[string]}"\ +%else: +None\ +% endif +\ + +<% + # Make sure that all required parameters are present in the instruction. + for program in programs["programs"]: + for instruction in program["instructions"]: + for parameter in instruction["parameters"]: + if "required_parameters" in programs["types"][parameter["type"]]: + for required_parameter in programs["types"][parameter["type"]]["required_parameters"]: + instruction_parameter_names = [parameter["name"] for parameter in instruction["parameters"]] + if required_parameter not in instruction_parameter_names: + raise Exception(f"Instruction \"{instruction['name']}\" is missing the required parameter \"{required_parameter}\" from paremeter \"{parameter['name']}\".") +%> + +def get_instruction( + program_id: str, instruction_id: InstructionId, instruction_accounts: list[Account], instruction_data: InstructionData +) -> Instruction: +% for program in programs["programs"]: +% if len(program["instructions"]) > 0: + if program_id == ${getProgramId(program)}: + % for instruction in program["instructions"]: + if instruction_id == ${getInstructionIdText(program, instruction)}: + return Instruction( + instruction_data, + program_id, + instruction_accounts, + ${getInstructionIdText(program, instruction)}, + [ + % for parameter in instruction["parameters"]: + PropertyTemplate( + "${parameter["name"]}", + ${parameter["type"] == "authority"}, + ${parameter["optional"]}, + ${programs["types"][parameter["type"]]["parse"]}, + ${programs["types"][parameter["type"]]["format"]}, + ), + % endfor + ], + [ + % for reference in instruction["references"]: + AccountTemplate( + "${reference["name"]}", + ${reference["is_authority"]}, + ${reference["optional"]}, + ), + % endfor + ], + [ + % for ui_property in instruction["ui_properties"]: + UIProperty( + ${getOptionalString(ui_property, "parameter")}, + ${getOptionalString(ui_property, "account")}, + "${ui_property["display_name"]}", + ${ui_property["is_authority"] if "is_authority" in ui_property else False}, + ${ui_property["default_value_to_hide"] if "default_value_to_hide" in ui_property else None}, + ), + % endfor + ], + "${program["name"]}: ${instruction["name"]}", + True, + True, + ${instruction["is_multisig"]}, + ${getOptionalString(instruction, "is_deprecated_warning")}, + ) + % endfor + return Instruction( + instruction_data, + program_id, + instruction_accounts, + instruction_id, + [], + [], + [], + "${program["name"]}", + True, + False, + False + ) +% endif +% endfor + return Instruction( + instruction_data, + program_id, + instruction_accounts, + 0, + [], + [], + [], + "Unsupported program", + False, + False, + False + ) + diff --git a/core/src/apps/solana/transaction/programs.json b/core/src/apps/solana/transaction/programs.json new file mode 100644 index 000000000..974ee8508 --- /dev/null +++ b/core/src/apps/solana/transaction/programs.json @@ -0,0 +1,3255 @@ +{ + "programs": [ + { + "id": "11111111111111111111111111111111", + "name": "System Program", + "instruction_id_length": 4, + "instructions": [ + { + "id": 0, + "name": "Create Account", + "is_multisig": false, + "parameters": [ + { + "name": "lamports", + "type": "lamports", + "optional": false + }, + { + "name": "space", + "type": "u64", + "optional": false + }, + { + "name": "owner", + "type": "authority", + "optional": false + } + ], + "references": [ + { + "name": "funding_account", + "is_authority": true, + "optional": false + }, + { + "name": "new_account", + "is_authority": false, + "optional": false + } + ], + "ui_properties": [ + { + "account": "new_account", + "display_name": "Create account" + }, + { + "parameter": "lamports", + "display_name": "Deposit" + }, + { + "account": "funding_account", + "display_name": "From" + } + ] + }, + { + "id": 1, + "name": "Assign", + "is_multisig": false, + "parameters": [ + { + "name": "owner", + "type": "authority", + "optional": false + } + ], + "references": [ + { + "name": "assigned_account", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "account": "assigned_account", + "display_name": "Assigned account" + }, + { + "parameter": "owner", + "display_name": "To program" + } + ] + }, + { + "id": 2, + "name": "Transfer", + "is_multisig": false, + "parameters": [ + { + "name": "lamports", + "type": "lamports", + "optional": false + } + ], + "references": [ + { + "name": "funding_account", + "is_authority": true, + "optional": false + }, + { + "name": "recipient_account", + "is_authority": false, + "optional": false + } + ], + "ui_properties": [ + { + "account": "recipient_account", + "display_name": "Recipient" + }, + { + "parameter": "lamports", + "display_name": "Amount" + }, + { + "account": "funding_account", + "display_name": "Sender" + } + ] + }, + { + "id": 3, + "name": "Create Account With Seed", + "is_multisig": false, + "parameters": [ + { + "name": "base", + "type": "pubkey", + "optional": false + }, + { + "name": "seed", + "type": "string", + "optional": false + }, + { + "name": "lamports", + "type": "lamports", + "optional": false + }, + { + "name": "space", + "type": "u64", + "optional": false + }, + { + "name": "owner", + "type": "pubkey", + "optional": false + } + ], + "references": [ + { + "name": "funding_account", + "is_authority": true, + "optional": false + }, + { + "name": "created_account", + "is_authority": false, + "optional": false + }, + { + "name": "base_account", + "is_authority": true, + "optional": true + } + ], + "ui_properties": [ + { + "account": "created_account", + "display_name": "Create account" + }, + { + "parameter": "lamports", + "display_name": "Deposit" + }, + { + "account": "funding_account", + "display_name": "From" + } + ] + }, + { + "id": 4, + "name": "Advance Nonce Account", + "is_multisig": false, + "parameters": [], + "references": [ + { + "name": "nonce_account", + "is_authority": false, + "optional": false + }, + { + "name": "recent_blockhashes_sysvar", + "is_authority": false, + "optional": false + }, + { + "name": "nonce_authority", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "account": "nonce_account", + "display_name": "Advance nonce" + }, + { + "account": "nonce_authority", + "display_name": "Authorized by" + } + ] + }, + { + "id": 5, + "name": "Withdraw Nonce Account", + "is_multisig": false, + "parameters": [ + { + "name": "lamports", + "type": "lamports", + "optional": false + } + ], + "references": [ + { + "name": "nonce_account", + "is_authority": false, + "optional": false + }, + { + "name": "recipient_account", + "is_authority": false, + "optional": false + }, + { + "name": "recent_blockhashes_sysvar", + "is_authority": false, + "optional": false + }, + { + "name": "rent_sysvar", + "is_authority": false, + "optional": false + }, + { + "name": "nonce_authority", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "parameter": "lamports", + "display_name": "Nonce withdraw" + }, + { + "account": "nonce_account", + "display_name": "From" + }, + { + "account": "recipient_account", + "display_name": "To" + }, + { + "account": "nonce_authority", + "display_name": "Authorized by" + } + ] + }, + { + "id": 6, + "name": "Initialize Nonce Account", + "is_multisig": false, + "parameters": [ + { + "name": "nonce_authority", + "type": "authority", + "optional": false + } + ], + "references": [ + { + "name": "nonce_account", + "is_authority": false, + "optional": false + }, + { + "name": "recent_blockhashes_sysvar", + "is_authority": false, + "optional": false + }, + { + "name": "rent_sysvar", + "is_authority": false, + "optional": false + } + ], + "ui_properties": [ + { + "account": "nonce_account", + "display_name": "Initialize nonce account" + }, + { + "parameter": "nonce_authority", + "display_name": "New authority" + } + ] + }, + { + "id": 7, + "name": "Authorize Nonce Account", + "is_multisig": false, + "parameters": [ + { + "name": "nonce_authority", + "type": "authority", + "optional": false + } + ], + "references": [ + { + "name": "nonce_account", + "is_authority": false, + "optional": false + }, + { + "name": "nonce_authority", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "account": "nonce_account", + "display_name": "Set nonce authority" + }, + { + "parameter": "nonce_authority", + "display_name": "New authority" + }, + { + "account": "nonce_authority", + "display_name": "Authorized by" + } + ] + }, + { + "id": 8, + "name": "Allocate", + "is_multisig": false, + "parameters": [ + { + "name": "space", + "type": "u64", + "optional": false + } + ], + "references": [ + { + "name": "new_account", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "account": "new_account", + "display_name": "Allocate account" + }, + { + "parameter": "space", + "display_name": "Data size" + } + ] + }, + { + "id": 9, + "name": "Allocate With Seed", + "is_multisig": false, + "parameters": [ + { + "name": "base", + "type": "pubkey", + "optional": false + }, + { + "name": "seed", + "type": "string", + "optional": false + }, + { + "name": "space", + "type": "u64", + "optional": false + }, + { + "name": "owner", + "type": "pubkey", + "optional": false + } + ], + "references": [ + { + "name": "allocated_account", + "is_authority": false, + "optional": false + }, + { + "name": "base_account", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "account": "allocated_account", + "display_name": "Allocate account" + }, + { + "parameter": "space", + "display_name": "Data size" + } + ] + }, + { + "id": 10, + "name": "Assign With Seed", + "is_multisig": false, + "parameters": [ + { + "name": "base", + "type": "pubkey", + "optional": false + }, + { + "name": "seed", + "type": "string", + "optional": false + }, + { + "name": "owner", + "type": "pubkey", + "optional": false + } + ], + "references": [ + { + "name": "assigned_account", + "is_authority": false, + "optional": false + }, + { + "name": "base_account", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "account": "assigned_account", + "display_name": "Assigned account" + }, + { + "parameter": "owner", + "display_name": "To program" + } + ] + }, + { + "id": 11, + "name": "Transfer With Seed", + "is_multisig": false, + "parameters": [ + { + "name": "lamports", + "type": "lamports", + "optional": false + }, + { + "name": "from_seed", + "type": "string", + "optional": false + }, + { + "name": "from_owner", + "type": "pubkey", + "optional": false + } + ], + "references": [ + { + "name": "funding_account", + "is_authority": false, + "optional": false + }, + { + "name": "base_account", + "is_authority": true, + "optional": false + }, + { + "name": "recipient_account", + "is_authority": false, + "optional": false + } + ], + "ui_properties": [ + { + "account": "recipient_account", + "display_name": "Recipient" + }, + { + "parameter": "lamports", + "display_name": "Amount" + }, + { + "account": "funding_account", + "display_name": "Sender" + } + ] + }, + { + "id": 12, + "name": "Upgrade Nonce Account", + "is_multisig": false, + "parameters": [], + "references": [ + { + "name": "nonce_account", + "is_authority": false, + "optional": false + } + ], + "ui_properties": [ + { + "account": "nonce_account", + "display_name": "Upgrade nonce account" + } + ] + } + ] + }, + { + "id": "Stake11111111111111111111111111111111111111", + "name": "Stake Program", + "instruction_id_length": 4, + "instructions": [ + { + "id": 0, + "name": "Initialize", + "is_multisig": false, + "parameters": [ + { + "name": "staker", + "type": "authority", + "optional": false + }, + { + "name": "withdrawer", + "type": "authority", + "optional": false + }, + { + "name": "unix_timestamp", + "type": "unix_timestamp", + "optional": false + }, + { + "name": "epoch", + "type": "u64", + "optional": false + }, + { + "name": "custodian", + "type": "authority", + "optional": false + } + ], + "references": [ + { + "name": "uninitialized_stake_account", + "is_authority": false, + "optional": false + }, + { + "name": "rent_sysvar", + "is_authority": false, + "optional": false + } + ], + "ui_properties": [ + { + "account": "uninitialized_stake_account", + "display_name": "Initialize stake account" + }, + { + "parameter": "staker", + "display_name": "New stake authority" + }, + { + "parameter": "withdrawer", + "display_name": "New withdraw authority" + }, + { + "parameter": "unix_timestamp", + "display_name": "Lockup time", + "default_value_to_hide": 0 + }, + { + "parameter": "epoch", + "display_name": "Lockup epoch", + "default_value_to_hide": 0 + }, + { + "parameter": "custodian", + "display_name": "Lockup authority" + } + ] + }, + { + "id": 1, + "name": "Authorize", + "is_multisig": false, + "parameters": [ + { + "name": "pubkey", + "type": "pubkey", + "optional": false + }, + { + "name": "stake_authorize", + "type": "StakeAuthorize", + "optional": false + } + ], + "references": [ + { + "name": "stake_account", + "is_authority": false, + "optional": false + }, + { + "name": "clock_sysvar", + "is_authority": false, + "optional": false + }, + { + "name": "stake_or_withdraw_authority", + "is_authority": true, + "optional": false + }, + { + "name": "lockup_authority", + "is_authority": true, + "optional": true + } + ], + "ui_properties": [ + { + "account": "stake_account", + "display_name": "Set stake authority for" + }, + { + "parameter": "pubkey", + "display_name": "New authority" + }, + { + "parameter": "stake_authorize", + "display_name": "Authority type" + }, + { + "account": "stake_or_withdraw_authority", + "display_name": "Authorized by" + }, + { + "account": "lockup_authority", + "display_name": "Custodian" + } + ] + }, + { + "id": 2, + "name": "Delegate Stake", + "is_multisig": false, + "parameters": [], + "references": [ + { + "name": "initialized_stake_account", + "is_authority": false, + "optional": false + }, + { + "name": "vote_account", + "is_authority": false, + "optional": false + }, + { + "name": "clock_sysvar", + "is_authority": false, + "optional": false + }, + { + "name": "stake_history_sysvar", + "is_authority": false, + "optional": false + }, + { + "name": "config_account", + "is_authority": false, + "optional": false + }, + { + "name": "stake_authority", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "account": "initialized_stake_account", + "display_name": "Delegate from" + }, + { + "account": "stake_authority", + "display_name": "Authorized by" + }, + { + "account": "vote_account", + "display_name": "Vote account" + } + ] + }, + { + "id": 3, + "name": "Split", + "is_multisig": false, + "parameters": [ + { + "name": "lamports", + "type": "lamports", + "optional": false + } + ], + "references": [ + { + "name": "stake_account", + "is_authority": false, + "optional": false + }, + { + "name": "uninitialized_stake_account", + "is_authority": false, + "optional": false + }, + { + "name": "stake_authority", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "parameter": "lamports", + "display_name": "Split stake" + }, + { + "account": "stake_account", + "display_name": "From" + }, + { + "account": "uninitialized_stake_account", + "display_name": "To" + }, + { + "account": "stake_authority", + "display_name": "Authorized by" + } + ] + }, + { + "id": 4, + "name": "Withdraw", + "is_multisig": false, + "parameters": [ + { + "name": "lamports", + "type": "lamports", + "optional": false + } + ], + "references": [ + { + "name": "stake_account", + "is_authority": false, + "optional": false + }, + { + "name": "recipient_account", + "is_authority": false, + "optional": false + }, + { + "name": "clock_sysvar", + "is_authority": false, + "optional": false + }, + { + "name": "stake_history_sysvar", + "is_authority": false, + "optional": false + }, + { + "name": "withdrawal_authority", + "is_authority": true, + "optional": false + }, + { + "name": "lockup_authority", + "is_authority": true, + "optional": true + } + ], + "ui_properties": [ + { + "parameter": "lamports", + "display_name": "Stake withdraw" + }, + { + "account": "stake_account", + "display_name": "From" + }, + { + "account": "recipient_account", + "display_name": "To" + }, + { + "account": "withdrawal_authority", + "display_name": "Authorized by" + } + ] + }, + { + "id": 5, + "name": "Deactivate", + "is_multisig": false, + "parameters": [], + "references": [ + { + "name": "delegated_stake_account", + "is_authority": false, + "optional": false + }, + { + "name": "clock_sysvar", + "is_authority": false, + "optional": false + }, + { + "name": "stake_authority", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "account": "delegated_stake_account", + "display_name": "Deactivate stake" + }, + { + "account": "stake_authority", + "display_name": "Authorized by" + } + ] + }, + { + "id": 6, + "name": "Set Lockup", + "is_multisig": false, + "parameters": [ + { + "name": "unix_timestamp", + "type": "unix_timestamp", + "optional": true + }, + { + "name": "epoch", + "type": "u64", + "optional": true + }, + { + "name": "custodian", + "type": "pubkey", + "optional": true + } + ], + "references": [ + { + "name": "initialized_stake_account", + "is_authority": false, + "optional": false + }, + { + "name": "lockup_or_withdraw_authority", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "account": "initialized_stake_account", + "display_name": "Set lockup for account" + }, + { + "parameter": "unix_timestamp", + "display_name": "Time", + "default_value_to_hide": 0 + }, + { + "parameter": "epoch", + "display_name": "Epoch", + "default_value_to_hide": 0 + }, + { + "parameter": "custodian", + "display_name": "New lockup authority" + }, + { + "account": "lockup_or_withdraw_authority", + "display_name": "Authorized by" + } + ] + }, + { + "id": 7, + "name": "Merge", + "is_multisig": false, + "parameters": [], + "references": [ + { + "name": "destination_stake_account", + "is_authority": false, + "optional": false + }, + { + "name": "source_stake_account", + "is_authority": false, + "optional": false + }, + { + "name": "clock_sysvar", + "is_authority": false, + "optional": false + }, + { + "name": "stake_history_sysvar", + "is_authority": false, + "optional": false + }, + { + "name": "stake_authority", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "account": "source_stake_account", + "display_name": "Merge" + }, + { + "account": "destination_stake_account", + "display_name": "Into" + }, + { + "account": "stake_authority", + "display_name": "Authorized by" + } + ] + }, + { + "id": 8, + "name": "Authorize With Seed", + "is_multisig": false, + "parameters": [ + { + "name": "new_authorized_pubkey", + "type": "pubkey", + "optional": false + }, + { + "name": "stake_authorize", + "type": "StakeAuthorize", + "optional": false + }, + { + "name": "authority_seed", + "type": "string", + "optional": false + }, + { + "name": "authority_owner", + "type": "pubkey", + "optional": false + } + ], + "references": [ + { + "name": "stake_account", + "is_authority": false, + "optional": false + }, + { + "name": "stake_or_withdraw_authority", + "is_authority": true, + "optional": false + }, + { + "name": "clock_sysvar", + "is_authority": false, + "optional": false + }, + { + "name": "lockup_authority", + "is_authority": true, + "optional": true + } + ], + "ui_properties": [ + { + "account": "stake_account", + "display_name": "Set stake auth" + }, + { + "parameter": "new_authorized_pubkey", + "display_name": "New (stake/withdraw) auth" + }, + { + "account": "stake_or_withdraw_authority", + "display_name": "Authorized by" + }, + { + "account": "lockup_authority", + "display_name": "Custodian" + } + ] + }, + { + "id": 9, + "name": "Initialize Checked", + "is_multisig": false, + "parameters": [], + "references": [ + { + "name": "uninitialized_stake_account", + "is_authority": false, + "optional": false + }, + { + "name": "rent_sysvar", + "is_authority": false, + "optional": false + }, + { + "name": "stake_authority", + "is_authority": false, + "optional": false + }, + { + "name": "withdrawal_authority", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "account": "uninitialized_stake_account", + "display_name": "Uninitialized stake account" + }, + { + "account": "stake_authority", + "display_name": "New stake authority" + }, + { + "account": "withdrawal_authority", + "display_name": "New withdraw authority" + } + ] + }, + { + "id": 10, + "name": "Authorize Checked", + "is_multisig": false, + "parameters": [ + { + "name": "stake_authorize", + "type": "StakeAuthorize", + "optional": false + } + ], + "references": [ + { + "name": "stake_account", + "is_authority": false, + "optional": false + }, + { + "name": "clock_sysvar", + "is_authority": false, + "optional": false + }, + { + "name": "stake_or_withdraw_authority", + "is_authority": true, + "optional": false + }, + { + "name": "new_stake_or_withdraw_authority", + "is_authority": true, + "optional": false + }, + { + "name": "lockup_authority", + "is_authority": true, + "optional": true + } + ], + "ui_properties": [ + { + "account": "stake_account", + "display_name": "Set stake auth" + }, + { + "account": "stake_or_withdraw_authority", + "display_name": "Stake or withdraw authority" + }, + { + "account": "new_stake_or_withdraw_authority", + "display_name": "New stake or withdraw authority" + } + ] + }, + { + "id": 11, + "name": "Authorize Checked With Seed", + "is_multisig": false, + "parameters": [ + { + "name": "stake_authorize", + "type": "StakeAuthorize", + "optional": false + }, + { + "name": "authority_seed", + "type": "string", + "optional": false + }, + { + "name": "authority_owner", + "type": "pubkey", + "optional": false + } + ], + "references": [ + { + "name": "stake_account", + "is_authority": false, + "optional": false + }, + { + "name": "stake_or_withdraw_authority", + "is_authority": true, + "optional": false + }, + { + "name": "clock_sysvar", + "is_authority": false, + "optional": false + }, + { + "name": "new_stake_or_withdraw_authority", + "is_authority": true, + "optional": false + }, + { + "name": "lockup_authority", + "is_authority": true, + "optional": true + } + ], + "ui_properties": [ + { + "account": "stake_account", + "display_name": "Set authority for stake account" + }, + { + "account": "new_stake_or_withdraw_authority", + "display_name": "New authority" + }, + { + "parameter": "stake_authorize", + "display_name": "Authority type" + }, + { + "account": "stake_or_withdraw_authority", + "display_name": "Authorized by" + }, + { + "account": "lockup_authority", + "display_name": "Custodian" + } + ] + }, + { + "id": 12, + "name": "Set Lockup Checked", + "is_multisig": false, + "parameters": [ + { + "name": "unix_timestamp", + "type": "unix_timestamp", + "optional": true + }, + { + "name": "epoch", + "type": "u64", + "optional": true + } + ], + "references": [ + { + "name": "stake_account", + "is_authority": false, + "optional": false + }, + { + "name": "lockup_or_withdraw_authority", + "is_authority": true, + "optional": false + }, + { + "name": "new_lockup_authority", + "is_authority": true, + "optional": true + } + ], + "ui_properties": [ + { + "account": "stake_account", + "display_name": "Set lockup for stake account" + }, + { + "parameter": "unix_timestamp", + "display_name": "Time", + "default_value_to_hide": 0 + }, + { + "parameter": "epoch", + "display_name": "Epoch", + "default_value_to_hide": 0 + }, + { + "account": "new_lockup_authority", + "display_name": "New lockup authority" + }, + { + "account": "lockup_or_withdraw_authority", + "display_name": "Authorized by" + } + ] + } + ] + }, + { + "id": "ComputeBudget111111111111111111111111111111", + "name": "Compute Budget Program", + "instruction_id_length": 1, + "instructions": [ + { + "id": 1, + "name": "Request Heap Frame", + "is_multisig": false, + "parameters": [ + { + "name": "bytes", + "type": "u32", + "optional": false + } + ], + "references": [], + "ui_properties": [ + { + "parameter": "bytes", + "display_name": "Bytes" + } + ] + }, + { + "id": 2, + "name": "Set Compute Unit Limit", + "is_multisig": false, + "parameters": [ + { + "name": "units", + "type": "u32", + "optional": false + } + ], + "references": [], + "ui_properties": [ + { + "parameter": "units", + "display_name": "Units" + } + ] + }, + { + "id": 3, + "name": "Set Compute Unit Price", + "is_multisig": false, + "parameters": [ + { + "name": "lamports", + "type": "u64", + "optional": false + } + ], + "references": [], + "ui_properties": [ + { + "parameter": "lamports", + "display_name": "Compute unit price" + } + ] + } + ] + }, + { + "id": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", + "name": "Token Program", + "instruction_id_length": 1, + "instructions": [ + { + "id": 1, + "name": "Initialize Account", + "is_multisig": false, + "parameters": [], + "references": [ + { + "name": "account_to_initialize", + "is_authority": false, + "optional": false + }, + { + "name": "mint_account", + "is_authority": false, + "optional": false + }, + { + "name": "owner", + "is_authority": false, + "optional": false + }, + { + "name": "rent_sysvar", + "is_authority": false, + "optional": false + } + ], + "ui_properties": [ + { + "account": "account_to_initialize", + "display_name": "Init account" + }, + { + "account": "owner", + "display_name": "Owner" + }, + { + "account": "mint_account", + "display_name": "Mint" + } + ] + }, + { + "id": 2, + "name": "Initialize Multisig", + "is_multisig": true, + "parameters": [ + { + "name": "number_of_signers", + "type": "u8", + "optional": false + } + ], + "references": [ + { + "name": "multisig_account", + "is_authority": false, + "optional": false + }, + { + "name": "rent_sysvar", + "is_authority": false, + "optional": false + }, + { + "name": "signer_accounts", + "is_authority": false, + "optional": false + } + ], + "ui_properties": [ + { + "account": "multisig_account", + "display_name": "Init multisig" + }, + { + "account": "signer_accounts", + "display_name": "Required signers" + } + ] + }, + { + "id": 3, + "name": "Transfer", + "is_multisig": true, + "is_deprecated_warning": "Warning: Instruction is deprecated. Token decimals unknown.", + "parameters": [ + { + "name": "amount", + "type": "u64", + "optional": false + } + ], + "references": [ + { + "name": "source_account", + "is_authority": false, + "optional": false + }, + { + "name": "destination_account", + "is_authority": false, + "optional": false + }, + { + "name": "owner", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "account": "destination_account", + "display_name": "Recipient" + }, + { + "parameter": "amount", + "display_name": "Amount" + }, + { + "account": "source_account", + "display_name": "From" + }, + { + "account": "owner", + "display_name": "Owner" + } + ] + }, + { + "id": 4, + "name": "Approve", + "is_multisig": true, + "is_deprecated_warning": "Warning: Instruction is deprecated. Token decimals unknown.", + "parameters": [ + { + "name": "amount", + "type": "u64", + "optional": false + } + ], + "references": [ + { + "name": "source_account", + "is_authority": false, + "optional": false + }, + { + "name": "delegate_account", + "is_authority": false, + "optional": false + }, + { + "name": "owner", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "account": "delegate_account", + "display_name": "Approve delegate" + }, + { + "parameter": "amount", + "display_name": "Allowance" + }, + { + "account": "owner", + "display_name": "Owner" + } + ] + }, + { + "id": 5, + "name": "Revoke", + "is_multisig": true, + "parameters": [], + "references": [ + { + "name": "source_account", + "is_authority": false, + "optional": false + }, + { + "name": "owner", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "account": "source_account", + "display_name": "Rewoke delegate" + }, + { + "account": "owner", + "display_name": "Owner" + } + ] + }, + { + "id": 6, + "name": "Set Authority", + "is_multisig": true, + "parameters": [ + { + "name": "authority_type", + "type": "AuthorityType", + "optional": false + }, + { + "name": "new_authority", + "type": "authority", + "optional": true + } + ], + "references": [ + { + "name": "mint_account", + "is_authority": false, + "optional": false + }, + { + "name": "current_authority", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "account": "mint_account", + "display_name": "Set authority for" + }, + { + "parameter": "new_authority", + "display_name": "New authority" + }, + { + "parameter": "authority_type", + "display_name": "Authority type" + }, + { + "account": "current_authority", + "display_name": "Current authority" + } + ] + }, + { + "id": 7, + "name": "Mint To", + "is_multisig": true, + "is_deprecated_warning": "Warning: Instruction is deprecated. Token decimals unknown.", + "parameters": [ + { + "name": "amount", + "type": "u64", + "optional": false + } + ], + "references": [ + { + "name": "mint", + "is_authority": false, + "optional": false + }, + { + "name": "account_to_mint", + "is_authority": false, + "optional": false + }, + { + "name": "minting_authority", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "parameter": "amount", + "display_name": "Mint tokens" + }, + { + "account": "account_to_mint", + "display_name": "To" + }, + { + "account": "minting_authority", + "display_name": "Mint authority" + } + ] + }, + { + "id": 8, + "name": "Burn", + "is_multisig": true, + "is_deprecated_warning": "Warning: Instruction is deprecated. Token decimals unknown.", + "parameters": [ + { + "name": "amount", + "type": "u64", + "optional": false + } + ], + "references": [ + { + "name": "account_to_burn_from", + "is_authority": false, + "optional": false + }, + { + "name": "token_mint", + "is_authority": false, + "optional": false + }, + { + "name": "owner", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "parameter": "amount", + "display_name": "Burn tokens" + }, + { + "account": "account_to_burn_from", + "display_name": "From" + }, + { + "account": "owner", + "display_name": "Mint authority" + } + ] + }, + { + "id": 9, + "name": "Close Account", + "is_multisig": true, + "parameters": [], + "references": [ + { + "name": "account_to_close", + "is_authority": false, + "optional": false + }, + { + "name": "destination_account", + "is_authority": false, + "optional": false + }, + { + "name": "owner", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "account": "account_to_close", + "display_name": "Close account" + }, + { + "account": "destination_account", + "display_name": "Withdraw to" + }, + { + "account": "owner", + "display_name": "Owner" + } + ] + }, + { + "id": 10, + "name": "Freeze Account", + "is_multisig": true, + "parameters": [], + "references": [ + { + "name": "account_to_freeze", + "is_authority": false, + "optional": false + }, + { + "name": "token_mint", + "is_authority": false, + "optional": false + }, + { + "name": "freeze_authority", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "account": "account_to_freeze", + "display_name": "Freeze account" + }, + { + "account": "freeze_authority", + "display_name": "Owner" + } + ] + }, + { + "id": 11, + "name": "Thaw Account", + "is_multisig": true, + "parameters": [], + "references": [ + { + "name": "account_to_freeze", + "is_authority": false, + "optional": false + }, + { + "name": "token_mint", + "is_authority": false, + "optional": false + }, + { + "name": "freeze_authority", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "account": "account_to_freeze", + "display_name": "Thaw account" + }, + { + "account": "freeze_authority", + "display_name": "Owner" + } + ] + }, + { + "id": 12, + "name": "Transfer Checked", + "is_multisig": true, + "parameters": [ + { + "name": "amount", + "type": "token_amount", + "optional": false + }, + { + "name": "decimals", + "type": "u8", + "optional": false + } + ], + "references": [ + { + "name": "source_account", + "is_authority": false, + "optional": false + }, + { + "name": "token_mint", + "is_authority": false, + "optional": false + }, + { + "name": "destination_account", + "is_authority": false, + "optional": false + }, + { + "name": "owner", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "account": "token_mint", + "display_name": "Token" + }, + { + "account": "destination_account", + "display_name": "Recipient" + }, + { + "parameter": "amount", + "display_name": "Amount" + }, + { + "account": "source_account", + "display_name": "From" + }, + { + "account": "owner", + "display_name": "Owner" + } + ] + }, + { + "id": 13, + "name": "Approve Checked", + "is_multisig": true, + "parameters": [ + { + "name": "amount", + "type": "token_amount", + "optional": false + }, + { + "name": "decimals", + "type": "u8", + "optional": false + } + ], + "references": [ + { + "name": "source_account", + "is_authority": false, + "optional": false + }, + { + "name": "token_mint", + "is_authority": false, + "optional": false + }, + { + "name": "delegate", + "is_authority": false, + "optional": false + }, + { + "name": "owner", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "account": "token_mint", + "display_name": "Approve token" + }, + { + "account": "delegate", + "display_name": "Approve delegate" + }, + { + "parameter": "amount", + "display_name": "Allowance" + }, + { + "account": "source_account", + "display_name": "From" + }, + { + "account": "owner", + "display_name": "Owner" + } + ] + }, + { + "id": 14, + "name": "Mint to Checked", + "is_multisig": true, + "parameters": [ + { + "name": "amount", + "type": "token_amount", + "optional": false + }, + { + "name": "decimals", + "type": "u8", + "optional": false + } + ], + "references": [ + { + "name": "mint", + "is_authority": false, + "optional": false + }, + { + "name": "account_to_mint", + "is_authority": false, + "optional": false + }, + { + "name": "minting_authority", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "account": "mint", + "display_name": "Mint token" + }, + { + "parameter": "amount", + "display_name": "Mint amount" + }, + { + "account": "account_to_mint", + "display_name": "To" + }, + { + "account": "minting_authority", + "display_name": "Owner" + } + ] + }, + { + "id": 15, + "name": "Burn Checked", + "is_multisig": true, + "parameters": [ + { + "name": "amount", + "type": "token_amount", + "optional": false + }, + { + "name": "decimals", + "type": "u8", + "optional": false + } + ], + "references": [ + { + "name": "account_to_burn_from", + "is_authority": false, + "optional": false + }, + { + "name": "token_mint", + "is_authority": false, + "optional": false + }, + { + "name": "owner", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "account": "token_mint", + "display_name": "Burn token" + }, + { + "parameter": "amount", + "display_name": "Burn amount" + }, + { + "account": "account_to_burn_from", + "display_name": "From" + }, + { + "account": "owner", + "display_name": "Owner" + } + ] + }, + { + "id": 16, + "name": "Initialize Account 2", + "is_multisig": false, + "parameters": [ + { + "name": "owner", + "type": "pubkey", + "optional": false + } + ], + "references": [ + { + "name": "account_to_initialize", + "is_authority": false, + "optional": false + }, + { + "name": "mint_account", + "is_authority": false, + "optional": false + }, + { + "name": "rent_sysvar", + "is_authority": false, + "optional": false + } + ], + "ui_properties": [ + { + "account": "account_to_initialize", + "display_name": "Init account" + }, + { + "parameter": "owner", + "display_name": "Owner" + }, + { + "account": "mint_account", + "display_name": "Mint" + } + ] + }, + { + "id": 17, + "name": "Sync Native", + "is_multisig": false, + "parameters": [], + "references": [ + { + "name": "token_account", + "is_authority": false, + "optional": false + } + ], + "ui_properties": [ + { + "account": "token_account", + "display_name": "Sync native account" + } + ] + }, + { + "id": 18, + "name": "Initialize Account 3", + "is_multisig": false, + "parameters": [ + { + "name": "owner", + "type": "pubkey", + "optional": false + } + ], + "references": [ + { + "name": "account_to_initialize", + "is_authority": false, + "optional": false + }, + { + "name": "mint_account", + "is_authority": false, + "optional": false + } + ], + "ui_properties": [ + { + "account": "account_to_initialize", + "display_name": "Init account" + }, + { + "parameter": "owner", + "display_name": "Owner" + }, + { + "account": "mint_account", + "display_name": "Mint" + } + ] + }, + { + "id": 22, + "name": "Initialize Immutable Owner", + "is_multisig": false, + "parameters": [], + "references": [ + { + "name": "account_to_initialize", + "is_authority": false, + "optional": false + } + ], + "ui_properties": [ + { + "account": "account_to_initialize", + "display_name": "Init account" + } + ] + } + ] + }, + { + "id": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb", + "name": "Token 2022 Program", + "instruction_id_length": 1, + "instructions": [ + { + "id": 1, + "name": "Initialize Account", + "is_multisig": false, + "parameters": [], + "references": [ + { + "name": "account_to_initialize", + "is_authority": false, + "optional": false + }, + { + "name": "mint_account", + "is_authority": false, + "optional": false + }, + { + "name": "owner", + "is_authority": false, + "optional": false + }, + { + "name": "rent_sysvar", + "is_authority": false, + "optional": false + } + ], + "ui_properties": [ + { + "account": "account_to_initialize", + "display_name": "Init account" + }, + { + "account": "owner", + "display_name": "Owner" + }, + { + "account": "mint_account", + "display_name": "Mint" + } + ] + }, + { + "id": 2, + "name": "Initialize Multisig", + "is_multisig": true, + "parameters": [ + { + "name": "number_of_signers", + "type": "u8", + "optional": false + } + ], + "references": [ + { + "name": "multisig_account", + "is_authority": false, + "optional": false + }, + { + "name": "rent_sysvar", + "is_authority": false, + "optional": false + }, + { + "name": "signer_accounts", + "is_authority": false, + "optional": false + } + ], + "ui_properties": [ + { + "account": "multisig_account", + "display_name": "Init multisig" + }, + { + "account": "signer_accounts", + "display_name": "Required signers" + } + ] + }, + { + "id": 3, + "name": "Transfer", + "is_multisig": true, + "is_deprecated_warning": "Warning: Instruction is deprecated. Token decimals unknown.", + "parameters": [ + { + "name": "amount", + "type": "u64", + "optional": false + } + ], + "references": [ + { + "name": "source_account", + "is_authority": false, + "optional": false + }, + { + "name": "destination_account", + "is_authority": false, + "optional": false + }, + { + "name": "owner", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "account": "destination_account", + "display_name": "Recipient" + }, + { + "parameter": "amount", + "display_name": "Amount" + }, + { + "account": "source_account", + "display_name": "From" + }, + { + "account": "owner", + "display_name": "Owner" + } + ] + }, + { + "id": 4, + "name": "Approve", + "is_multisig": true, + "is_deprecated_warning": "Warning: Instruction is deprecated. Token decimals unknown.", + "parameters": [ + { + "name": "amount", + "type": "u64", + "optional": false + } + ], + "references": [ + { + "name": "source_account", + "is_authority": false, + "optional": false + }, + { + "name": "delegate_account", + "is_authority": false, + "optional": false + }, + { + "name": "owner", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "account": "delegate_account", + "display_name": "Approve delegate" + }, + { + "parameter": "amount", + "display_name": "Allowance" + }, + { + "account": "owner", + "display_name": "Owner" + } + ] + }, + { + "id": 5, + "name": "Revoke", + "is_multisig": true, + "parameters": [], + "references": [ + { + "name": "source_account", + "is_authority": false, + "optional": false + }, + { + "name": "owner", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "account": "source_account", + "display_name": "Rewoke delegate" + }, + { + "account": "owner", + "display_name": "Owner" + } + ] + }, + { + "id": 6, + "name": "Set Authority", + "is_multisig": true, + "parameters": [ + { + "name": "authority_type", + "type": "AuthorityType", + "optional": false + }, + { + "name": "new_authority", + "type": "authority", + "optional": true + } + ], + "references": [ + { + "name": "mint_account", + "is_authority": false, + "optional": false + }, + { + "name": "current_authority", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "account": "mint_account", + "display_name": "Set authority for" + }, + { + "parameter": "new_authority", + "display_name": "New authority" + }, + { + "parameter": "authority_type", + "display_name": "Authority type" + }, + { + "account": "current_authority", + "display_name": "Current authority" + } + ] + }, + { + "id": 7, + "name": "Mint to", + "is_multisig": true, + "is_deprecated_warning": "Warning: Instruction is deprecated. Token decimals unknown.", + "parameters": [ + { + "name": "amount", + "type": "u64", + "optional": false + } + ], + "references": [ + { + "name": "mint", + "is_authority": false, + "optional": false + }, + { + "name": "account_to_mint", + "is_authority": false, + "optional": false + }, + { + "name": "minting_authority", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "parameter": "amount", + "display_name": "Mint tokens" + }, + { + "account": "account_to_mint", + "display_name": "To" + }, + { + "account": "minting_authority", + "display_name": "Mint authority" + } + ] + }, + { + "id": 8, + "name": "Burn", + "is_multisig": true, + "is_deprecated_warning": "Warning: Instruction is deprecated. Token decimals unknown.", + "parameters": [ + { + "name": "amount", + "type": "u64", + "optional": false + } + ], + "references": [ + { + "name": "account_to_burn_from", + "is_authority": false, + "optional": false + }, + { + "name": "token_mint", + "is_authority": false, + "optional": false + }, + { + "name": "owner", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "parameter": "amount", + "display_name": "Burn tokens" + }, + { + "account": "account_to_burn_from", + "display_name": "From" + }, + { + "account": "owner", + "display_name": "Mint authority" + } + ] + }, + { + "id": 9, + "name": "Close Account", + "is_multisig": true, + "parameters": [], + "references": [ + { + "name": "account_to_close", + "is_authority": false, + "optional": false + }, + { + "name": "destination_account", + "is_authority": false, + "optional": false + }, + { + "name": "owner", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "account": "account_to_close", + "display_name": "Close account" + }, + { + "account": "destination_account", + "display_name": "Withdraw to" + }, + { + "account": "owner", + "display_name": "Owner" + } + ] + }, + { + "id": 10, + "name": "Freeze Account", + "is_multisig": true, + "parameters": [], + "references": [ + { + "name": "account_to_freeze", + "is_authority": false, + "optional": false + }, + { + "name": "token_mint", + "is_authority": false, + "optional": false + }, + { + "name": "freeze_authority", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "account": "account_to_freeze", + "display_name": "Freeze account" + }, + { + "account": "freeze_authority", + "display_name": "Owner" + } + ] + }, + { + "id": 11, + "name": "Thaw Account", + "is_multisig": true, + "parameters": [], + "references": [ + { + "name": "account_to_freeze", + "is_authority": false, + "optional": false + }, + { + "name": "token_mint", + "is_authority": false, + "optional": false + }, + { + "name": "freeze_authority", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "account": "account_to_freeze", + "display_name": "Thaw account" + }, + { + "account": "freeze_authority", + "display_name": "Owner" + } + ] + }, + { + "id": 12, + "name": "Transfer Checked", + "is_multisig": true, + "parameters": [ + { + "name": "amount", + "type": "token_amount", + "optional": false + }, + { + "name": "decimals", + "type": "u8", + "optional": false + } + ], + "references": [ + { + "name": "source_account", + "is_authority": false, + "optional": false + }, + { + "name": "token_mint", + "is_authority": false, + "optional": false + }, + { + "name": "destination_account", + "is_authority": false, + "optional": false + }, + { + "name": "owner", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "account": "token_mint", + "display_name": "Token" + }, + { + "account": "destination_account", + "display_name": "Recipient" + }, + { + "parameter": "amount", + "display_name": "Amount" + }, + { + "account": "source_account", + "display_name": "From" + }, + { + "account": "owner", + "display_name": "Owner" + } + ] + }, + { + "id": 13, + "name": "Approve Checked", + "is_multisig": true, + "parameters": [ + { + "name": "amount", + "type": "token_amount", + "optional": false + }, + { + "name": "decimals", + "type": "u8", + "optional": false + } + ], + "references": [ + { + "name": "source_account", + "is_authority": false, + "optional": false + }, + { + "name": "token_mint", + "is_authority": false, + "optional": false + }, + { + "name": "delegate", + "is_authority": false, + "optional": false + }, + { + "name": "owner", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "account": "token_mint", + "display_name": "Approve token" + }, + { + "account": "delegate", + "display_name": "Approve delegate" + }, + { + "parameter": "amount", + "display_name": "Allowance" + }, + { + "account": "source_account", + "display_name": "From" + }, + { + "account": "owner", + "display_name": "Owner" + } + ] + }, + { + "id": 14, + "name": "Mint to Checked", + "is_multisig": true, + "parameters": [ + { + "name": "amount", + "type": "token_amount", + "optional": false + }, + { + "name": "decimals", + "type": "u8", + "optional": false + } + ], + "references": [ + { + "name": "mint", + "is_authority": false, + "optional": false + }, + { + "name": "account_to_mint", + "is_authority": false, + "optional": false + }, + { + "name": "minting_authority", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "account": "mint", + "display_name": "Mint token" + }, + { + "parameter": "amount", + "display_name": "Mint amount" + }, + { + "account": "account_to_mint", + "display_name": "To" + }, + { + "account": "minting_authority", + "display_name": "Owner" + } + ] + }, + { + "id": 15, + "name": "Burn Checked", + "is_multisig": true, + "parameters": [ + { + "name": "amount", + "type": "token_amount", + "optional": false + }, + { + "name": "decimals", + "type": "u8", + "optional": false + } + ], + "references": [ + { + "name": "account_to_burn_from", + "is_authority": false, + "optional": false + }, + { + "name": "token_mint", + "is_authority": false, + "optional": false + }, + { + "name": "owner", + "is_authority": true, + "optional": false + } + ], + "ui_properties": [ + { + "account": "token_mint", + "display_name": "Burn token" + }, + { + "parameter": "amount", + "display_name": "Burn amount" + }, + { + "account": "account_to_burn_from", + "display_name": "From" + }, + { + "account": "owner", + "display_name": "Owner" + } + ] + }, + { + "id": 16, + "name": "Initialize Account 2", + "is_multisig": false, + "parameters": [ + { + "name": "owner", + "type": "pubkey", + "optional": false + } + ], + "references": [ + { + "name": "account_to_initialize", + "is_authority": false, + "optional": false + }, + { + "name": "mint_account", + "is_authority": false, + "optional": false + }, + { + "name": "rent_sysvar", + "is_authority": false, + "optional": false + } + ], + "ui_properties": [ + { + "account": "account_to_initialize", + "display_name": "Init account" + }, + { + "parameter": "owner", + "display_name": "Owner" + }, + { + "account": "mint_account", + "display_name": "Mint" + } + ] + }, + { + "id": 17, + "name": "Sync Native", + "is_multisig": false, + "parameters": [], + "references": [ + { + "name": "token_account", + "is_authority": false, + "optional": false + } + ], + "ui_properties": [ + { + "account": "token_account", + "display_name": "Sync native account" + } + ] + }, + { + "id": 18, + "name": "Initialize Account 3", + "is_multisig": false, + "parameters": [ + { + "name": "owner", + "type": "pubkey", + "optional": false + } + ], + "references": [ + { + "name": "account_to_initialize", + "is_authority": false, + "optional": false + }, + { + "name": "mint_account", + "is_authority": false, + "optional": false + } + ], + "ui_properties": [ + { + "account": "account_to_initialize", + "display_name": "Init account" + }, + { + "parameter": "owner", + "display_name": "Owner" + }, + { + "account": "mint_account", + "display_name": "Mint" + } + ] + }, + { + "id": 22, + "name": "Initialize Immutable Owner", + "is_multisig": false, + "parameters": [], + "references": [ + { + "name": "account_to_initialize", + "is_authority": false, + "optional": false + } + ], + "ui_properties": [ + { + "account": "account_to_initialize", + "display_name": "Init account" + } + ] + } + ] + }, + { + "id": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL", + "name": "Associated Token Account Program", + "instruction_id_length": 1, + "instructions": [ + { + "id": null, + "name": "Create", + "is_multisig": false, + "parameters": [], + "references": [ + { + "name": "funding_account", + "is_authority": true, + "optional": false + }, + { + "name": "associated_token_account", + "is_authority": false, + "optional": false + }, + { + "name": "wallet_address", + "is_authority": false, + "optional": false + }, + { + "name": "token_mint", + "is_authority": false, + "optional": false + }, + { + "name": "system_program", + "is_authority": false, + "optional": false + }, + { + "name": "spl_token", + "is_authority": false, + "optional": false + } + ], + "ui_properties": [ + { + "account": "associated_token_account", + "display_name": "Create token account" + }, + { + "account": "token_mint", + "display_name": "From mint" + }, + { + "account": "wallet_address", + "display_name": "Owned by" + }, + { + "account": "funding_account", + "display_name": "Funded by" + } + ] + }, + { + "id": 1, + "name": "Create Idempotent", + "is_multisig": false, + "parameters": [], + "references": [ + { + "name": "funding_account", + "is_authority": true, + "optional": false + }, + { + "name": "associated_token_account", + "is_authority": false, + "optional": false + }, + { + "name": "wallet_addr", + "is_authority": false, + "optional": false + }, + { + "name": "token_mint", + "is_authority": false, + "optional": false + }, + { + "name": "system_program", + "is_authority": false, + "optional": false + }, + { + "name": "spl_token", + "is_authority": false, + "optional": false + } + ], + "ui_properties": [ + { + "account": "associated_token_account", + "display_name": "Create token account" + }, + { + "account": "token_mint", + "display_name": "From mint" + }, + { + "account": "wallet_addr", + "display_name": "Owned by" + }, + { + "account": "funding_account", + "display_name": "Funded by" + } + ] + }, + { + "id": 2, + "name": "Recover Nested", + "is_multisig": false, + "parameters": [], + "references": [ + { + "name": "nested_account", + "is_authority": true, + "optional": false + }, + { + "name": "token_mint_nested", + "is_authority": false, + "optional": false + }, + { + "name": "associated_token_account", + "is_authority": false, + "optional": false + }, + { + "name": "owner", + "is_authority": false, + "optional": false + }, + { + "name": "token_mint_owner", + "is_authority": false, + "optional": false + }, + { + "name": "wallet_address", + "is_authority": true, + "optional": false + }, + { + "name": "spl_token", + "is_authority": false, + "optional": false + } + ], + "ui_properties": [ + { + "account": "nested_account", + "display_name": "Recover nested token account" + }, + { + "account": "associated_token_account", + "display_name": "Transfer recovered tokens to" + }, + { + "account": "wallet_address", + "display_name": "Transfer recovered SOL to" + } + ] + } + ] + }, + { + "id": "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr", + "name": "Memo Program", + "instruction_id_length": 0, + "instructions": [ + { + "id": null, + "name": "Memo", + "is_multisig": false, + "parameters": [ + { + "name": "memo", + "type": "memo", + "optional": false + } + ], + "references": [ + { + "name": "signer_accounts", + "is_authority": true, + "optional": true + } + ], + "ui_properties": [ + { + "parameter": "memo", + "display_name": "Memo" + }, + { + "account": "signer_accounts", + "display_name": "Signer accounts" + } + ] + } + ] + }, + { + "id": "Memo1UhkJRfHyvLMcVucJwxXeuD728EqVDDwQDxFMNo", + "name": "Memo Legacy Program", + "instruction_id_length": 0, + "instructions": [ + { + "id": null, + "name": "Memo", + "is_multisig": false, + "parameters": [ + { + "name": "memo", + "type": "memo", + "optional": false + } + ], + "references": [ + { + "name": "signer_accounts", + "is_authority": true, + "optional": true + } + ], + "ui_properties": [ + { + "parameter": "memo", + "display_name": "Memo" + }, + { + "account": "signer_accounts", + "display_name": "Signer accounts" + } + ] + } + ] + } + ], + "types": { + "u8": { + "parse": "parse_byte", + "format": "format_int" + }, + "u32": { + "parse": "read_uint32_le", + "format": "format_int" + }, + "u64": { + "parse": "read_uint64_le", + "format": "format_int" + }, + "unix_timestamp": { + "parse": "read_uint64_le", + "format": "format_unix_timestamp" + }, + "lamports": { + "parse": "read_uint64_le", + "format": "format_lamports" + }, + "token_amount": { + "parse": "read_uint64_le", + "format": "format_token_amount", + "required_parameters": ["decimals"] + }, + "pubkey": { + "parse": "parse_pubkey", + "format": "format_pubkey" + }, + "authority": { + "parse": "parse_pubkey", + "format": "format_pubkey" + }, + "string": { + "parse": "parse_string", + "format": "format_identity" + }, + "memo": { + "parse": "parse_memo", + "format": "format_identity" + }, + "StakeAuthorize": { + "is_enum": true, + "parse": "read_uint32_le", + "format": "format_StakeAuthorize", + "fields": [ + { + "name": "Stake", + "value": 0 + }, + { + "name": "Withdraw", + "value": 1 + } + ] + }, + "AuthorityType": { + "is_enum": true, + "parse": "parse_byte", + "format": "format_AuthorityType", + "fields": [ + { + "name": "Mint tokens", + "value": 0 + }, + { + "name": "Freeze account", + "value": 1 + }, + { + "name": "Account owner", + "value": 2 + }, + { + "name": "Close account", + "value": 3 + } + ] + } + } +} diff --git a/core/tools/build_solana_templates b/core/tools/build_solana_templates new file mode 100755 index 000000000..3014687d8 --- /dev/null +++ b/core/tools/build_solana_templates @@ -0,0 +1,64 @@ +#!/usr/bin/env bash +set -e + +CWD=`dirname "$0"` +RENDER="python3 $CWD/build_solana_templates.py" + +PROGRAMS_FILE_PATH="$CWD/../src/apps/solana/transaction/programs.json" + +FW_PATH="$CWD/../src/apps/solana/transaction" +FW_TEMPLATE_PATH="$FW_PATH/instructions.py.mako" +FW_OUTPUT_PATH="$FW_PATH/instructions.py" + +TESTS_PATH="$CWD/../../tests/device_tests/solana/construct" +TESTS_TEMPLATE_PATH="$TESTS_PATH/instructions.py.mako" +TESTS_OUTPUT_PATH="$TESTS_PATH/instructions.py" + +format() { + isort $1 -q + black $1 -q + flake8 $1 -q +} + +check_results() { + TEMPLATE_PATH=$1 + OUTPUT_PATH=$2 + + CHECK_FAIL=0 + TMP=`mktemp` + TARGET=$OUTPUT_PATH + $RENDER $TEMPLATE_PATH -p $PROGRAMS_FILE_PATH -o $TMP + format $TMP + + if ! diff -u "$TARGET" "$TMP"; then + CHECK_FAIL=1 + fi + exit $CHECK_FAIL +} + +set_output_timestamp() { + TEMPLATE_PATH=$1 + OUTPUT_PATH=$2 + + PROGRAMS_FILE_TIMESTAMP=$(date -r $PROGRAMS_FILE_PATH) + TEMPLATE_TIMESTAMP=$(date -r $TEMPLATE_PATH) + + if [[ "$PROGRAMS_FILE_TIMESTAMP" > "$TEMPLATE_TIMESTAMP" ]]; then + touch $OUTPUT_PATH -r $PROGRAMS_FILE_PATH + else + touch $OUTPUT_PATH -r $TEMPLATE_PATH + fi +} + +if [ "$1" = "--check" ]; then + check_results $FW_PATH $FW_OUTPUT_PATH + check_results $TESTS_PATH $TESTS_OUTPUT_PATH +else + $RENDER $FW_PATH -p $PROGRAMS_FILE_PATH -o $FW_OUTPUT_PATH + format $FW_OUTPUT_PATH + set_output_timestamp $FW_TEMPLATE_PATH $FW_OUTPUT_PATH + + $RENDER $TESTS_PATH -p "$PROGRAMS_FILE_PATH" -o $TESTS_OUTPUT_PATH + format $TESTS_OUTPUT_PATH + set_output_timestamp $TESTS_TEMPLATE_PATH $TESTS_OUTPUT_PATH +fi diff --git a/core/tools/build_solana_templates.py b/core/tools/build_solana_templates.py new file mode 100755 index 000000000..fe0c52d56 --- /dev/null +++ b/core/tools/build_solana_templates.py @@ -0,0 +1,22 @@ +# !/usr/bin/env python3 +from json import load + +import click +from mako.template import Template +from munch import munchify + + +@click.command() +@click.argument("template_path", type=str) +@click.option("-p", "--programs-file", type=click.File(mode="r"), default="-") +@click.option("-o", "--out-file", type=click.File(mode="w"), default="-") +def render(template_path, programs_file, out_file): + programs = munchify(load(programs_file)) + + template = Template(filename=f"{template_path}/instructions.py.mako") + + out_file.write(template.render(programs=programs)) + + +if __name__ == "__main__": + render() diff --git a/core/tools/build_templates b/core/tools/build_templates index e6e9af2e4..93053950b 100755 --- a/core/tools/build_templates +++ b/core/tools/build_templates @@ -4,8 +4,8 @@ set -e CWD=`dirname "$0"` RENDER="$CWD/../vendor/trezor-common/tools/cointool.py render" -# Search both in `core/src` and `core/embed` -FIND_TEMPLATES="find $CWD/.. -name *.mako -not -name _proto*" +# Search both in `core/src` and `core/embed` - Solana templates are excluded since those are handled separately +FIND_TEMPLATES="find $CWD/.. -name *.mako -not -name _proto* -not -path *solana*" check_results() { CHECK_FAIL=0 diff --git a/tests/device_tests/solana/construct/instructions.py b/tests/device_tests/solana/construct/instructions.py new file mode 100644 index 000000000..4d4a8e6b7 --- /dev/null +++ b/tests/device_tests/solana/construct/instructions.py @@ -0,0 +1,1404 @@ +# generated from __init__.py.mako +# do not edit manually! + +from enum import Enum + +from construct import ( + Byte, + Const, + GreedyBytes, + GreedyRange, + Int32ul, + Int64ul, + Optional, + Pass, + Select, + Struct, +) + +from .custom_constructs import ( + CompactArray, + CompactStruct, + HexStringAdapter, + Memo, + OptionalParameter, + PublicKey, + String, +) + + +class Program(Enum): + SYSTEM_PROGRAM = "11111111111111111111111111111111" + STAKE_PROGRAM = "Stake11111111111111111111111111111111111111" + COMPUTE_BUDGET_PROGRAM = "ComputeBudget111111111111111111111111111111" + TOKEN_PROGRAM = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + TOKEN_2022_PROGRAM = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" + ASSOCIATED_TOKEN_ACCOUNT_PROGRAM = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" + MEMO_PROGRAM = "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" + MEMO_LEGACY_PROGRAM = "Memo1UhkJRfHyvLMcVucJwxXeuD728EqVDDwQDxFMNo" + + +# System Program begin + + +class SystemProgramInstruction(Enum): + CREATE_ACCOUNT = 0 + ASSIGN = 1 + TRANSFER = 2 + CREATE_ACCOUNT_WITH_SEED = 3 + ADVANCE_NONCE_ACCOUNT = 4 + WITHDRAW_NONCE_ACCOUNT = 5 + INITIALIZE_NONCE_ACCOUNT = 6 + AUTHORIZE_NONCE_ACCOUNT = 7 + ALLOCATE = 8 + ALLOCATE_WITH_SEED = 9 + ASSIGN_WITH_SEED = 10 + TRANSFER_WITH_SEED = 11 + UPGRADE_NONCE_ACCOUNT = 12 + + +SystemProgram_CreateAccount = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "funding_account" / Byte, + "new_account" / Byte, + ), + "data" + / CompactStruct( + "instruction_id" / Const(0, Int32ul), + "lamports" / Int64ul, + "space" / Int64ul, + "owner" / PublicKey, + ), +) + +SystemProgram_Assign = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "assigned_account" / Byte, + ), + "data" + / CompactStruct( + "instruction_id" / Const(1, Int32ul), + "owner" / PublicKey, + ), +) + +SystemProgram_Transfer = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "funding_account" / Byte, + "recipient_account" / Byte, + ), + "data" + / CompactStruct( + "instruction_id" / Const(2, Int32ul), + "lamports" / Int64ul, + ), +) + +SystemProgram_CreateAccountWithSeed = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "funding_account" / Byte, + "created_account" / Byte, + "base_account" / Optional(Byte), + ), + "data" + / CompactStruct( + "instruction_id" / Const(3, Int32ul), + "base" / PublicKey, + "seed" / String, + "lamports" / Int64ul, + "space" / Int64ul, + "owner" / PublicKey, + ), +) + +SystemProgram_AdvanceNonceAccount = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "nonce_account" / Byte, + "recent_blockhashes_sysvar" / Byte, + "nonce_authority" / Byte, + ), + "data" + / CompactStruct( + "instruction_id" / Const(4, Int32ul), + ), +) + +SystemProgram_WithdrawNonceAccount = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "nonce_account" / Byte, + "recipient_account" / Byte, + "recent_blockhashes_sysvar" / Byte, + "rent_sysvar" / Byte, + "nonce_authority" / Byte, + ), + "data" + / CompactStruct( + "instruction_id" / Const(5, Int32ul), + "lamports" / Int64ul, + ), +) + +SystemProgram_InitializeNonceAccount = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "nonce_account" / Byte, + "recent_blockhashes_sysvar" / Byte, + "rent_sysvar" / Byte, + ), + "data" + / CompactStruct( + "instruction_id" / Const(6, Int32ul), + "nonce_authority" / PublicKey, + ), +) + +SystemProgram_AuthorizeNonceAccount = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "nonce_account" / Byte, + "nonce_authority" / Byte, + ), + "data" + / CompactStruct( + "instruction_id" / Const(7, Int32ul), + "nonce_authority" / PublicKey, + ), +) + +SystemProgram_Allocate = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "new_account" / Byte, + ), + "data" + / CompactStruct( + "instruction_id" / Const(8, Int32ul), + "space" / Int64ul, + ), +) + +SystemProgram_AllocateWithSeed = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "allocated_account" / Byte, + "base_account" / Byte, + ), + "data" + / CompactStruct( + "instruction_id" / Const(9, Int32ul), + "base" / PublicKey, + "seed" / String, + "space" / Int64ul, + "owner" / PublicKey, + ), +) + +SystemProgram_AssignWithSeed = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "assigned_account" / Byte, + "base_account" / Byte, + ), + "data" + / CompactStruct( + "instruction_id" / Const(10, Int32ul), + "base" / PublicKey, + "seed" / String, + "owner" / PublicKey, + ), +) + +SystemProgram_TransferWithSeed = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "funding_account" / Byte, + "base_account" / Byte, + "recipient_account" / Byte, + ), + "data" + / CompactStruct( + "instruction_id" / Const(11, Int32ul), + "lamports" / Int64ul, + "from_seed" / String, + "from_owner" / PublicKey, + ), +) + +SystemProgram_UpgradeNonceAccount = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "nonce_account" / Byte, + ), + "data" + / CompactStruct( + "instruction_id" / Const(12, Int32ul), + ), +) + + +SystemProgram_Instruction = Select( + SystemProgram_CreateAccount, + SystemProgram_Assign, + SystemProgram_Transfer, + SystemProgram_CreateAccountWithSeed, + SystemProgram_AdvanceNonceAccount, + SystemProgram_WithdrawNonceAccount, + SystemProgram_InitializeNonceAccount, + SystemProgram_AuthorizeNonceAccount, + SystemProgram_Allocate, + SystemProgram_AllocateWithSeed, + SystemProgram_AssignWithSeed, + SystemProgram_TransferWithSeed, + SystemProgram_UpgradeNonceAccount, +) + +# System Program end + +# Stake Program begin + + +class StakeProgramInstruction(Enum): + INITIALIZE = 0 + AUTHORIZE = 1 + DELEGATE_STAKE = 2 + SPLIT = 3 + WITHDRAW = 4 + DEACTIVATE = 5 + SET_LOCKUP = 6 + MERGE = 7 + AUTHORIZE_WITH_SEED = 8 + INITIALIZE_CHECKED = 9 + AUTHORIZE_CHECKED = 10 + AUTHORIZE_CHECKED_WITH_SEED = 11 + SET_LOCKUP_CHECKED = 12 + + +StakeProgram_Initialize = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "uninitialized_stake_account" / Byte, + "rent_sysvar" / Byte, + ), + "data" + / CompactStruct( + "instruction_id" / Const(0, Int32ul), + "staker" / PublicKey, + "withdrawer" / PublicKey, + "unix_timestamp" / Int64ul, + "epoch" / Int64ul, + "custodian" / PublicKey, + ), +) + +StakeProgram_Authorize = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "stake_account" / Byte, + "clock_sysvar" / Byte, + "stake_or_withdraw_authority" / Byte, + "lockup_authority" / Optional(Byte), + ), + "data" + / CompactStruct( + "instruction_id" / Const(1, Int32ul), + "pubkey" / PublicKey, + "stake_authorize" / Int32ul, + ), +) + +StakeProgram_DelegateStake = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "initialized_stake_account" / Byte, + "vote_account" / Byte, + "clock_sysvar" / Byte, + "stake_history_sysvar" / Byte, + "config_account" / Byte, + "stake_authority" / Byte, + ), + "data" + / CompactStruct( + "instruction_id" / Const(2, Int32ul), + ), +) + +StakeProgram_Split = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "stake_account" / Byte, + "uninitialized_stake_account" / Byte, + "stake_authority" / Byte, + ), + "data" + / CompactStruct( + "instruction_id" / Const(3, Int32ul), + "lamports" / Int64ul, + ), +) + +StakeProgram_Withdraw = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "stake_account" / Byte, + "recipient_account" / Byte, + "clock_sysvar" / Byte, + "stake_history_sysvar" / Byte, + "withdrawal_authority" / Byte, + "lockup_authority" / Optional(Byte), + ), + "data" + / CompactStruct( + "instruction_id" / Const(4, Int32ul), + "lamports" / Int64ul, + ), +) + +StakeProgram_Deactivate = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "delegated_stake_account" / Byte, + "clock_sysvar" / Byte, + "stake_authority" / Byte, + ), + "data" + / CompactStruct( + "instruction_id" / Const(5, Int32ul), + ), +) + +StakeProgram_SetLockup = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "initialized_stake_account" / Byte, + "lockup_or_withdraw_authority" / Byte, + ), + "data" + / CompactStruct( + "instruction_id" / Const(6, Int32ul), + "unix_timestamp" / OptionalParameter(Int64ul), + "epoch" / OptionalParameter(Int64ul), + "custodian" / OptionalParameter(PublicKey), + ), +) + +StakeProgram_Merge = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "destination_stake_account" / Byte, + "source_stake_account" / Byte, + "clock_sysvar" / Byte, + "stake_history_sysvar" / Byte, + "stake_authority" / Byte, + ), + "data" + / CompactStruct( + "instruction_id" / Const(7, Int32ul), + ), +) + +StakeProgram_AuthorizeWithSeed = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "stake_account" / Byte, + "stake_or_withdraw_authority" / Byte, + "clock_sysvar" / Byte, + "lockup_authority" / Optional(Byte), + ), + "data" + / CompactStruct( + "instruction_id" / Const(8, Int32ul), + "new_authorized_pubkey" / PublicKey, + "stake_authorize" / Int32ul, + "authority_seed" / String, + "authority_owner" / PublicKey, + ), +) + +StakeProgram_InitializeChecked = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "uninitialized_stake_account" / Byte, + "rent_sysvar" / Byte, + "stake_authority" / Byte, + "withdrawal_authority" / Byte, + ), + "data" + / CompactStruct( + "instruction_id" / Const(9, Int32ul), + ), +) + +StakeProgram_AuthorizeChecked = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "stake_account" / Byte, + "clock_sysvar" / Byte, + "stake_or_withdraw_authority" / Byte, + "new_stake_or_withdraw_authority" / Byte, + "lockup_authority" / Optional(Byte), + ), + "data" + / CompactStruct( + "instruction_id" / Const(10, Int32ul), + "stake_authorize" / Int32ul, + ), +) + +StakeProgram_AuthorizeCheckedWithSeed = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "stake_account" / Byte, + "stake_or_withdraw_authority" / Byte, + "clock_sysvar" / Byte, + "new_stake_or_withdraw_authority" / Byte, + "lockup_authority" / Optional(Byte), + ), + "data" + / CompactStruct( + "instruction_id" / Const(11, Int32ul), + "stake_authorize" / Int32ul, + "authority_seed" / String, + "authority_owner" / PublicKey, + ), +) + +StakeProgram_SetLockupChecked = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "stake_account" / Byte, + "lockup_or_withdraw_authority" / Byte, + "new_lockup_authority" / Optional(Byte), + ), + "data" + / CompactStruct( + "instruction_id" / Const(12, Int32ul), + "unix_timestamp" / OptionalParameter(Int64ul), + "epoch" / OptionalParameter(Int64ul), + ), +) + + +StakeProgram_Instruction = Select( + StakeProgram_Initialize, + StakeProgram_Authorize, + StakeProgram_DelegateStake, + StakeProgram_Split, + StakeProgram_Withdraw, + StakeProgram_Deactivate, + StakeProgram_SetLockup, + StakeProgram_Merge, + StakeProgram_AuthorizeWithSeed, + StakeProgram_InitializeChecked, + StakeProgram_AuthorizeChecked, + StakeProgram_AuthorizeCheckedWithSeed, + StakeProgram_SetLockupChecked, +) + +# Stake Program end + +# Compute Budget Program begin + + +class ComputeBudgetProgramInstruction(Enum): + REQUEST_HEAP_FRAME = 1 + SET_COMPUTE_UNIT_LIMIT = 2 + SET_COMPUTE_UNIT_PRICE = 3 + + +ComputeBudgetProgram_RequestHeapFrame = Struct( + "program_index" / Byte, + "accounts" / CompactStruct(), + "data" + / CompactStruct( + "instruction_id" / Const(1, Byte), + "bytes" / Int32ul, + ), +) + +ComputeBudgetProgram_SetComputeUnitLimit = Struct( + "program_index" / Byte, + "accounts" / CompactStruct(), + "data" + / CompactStruct( + "instruction_id" / Const(2, Byte), + "units" / Int32ul, + ), +) + +ComputeBudgetProgram_SetComputeUnitPrice = Struct( + "program_index" / Byte, + "accounts" / CompactStruct(), + "data" + / CompactStruct( + "instruction_id" / Const(3, Byte), + "lamports" / Int64ul, + ), +) + + +ComputeBudgetProgram_Instruction = Select( + ComputeBudgetProgram_RequestHeapFrame, + ComputeBudgetProgram_SetComputeUnitLimit, + ComputeBudgetProgram_SetComputeUnitPrice, +) + +# Compute Budget Program end + +# Token Program begin + + +class TokenProgramInstruction(Enum): + INITIALIZE_ACCOUNT = 1 + INITIALIZE_MULTISIG = 2 + TRANSFER = 3 + APPROVE = 4 + REVOKE = 5 + SET_AUTHORITY = 6 + MINT_TO = 7 + BURN = 8 + CLOSE_ACCOUNT = 9 + FREEZE_ACCOUNT = 10 + THAW_ACCOUNT = 11 + TRANSFER_CHECKED = 12 + APPROVE_CHECKED = 13 + MINT_TO_CHECKED = 14 + BURN_CHECKED = 15 + INITIALIZE_ACCOUNT_2 = 16 + SYNC_NATIVE = 17 + INITIALIZE_ACCOUNT_3 = 18 + INITIALIZE_IMMUTABLE_OWNER = 22 + + +TokenProgram_InitializeAccount = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "account_to_initialize" / Byte, + "mint_account" / Byte, + "owner" / Byte, + "rent_sysvar" / Byte, + ), + "data" + / CompactStruct( + "instruction_id" / Const(1, Byte), + ), +) + +TokenProgram_InitializeMultisig = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "multisig_account" / Byte, + "rent_sysvar" / Byte, + "signer_accounts" / Byte, + "multisig_signers" / Optional(GreedyRange(Byte)), + ), + "data" + / CompactStruct( + "instruction_id" / Const(2, Byte), + "number_of_signers" / Byte, + ), +) + +TokenProgram_Transfer = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "source_account" / Byte, + "destination_account" / Byte, + "owner" / Byte, + "multisig_signers" / Optional(GreedyRange(Byte)), + ), + "data" + / CompactStruct( + "instruction_id" / Const(3, Byte), + "amount" / Int64ul, + ), +) + +TokenProgram_Approve = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "source_account" / Byte, + "delegate_account" / Byte, + "owner" / Byte, + "multisig_signers" / Optional(GreedyRange(Byte)), + ), + "data" + / CompactStruct( + "instruction_id" / Const(4, Byte), + "amount" / Int64ul, + ), +) + +TokenProgram_Revoke = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "source_account" / Byte, + "owner" / Byte, + "multisig_signers" / Optional(GreedyRange(Byte)), + ), + "data" + / CompactStruct( + "instruction_id" / Const(5, Byte), + ), +) + +TokenProgram_SetAuthority = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "mint_account" / Byte, + "current_authority" / Byte, + "multisig_signers" / Optional(GreedyRange(Byte)), + ), + "data" + / CompactStruct( + "instruction_id" / Const(6, Byte), + "authority_type" / Byte, + "new_authority" / OptionalParameter(PublicKey), + ), +) + +TokenProgram_MintTo = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "mint" / Byte, + "account_to_mint" / Byte, + "minting_authority" / Byte, + "multisig_signers" / Optional(GreedyRange(Byte)), + ), + "data" + / CompactStruct( + "instruction_id" / Const(7, Byte), + "amount" / Int64ul, + ), +) + +TokenProgram_Burn = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "account_to_burn_from" / Byte, + "token_mint" / Byte, + "owner" / Byte, + "multisig_signers" / Optional(GreedyRange(Byte)), + ), + "data" + / CompactStruct( + "instruction_id" / Const(8, Byte), + "amount" / Int64ul, + ), +) + +TokenProgram_CloseAccount = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "account_to_close" / Byte, + "destination_account" / Byte, + "owner" / Byte, + "multisig_signers" / Optional(GreedyRange(Byte)), + ), + "data" + / CompactStruct( + "instruction_id" / Const(9, Byte), + ), +) + +TokenProgram_FreezeAccount = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "account_to_freeze" / Byte, + "token_mint" / Byte, + "freeze_authority" / Byte, + "multisig_signers" / Optional(GreedyRange(Byte)), + ), + "data" + / CompactStruct( + "instruction_id" / Const(10, Byte), + ), +) + +TokenProgram_ThawAccount = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "account_to_freeze" / Byte, + "token_mint" / Byte, + "freeze_authority" / Byte, + "multisig_signers" / Optional(GreedyRange(Byte)), + ), + "data" + / CompactStruct( + "instruction_id" / Const(11, Byte), + ), +) + +TokenProgram_TransferChecked = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "source_account" / Byte, + "token_mint" / Byte, + "destination_account" / Byte, + "owner" / Byte, + "multisig_signers" / Optional(GreedyRange(Byte)), + ), + "data" + / CompactStruct( + "instruction_id" / Const(12, Byte), + "amount" / Int64ul, + "decimals" / Byte, + ), +) + +TokenProgram_ApproveChecked = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "source_account" / Byte, + "token_mint" / Byte, + "delegate" / Byte, + "owner" / Byte, + "multisig_signers" / Optional(GreedyRange(Byte)), + ), + "data" + / CompactStruct( + "instruction_id" / Const(13, Byte), + "amount" / Int64ul, + "decimals" / Byte, + ), +) + +TokenProgram_MintToChecked = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "mint" / Byte, + "account_to_mint" / Byte, + "minting_authority" / Byte, + "multisig_signers" / Optional(GreedyRange(Byte)), + ), + "data" + / CompactStruct( + "instruction_id" / Const(14, Byte), + "amount" / Int64ul, + "decimals" / Byte, + ), +) + +TokenProgram_BurnChecked = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "account_to_burn_from" / Byte, + "token_mint" / Byte, + "owner" / Byte, + "multisig_signers" / Optional(GreedyRange(Byte)), + ), + "data" + / CompactStruct( + "instruction_id" / Const(15, Byte), + "amount" / Int64ul, + "decimals" / Byte, + ), +) + +TokenProgram_InitializeAccount2 = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "account_to_initialize" / Byte, + "mint_account" / Byte, + "rent_sysvar" / Byte, + ), + "data" + / CompactStruct( + "instruction_id" / Const(16, Byte), + "owner" / PublicKey, + ), +) + +TokenProgram_SyncNative = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "token_account" / Byte, + ), + "data" + / CompactStruct( + "instruction_id" / Const(17, Byte), + ), +) + +TokenProgram_InitializeAccount3 = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "account_to_initialize" / Byte, + "mint_account" / Byte, + ), + "data" + / CompactStruct( + "instruction_id" / Const(18, Byte), + "owner" / PublicKey, + ), +) + +TokenProgram_InitializeImmutableOwner = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "account_to_initialize" / Byte, + ), + "data" + / CompactStruct( + "instruction_id" / Const(22, Byte), + ), +) + + +TokenProgram_Instruction = Select( + TokenProgram_InitializeAccount, + TokenProgram_InitializeMultisig, + TokenProgram_Transfer, + TokenProgram_Approve, + TokenProgram_Revoke, + TokenProgram_SetAuthority, + TokenProgram_MintTo, + TokenProgram_Burn, + TokenProgram_CloseAccount, + TokenProgram_FreezeAccount, + TokenProgram_ThawAccount, + TokenProgram_TransferChecked, + TokenProgram_ApproveChecked, + TokenProgram_MintToChecked, + TokenProgram_BurnChecked, + TokenProgram_InitializeAccount2, + TokenProgram_SyncNative, + TokenProgram_InitializeAccount3, + TokenProgram_InitializeImmutableOwner, +) + +# Token Program end + +# Token 2022 Program begin + + +class Token2022ProgramInstruction(Enum): + INITIALIZE_ACCOUNT = 1 + INITIALIZE_MULTISIG = 2 + TRANSFER = 3 + APPROVE = 4 + REVOKE = 5 + SET_AUTHORITY = 6 + MINT_TO = 7 + BURN = 8 + CLOSE_ACCOUNT = 9 + FREEZE_ACCOUNT = 10 + THAW_ACCOUNT = 11 + TRANSFER_CHECKED = 12 + APPROVE_CHECKED = 13 + MINT_TO_CHECKED = 14 + BURN_CHECKED = 15 + INITIALIZE_ACCOUNT_2 = 16 + SYNC_NATIVE = 17 + INITIALIZE_ACCOUNT_3 = 18 + INITIALIZE_IMMUTABLE_OWNER = 22 + + +Token2022Program_InitializeAccount = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "account_to_initialize" / Byte, + "mint_account" / Byte, + "owner" / Byte, + "rent_sysvar" / Byte, + ), + "data" + / CompactStruct( + "instruction_id" / Const(1, Byte), + ), +) + +Token2022Program_InitializeMultisig = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "multisig_account" / Byte, + "rent_sysvar" / Byte, + "signer_accounts" / Byte, + "multisig_signers" / Optional(GreedyRange(Byte)), + ), + "data" + / CompactStruct( + "instruction_id" / Const(2, Byte), + "number_of_signers" / Byte, + ), +) + +Token2022Program_Transfer = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "source_account" / Byte, + "destination_account" / Byte, + "owner" / Byte, + "multisig_signers" / Optional(GreedyRange(Byte)), + ), + "data" + / CompactStruct( + "instruction_id" / Const(3, Byte), + "amount" / Int64ul, + ), +) + +Token2022Program_Approve = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "source_account" / Byte, + "delegate_account" / Byte, + "owner" / Byte, + "multisig_signers" / Optional(GreedyRange(Byte)), + ), + "data" + / CompactStruct( + "instruction_id" / Const(4, Byte), + "amount" / Int64ul, + ), +) + +Token2022Program_Revoke = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "source_account" / Byte, + "owner" / Byte, + "multisig_signers" / Optional(GreedyRange(Byte)), + ), + "data" + / CompactStruct( + "instruction_id" / Const(5, Byte), + ), +) + +Token2022Program_SetAuthority = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "mint_account" / Byte, + "current_authority" / Byte, + "multisig_signers" / Optional(GreedyRange(Byte)), + ), + "data" + / CompactStruct( + "instruction_id" / Const(6, Byte), + "authority_type" / Byte, + "new_authority" / OptionalParameter(PublicKey), + ), +) + +Token2022Program_MintTo = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "mint" / Byte, + "account_to_mint" / Byte, + "minting_authority" / Byte, + "multisig_signers" / Optional(GreedyRange(Byte)), + ), + "data" + / CompactStruct( + "instruction_id" / Const(7, Byte), + "amount" / Int64ul, + ), +) + +Token2022Program_Burn = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "account_to_burn_from" / Byte, + "token_mint" / Byte, + "owner" / Byte, + "multisig_signers" / Optional(GreedyRange(Byte)), + ), + "data" + / CompactStruct( + "instruction_id" / Const(8, Byte), + "amount" / Int64ul, + ), +) + +Token2022Program_CloseAccount = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "account_to_close" / Byte, + "destination_account" / Byte, + "owner" / Byte, + "multisig_signers" / Optional(GreedyRange(Byte)), + ), + "data" + / CompactStruct( + "instruction_id" / Const(9, Byte), + ), +) + +Token2022Program_FreezeAccount = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "account_to_freeze" / Byte, + "token_mint" / Byte, + "freeze_authority" / Byte, + "multisig_signers" / Optional(GreedyRange(Byte)), + ), + "data" + / CompactStruct( + "instruction_id" / Const(10, Byte), + ), +) + +Token2022Program_ThawAccount = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "account_to_freeze" / Byte, + "token_mint" / Byte, + "freeze_authority" / Byte, + "multisig_signers" / Optional(GreedyRange(Byte)), + ), + "data" + / CompactStruct( + "instruction_id" / Const(11, Byte), + ), +) + +Token2022Program_TransferChecked = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "source_account" / Byte, + "token_mint" / Byte, + "destination_account" / Byte, + "owner" / Byte, + "multisig_signers" / Optional(GreedyRange(Byte)), + ), + "data" + / CompactStruct( + "instruction_id" / Const(12, Byte), + "amount" / Int64ul, + "decimals" / Byte, + ), +) + +Token2022Program_ApproveChecked = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "source_account" / Byte, + "token_mint" / Byte, + "delegate" / Byte, + "owner" / Byte, + "multisig_signers" / Optional(GreedyRange(Byte)), + ), + "data" + / CompactStruct( + "instruction_id" / Const(13, Byte), + "amount" / Int64ul, + "decimals" / Byte, + ), +) + +Token2022Program_MintToChecked = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "mint" / Byte, + "account_to_mint" / Byte, + "minting_authority" / Byte, + "multisig_signers" / Optional(GreedyRange(Byte)), + ), + "data" + / CompactStruct( + "instruction_id" / Const(14, Byte), + "amount" / Int64ul, + "decimals" / Byte, + ), +) + +Token2022Program_BurnChecked = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "account_to_burn_from" / Byte, + "token_mint" / Byte, + "owner" / Byte, + "multisig_signers" / Optional(GreedyRange(Byte)), + ), + "data" + / CompactStruct( + "instruction_id" / Const(15, Byte), + "amount" / Int64ul, + "decimals" / Byte, + ), +) + +Token2022Program_InitializeAccount2 = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "account_to_initialize" / Byte, + "mint_account" / Byte, + "rent_sysvar" / Byte, + ), + "data" + / CompactStruct( + "instruction_id" / Const(16, Byte), + "owner" / PublicKey, + ), +) + +Token2022Program_SyncNative = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "token_account" / Byte, + ), + "data" + / CompactStruct( + "instruction_id" / Const(17, Byte), + ), +) + +Token2022Program_InitializeAccount3 = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "account_to_initialize" / Byte, + "mint_account" / Byte, + ), + "data" + / CompactStruct( + "instruction_id" / Const(18, Byte), + "owner" / PublicKey, + ), +) + +Token2022Program_InitializeImmutableOwner = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "account_to_initialize" / Byte, + ), + "data" + / CompactStruct( + "instruction_id" / Const(22, Byte), + ), +) + + +Token2022Program_Instruction = Select( + Token2022Program_InitializeAccount, + Token2022Program_InitializeMultisig, + Token2022Program_Transfer, + Token2022Program_Approve, + Token2022Program_Revoke, + Token2022Program_SetAuthority, + Token2022Program_MintTo, + Token2022Program_Burn, + Token2022Program_CloseAccount, + Token2022Program_FreezeAccount, + Token2022Program_ThawAccount, + Token2022Program_TransferChecked, + Token2022Program_ApproveChecked, + Token2022Program_MintToChecked, + Token2022Program_BurnChecked, + Token2022Program_InitializeAccount2, + Token2022Program_SyncNative, + Token2022Program_InitializeAccount3, + Token2022Program_InitializeImmutableOwner, +) + +# Token 2022 Program end + +# Associated Token Account Program begin + + +class AssociatedTokenAccountProgramInstruction(Enum): + CREATE = None + CREATE_IDEMPOTENT = 1 + RECOVER_NESTED = 2 + + +AssociatedTokenAccountProgram_Create = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "funding_account" / Byte, + "associated_token_account" / Byte, + "wallet_address" / Byte, + "token_mint" / Byte, + "system_program" / Byte, + "spl_token" / Byte, + ), + "data" + / CompactStruct( + "instruction_id" / Pass, + ), +) + +AssociatedTokenAccountProgram_CreateIdempotent = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "funding_account" / Byte, + "associated_token_account" / Byte, + "wallet_addr" / Byte, + "token_mint" / Byte, + "system_program" / Byte, + "spl_token" / Byte, + ), + "data" + / CompactStruct( + "instruction_id" / Const(1, Byte), + ), +) + +AssociatedTokenAccountProgram_RecoverNested = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "nested_account" / Byte, + "token_mint_nested" / Byte, + "associated_token_account" / Byte, + "owner" / Byte, + "token_mint_owner" / Byte, + "wallet_address" / Byte, + "spl_token" / Byte, + ), + "data" + / CompactStruct( + "instruction_id" / Const(2, Byte), + ), +) + + +AssociatedTokenAccountProgram_Instruction = Select( + AssociatedTokenAccountProgram_Create, + AssociatedTokenAccountProgram_CreateIdempotent, + AssociatedTokenAccountProgram_RecoverNested, +) + +# Associated Token Account Program end + +# Memo Program begin + + +class MemoProgramInstruction(Enum): + MEMO = None + + +MemoProgram_Memo = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "signer_accounts" / Optional(Byte), + ), + "data" + / CompactStruct( + "instruction_id" / Pass, + "memo" / Memo, + ), +) + + +MemoProgram_Instruction = Select( + MemoProgram_Memo, +) + +# Memo Program end + +# Memo Legacy Program begin + + +class MemoLegacyProgramInstruction(Enum): + MEMO = None + + +MemoLegacyProgram_Memo = Struct( + "program_index" / Byte, + "accounts" + / CompactStruct( + "signer_accounts" / Optional(Byte), + ), + "data" + / CompactStruct( + "instruction_id" / Pass, + "memo" / Memo, + ), +) + + +MemoLegacyProgram_Instruction = Select( + MemoLegacyProgram_Memo, +) + +# Memo Legacy Program end + +PROGRAMS = { + "11111111111111111111111111111111": SystemProgram_Instruction, + "Stake11111111111111111111111111111111111111": StakeProgram_Instruction, + "ComputeBudget111111111111111111111111111111": ComputeBudgetProgram_Instruction, + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA": TokenProgram_Instruction, + "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb": Token2022Program_Instruction, + "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL": AssociatedTokenAccountProgram_Instruction, + "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr": MemoProgram_Instruction, + "Memo1UhkJRfHyvLMcVucJwxXeuD728EqVDDwQDxFMNo": MemoLegacyProgram_Instruction, +} + +UnknownInstruction = Struct( + "program_index" / Byte, + "accounts" / CompactArray(Byte), + "data" / HexStringAdapter(GreedyBytes), +) diff --git a/tests/device_tests/solana/construct/instructions.py.mako b/tests/device_tests/solana/construct/instructions.py.mako new file mode 100644 index 000000000..e099b0707 --- /dev/null +++ b/tests/device_tests/solana/construct/instructions.py.mako @@ -0,0 +1,123 @@ +# generated from __init__.py.mako +# do not edit manually! + +<% +CONSTRUCT_TYPES = { + "u64": "Int64ul", + "i64": "Int64ul", + "unix_timestamp": "Int64ul", + "u32": "Int32ul", + "i32": "Int32ul", + "StakeAuthorize": "Int32ul", + "u8": "Byte", + "AuthorityType": "Byte", + "pubkey": "PublicKey", + "authority": "PublicKey", + "string": "String", + "memo": "Memo", +} +INSTRUCTION_TYPES = { + 0: "Pass", + 1: "Byte", + 4: "Int32ul", +} +def upper_snake_case(name): + return "_".join(name.split(" ")).upper() +def camelcase(name): + return "".join([word.capitalize() for word in name.split(" ")]) +def instruction_id(instruction): + return "INS_" + upper_snake_case(instruction.name) +def instruction_struct_name(program, instruction): + return camelcase(program.name) + "_" + camelcase(instruction.name) + "_Instruction" +def instruction_subcon(program, instruction): + if instruction.id is None: + return "Pass" + instruction_id_type = INSTRUCTION_TYPES[program.instruction_id_length] + return f"Const({instruction.id}, {instruction_id_type})" +%>\ +from enum import Enum +from construct import ( + Byte, + Const, + GreedyBytes, + GreedyRange, + Int32ul, + Int64ul, + Optional, + Pass, + Select, + Struct, +) +from .custom_constructs import ( + CompactArray, + CompactStruct, + HexStringAdapter, + Memo, + OptionalParameter, + PublicKey, + String, +) + +class Program(Enum): +% for program in programs.programs: + ${upper_snake_case(program.name)} = "${program.id}" +% endfor + +% for program in programs.programs: + +${"#"} ${program.name} begin + +class ${camelcase(program.name)}Instruction(Enum): + % for instruction in program.instructions: + ${upper_snake_case(instruction.name)} = ${instruction.id} + % endfor + + % for instruction in program.instructions: +${camelcase(program.name)}_${camelcase(instruction.name)} = Struct( + "program_index" / Byte, + "accounts" / CompactStruct( + % for reference in instruction.references: + % if reference.optional: + "${reference.name}" / Optional(Byte), + % else: + "${reference.name}" / Byte, + % endif + % endfor + % if instruction.is_multisig: + "multisig_signers" / Optional(GreedyRange(Byte)) + % endif + ), + "data" / CompactStruct( + "instruction_id" / ${instruction_subcon(program, instruction)}, + % for parameter in instruction.parameters: + % if parameter["optional"]: + "${parameter["name"]}" / OptionalParameter(${CONSTRUCT_TYPES.get(parameter.type)}), + % else: + "${parameter["name"]}" / ${CONSTRUCT_TYPES.get(parameter.type, "Int64ul")}, + % endif + % endfor + ), +) + + % endfor + +${camelcase(program.name)}_Instruction = Select( + %for instruction in program.instructions: + ${camelcase(program.name)}_${camelcase(instruction.name)}, + %endfor +) + +${"#"} ${program.name} end +% endfor + +PROGRAMS = { +% for program in programs.programs: + "${program.id}": ${camelcase(program.name)}_Instruction, +%endfor +} + +UnknownInstruction = Struct( + "program_index" / Byte, + "accounts" / CompactArray(Byte), + "data" / HexStringAdapter(GreedyBytes), +)