From e53121b3c4ee5fe562b8cd27cdff745a1c49d824 Mon Sep 17 00:00:00 2001 From: gabrielkerekes Date: Wed, 18 Oct 2023 12:07:14 +0200 Subject: [PATCH] chore(solana): add `sign_tx` tests --- ...n_tx.associated_token_account_program.json | 94 ++ .../sign_tx.compute_budget_program.json | 70 + .../fixtures/solana/sign_tx.memo_program.json | 78 ++ .../solana/sign_tx.stake_program.json | 707 ++++++++++ .../solana/sign_tx.system_program.json | 586 +++++++++ .../solana/sign_tx.token_program.json | 1140 +++++++++++++++++ .../solana/sign_tx.unknown_instructions.json | 39 + .../solana/construct/custom_constructs.py | 92 ++ .../solana/construct/transaction.py | 37 + tests/device_tests/solana/test_sign_tx.py | 77 ++ 10 files changed, 2920 insertions(+) create mode 100644 common/tests/fixtures/solana/sign_tx.associated_token_account_program.json create mode 100644 common/tests/fixtures/solana/sign_tx.compute_budget_program.json create mode 100644 common/tests/fixtures/solana/sign_tx.memo_program.json create mode 100644 common/tests/fixtures/solana/sign_tx.stake_program.json create mode 100644 common/tests/fixtures/solana/sign_tx.system_program.json create mode 100644 common/tests/fixtures/solana/sign_tx.token_program.json create mode 100644 common/tests/fixtures/solana/sign_tx.unknown_instructions.json create mode 100644 tests/device_tests/solana/construct/custom_constructs.py create mode 100644 tests/device_tests/solana/construct/transaction.py create mode 100644 tests/device_tests/solana/test_sign_tx.py diff --git a/common/tests/fixtures/solana/sign_tx.associated_token_account_program.json b/common/tests/fixtures/solana/sign_tx.associated_token_account_program.json new file mode 100644 index 0000000000..f067142b29 --- /dev/null +++ b/common/tests/fixtures/solana/sign_tx.associated_token_account_program.json @@ -0,0 +1,94 @@ +{ + "setup": { + "mnemonic": "all all all all all all all all all all all all", + "passphrase": "" + }, + "tests": [ + { + "description": "Create Associated Token Account", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 4 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "FUqrjRRtF1LiptdFqaFxipE8R3YfCE4k56xwm5n1piqX", + "11111111111111111111111111111111", + "6YuhWADZyAAxAaVKPm1G5N51RvDBXsnWo4SfsJ47wSoK", + "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL", + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 4, + "accounts": { + "funding_account": 0, + "associated_token_account": 1, + "wallet_address": 0, + "token_mint": 3, + "system_program": 2, + "spl_token": 5 + }, + "data": { + "instruction_id": null + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "629daa88d10bca2315fe4176c323197a22c821026f7f6019cadbcf2769c5bb38ceef7652b5cba7e246a51f131f14fa8d776df63c50a1c4a09a3cf0bf2d446201" + } + }, + { + "description": "Create Associated Token Account Idempotent", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 4 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "FUqrjRRtF1LiptdFqaFxipE8R3YfCE4k56xwm5n1piqX", + "11111111111111111111111111111111", + "6YuhWADZyAAxAaVKPm1G5N51RvDBXsnWo4SfsJ47wSoK", + "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL", + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 4, + "accounts": { + "funding_account": 0, + "associated_token_account": 1, + "wallet_addr": 0, + "token_mint": 3, + "system_program": 2, + "spl_token": 5 + }, + "data": { + "instruction_id": 1 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "c7b7dc9afab413788fa185b85cbf72a90b6f12de583a478a531eaa2f7d13f6cbeae97b539c6859f2c954a9d92fbce8be12b0fe1a5a53df367e715b9793f20301" + } + } + ] +} diff --git a/common/tests/fixtures/solana/sign_tx.compute_budget_program.json b/common/tests/fixtures/solana/sign_tx.compute_budget_program.json new file mode 100644 index 0000000000..86004be79d --- /dev/null +++ b/common/tests/fixtures/solana/sign_tx.compute_budget_program.json @@ -0,0 +1,70 @@ +{ + "setup": { + "mnemonic": "all all all all all all all all all all all all", + "passphrase": "" + }, + "tests": [ + { + "description": "Transfer With Compute Budget", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 2 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "ETxHeBBcuw9Yu4dGuP3oXrD12V5RECvmi8ogQ9PkjyVF", + "11111111111111111111111111111111", + "ComputeBudget111111111111111111111111111111" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 3, + "accounts": {}, + "data": { + "instruction_id": 1, + "bytes": 2048 + } + }, + { + "program_index": 3, + "accounts": {}, + "data": { + "instruction_id": 2, + "units": 200000 + } + }, + { + "program_index": 3, + "accounts": {}, + "data": { + "instruction_id": 3, + "lamports": 8000 + } + }, + { + "program_index": 2, + "accounts": { + "funding_account": 0, + "recipient_account": 1 + }, + "data": { + "instruction_id": 2, + "lamports": 20000000 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "682ba0889bcf9061ce0560fb7f300bfce25ff8ecdc65f1904a3fced1895de5145cf3c73352a811021d930bd224d4789b3c263acc1f1ae0fb48959d8332cc1702" + } + } + ] +} diff --git a/common/tests/fixtures/solana/sign_tx.memo_program.json b/common/tests/fixtures/solana/sign_tx.memo_program.json new file mode 100644 index 0000000000..b624838a5e --- /dev/null +++ b/common/tests/fixtures/solana/sign_tx.memo_program.json @@ -0,0 +1,78 @@ +{ + "setup": { + "mnemonic": "all all all all all all all all all all all all", + "passphrase": "" + }, + "tests": [ + { + "description": "Memo", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 1 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 1, + "accounts": { + "signer_accounts": 0 + }, + "data": { + "instruction_id": null, + "memo": "Hello World" + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "0a69b5df79ea6dc007fea6d9be72a94bb19dd3f957c7634737c33452b2539f870b251cb88ef639b4f5f2720c5de1a6bedf5f9b88b5ee0fa0a9ad87634f121909" + } + }, + { + "description": "Memo Legacy", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 1 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "Memo1UhkJRfHyvLMcVucJwxXeuD728EqVDDwQDxFMNo" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 1, + "accounts": { + "signer_accounts": 0 + }, + "data": { + "instruction_id": null, + "memo": "Hello Legacy World" + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "d52b675ca8a81bc9d3dd87eec309589a32645221fbab8792d5b3bf647528711321fdba67dd8af1276d62b201a5bb12d8b1a870e65341989708ccb25ef7155f08" + } + } + ] +} diff --git a/common/tests/fixtures/solana/sign_tx.stake_program.json b/common/tests/fixtures/solana/sign_tx.stake_program.json new file mode 100644 index 0000000000..025657ba30 --- /dev/null +++ b/common/tests/fixtures/solana/sign_tx.stake_program.json @@ -0,0 +1,707 @@ +{ + "setup": { + "mnemonic": "all all all all all all all all all all all all", + "passphrase": "" + }, + "tests": [ + { + "description": "Initialize Stake Account", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 2 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "ATFXMD5cYiw9yHkvexgx3nf9LNSouEViB5BZBsgwunAv", + "Stake11111111111111111111111111111111111111", + "SysvarRent111111111111111111111111111111111" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 2, + "accounts": { + "uninitialized_stake_account": 1, + "rent_sysvar": 3 + }, + "data": { + "instruction_id": 0, + "staker": "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "withdrawer": "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "unix_timestamp": 20, + "epoch": 330, + "custodian": "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS" + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "196037eae9f57396938a8c673d255a8f34f1d79200fb439a1bcc551484b0a79716e8db42af041f23207f9e9e7603e567ba8fb9b6ffa4f20dad64e1277453530d" + } + }, + { + "description": "Authorize", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 1 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "ATFXMD5cYiw9yHkvexgx3nf9LNSouEViB5BZBsgwunAv", + "SysvarC1ock11111111111111111111111111111111", + "Stake11111111111111111111111111111111111111" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 3, + "accounts": { + "stake_account": 1, + "clock_sysvar": 2, + "stake_or_withdraw_authority": 0, + "lockup_authority": null + }, + "data": { + "instruction_id": 1, + "pubkey": "ETxHeBBcuw9Yu4dGuP3oXrD12V5RECvmi8ogQ9PkjyVF", + "stake_authorize": 0 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "e1c3a670771b50cb1a503ec46fd5674191753eaeb76c6c38a84417123887374e5873c0d27a0e3bf26b745a591ca540dba79113856441e7f606683aecba5cfa00" + } + }, + { + "description": "Delegate", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 5 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "ETxHeBBcuw9Yu4dGuP3oXrD12V5RECvmi8ogQ9PkjyVF", + "Stake11111111111111111111111111111111111111", + "StakeConfig11111111111111111111111111111111", + "SysvarC1ock11111111111111111111111111111111", + "SysvarStakeHistory1111111111111111111111111" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 2, + "accounts": { + "initialized_stake_account": 0, + "vote_account": 1, + "clock_sysvar": 4, + "stake_history_sysvar": 5, + "config_account": 3, + "stake_authority": 0 + }, + "data": { + "instruction_id": 2 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "05d5bbece41d3ff7b330e17112a1249f2dee18ce07df8350ca904e64f9f2bab8b3590b91390f9cb773b9b53262663261d7ea734ef688c1c5fcfc6712310b7000" + } + }, + { + "description": "Split", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 2, + "readonly_signers": 0, + "readonly_non_signers": 2 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "ETxHeBBcuw9Yu4dGuP3oXrD12V5RECvmi8ogQ9PkjyVF", + "11111111111111111111111111111111", + "Stake11111111111111111111111111111111111111" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 2, + "accounts": { + "funding_account": 0, + "new_account": 1 + }, + "data": { + "instruction_id": 0, + "lamports": 0, + "space": 200, + "owner": "Stake11111111111111111111111111111111111111" + } + }, + { + "program_index": 3, + "accounts": { + "stake_account": 0, + "uninitialized_stake_account": 1, + "stake_authority": 0 + }, + "data": { + "instruction_id": 3, + "lamports": 1000000 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "999ba80a6183a2c99b43880190572e457a0398eb8acfa806d2c284cf2ebf9a0878239e8d1e62ac061a568db866424ccc0175c075536e325cb1f14968c0fbdc05" + } + }, + { + "description": "Withdraw", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 3 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "ATFXMD5cYiw9yHkvexgx3nf9LNSouEViB5BZBsgwunAv", + "Stake11111111111111111111111111111111111111", + "SysvarC1ock11111111111111111111111111111111", + "SysvarStakeHistory1111111111111111111111111" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 2, + "accounts": { + "stake_account": 1, + "recipient_account": 0, + "clock_sysvar": 3, + "stake_history_sysvar": 4, + "withdrawal_authority": 0, + "lockup_authority": 0 + }, + "data": { + "instruction_id": 4, + "lamports": 1000000 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "2da1355daca8802daddb33bd79767ca7c4c4f3e79b4949cde10559a1836acbbd409f2227040d6b502d84292e91910ad0f12dc8a151b42e39b130a1dcd165860a" + } + }, + { + "description": "Deactivate", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 2 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "ATFXMD5cYiw9yHkvexgx3nf9LNSouEViB5BZBsgwunAv", + "Stake11111111111111111111111111111111111111", + "SysvarC1ock11111111111111111111111111111111" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 2, + "accounts": { + "delegated_stake_account": 1, + "clock_sysvar": 3, + "stake_authority": 0 + }, + "data": { + "instruction_id": 5 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "6320fa5c4ced21216459f85cc180d9bb69b9f335ba6e9c71ea0482184b41020c0145f72cb0306e7f33967be8828cf4bcbfd960381e87ff0871bf1e4688bef505" + } + }, + { + "description": "Set Lockup - with epoch only", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 1 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "ATFXMD5cYiw9yHkvexgx3nf9LNSouEViB5BZBsgwunAv", + "Stake11111111111111111111111111111111111111" + ], + "blockhash": "6Tq9obRZkiwPGQv7bX8FbMNHFBVKCXsWd5MJqSWw884Z", + "instructions": [ + { + "program_index": 2, + "accounts": { + "initialized_stake_account": 1, + "lockup_or_withdraw_authority": 0 + }, + "data": { + "instruction_id": 6, + "unix_timestamp": { + "is_included": 0 + }, + "epoch": { + "is_included": 1, + "value": 20 + }, + "custodian": { + "is_included": 0 + } + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "6b21c7f625ff58ab64d9f3c54169565a1960d1612b2d5d9f51db1e17a23f3ec76955aac25fce636302c0b8db61c932e80d4031fd019a89aa6ad10c59d8a0f00b" + } + }, + { + "description": "Set Lockup - with all params set", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 1 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "ATFXMD5cYiw9yHkvexgx3nf9LNSouEViB5BZBsgwunAv", + "Stake11111111111111111111111111111111111111" + ], + "blockhash": "ENP1bFTWGR7GiPcPg7TB9ekX82xaham8aFkB7vQeoNaZ", + "instructions": [ + { + "program_index": 2, + "accounts": { + "initialized_stake_account": 1, + "lockup_or_withdraw_authority": 0 + }, + "data": { + "instruction_id": 6, + "unix_timestamp": { + "is_included": 1, + "value": 482196050 + }, + "epoch": { + "is_included": 1, + "value": 20 + }, + "custodian": { + "is_included": 1, + "value": "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS" + } + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "b92c3f408965ceee6512ede6dec12b0436eb62e9631b5f9a4eef33384a745f0d57d583cb808ae41f2cfb24ffa768738724269a3f528be491e64162b016cbce03" + } + }, + { + "description": "Merge", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 3 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "AeDJ1BqA7ruBbd6mEcS1QNxFbT8FQbiBVuN9NqK94Taq", + "ATFXMD5cYiw9yHkvexgx3nf9LNSouEViB5BZBsgwunAv", + "Stake11111111111111111111111111111111111111", + "SysvarC1ock11111111111111111111111111111111", + "SysvarStakeHistory1111111111111111111111111" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 3, + "accounts": { + "destination_stake_account": 2, + "source_stake_account": 1, + "clock_sysvar": 4, + "stake_history_sysvar": 5, + "stake_authority": 0 + }, + "data": { + "instruction_id": 7 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "e2035c812b38b6524698c1e77fff5470471dc5c0a9a163e6a0d236b41f3ccf5ab0c03b2e5694f3776f5cf8c1838e47b429f4e52389e118665e6d609db4e0d30c" + } + }, + { + "description": "Authorize With Seed", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 2 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "ATFXMD5cYiw9yHkvexgx3nf9LNSouEViB5BZBsgwunAv", + "Stake11111111111111111111111111111111111111", + "SysvarC1ock11111111111111111111111111111111" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 2, + "accounts": { + "stake_account": 1, + "stake_or_withdraw_authority": 0, + "clock_sysvar": 3, + "lockup_authority": null + }, + "data": { + "instruction_id": 8, + "new_authorized_pubkey": "ETxHeBBcuw9Yu4dGuP3oXrD12V5RECvmi8ogQ9PkjyVF", + "stake_authorize": 1, + "authority_seed": { + "length": 7, + "chars": "stake:0" + }, + "authority_owner": "11111111111111111111111111111111" + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "2cfb0d5ad4e2674d20ee7c5dc64c5d7068ae2a31019662b940239394769843f7df77d596ff8f9dfac78ab0f264bacc9c38b806d210eddd5870d68d923c558c0b" + } + }, + { + "description": "Initialize Checked", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 3 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "GpX913B4PeKzzukWw4zyqz76smpExLysTTDR4rYUiijM", + "11111111111111111111111111111111", + "Stake11111111111111111111111111111111111111", + "SysvarRent111111111111111111111111111111111" + ], + "blockhash": "2NuqEwZcMwFQyQaKGaLiFSFBpJaW1er26cni1sBDAeKw", + "instructions": [ + { + "program_index": 2, + "accounts": { + "funding_account": 0, + "created_account": 1, + "base_account": 0 + }, + "data": { + "instruction_id": 3, + "base": "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "seed": { + "length": 7, + "chars": "stake:1" + }, + "lamports": 3000000, + "space": 200, + "owner": "Stake11111111111111111111111111111111111111" + } + }, + { + "program_index": 3, + "accounts": { + "uninitialized_stake_account": 1, + "rent_sysvar": 4, + "stake_authority": 0, + "withdrawal_authority": 0 + }, + "data": { + "instruction_id": 9 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "f34b9eb5f586a320b919ad6dcc3f51553d3d08f5a1260279973d9fa4250bc61658a38a51322c0586b0e73b7e66325a46b8f4b60828d35e7da1013e84fa12540e" + } + }, + { + "description": "Authorize Checked", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 2 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "ATFXMD5cYiw9yHkvexgx3nf9LNSouEViB5BZBsgwunAv", + "Stake11111111111111111111111111111111111111", + "SysvarC1ock11111111111111111111111111111111" + ], + "blockhash": "5AMCR1wLcR4nVUn3w6h4cK6UYjkdKc6SXNGP9Hj8vNUc", + "instructions": [ + { + "program_index": 2, + "accounts": { + "stake_account": 1, + "clock_sysvar": 3, + "stake_or_withdraw_authority": 0, + "new_stake_or_withdraw_authority": 0 + }, + "data": { + "instruction_id": 10, + "stake_authorize": 0 + } + }, + { + "program_index": 2, + "accounts": { + "stake_account": 1, + "clock_sysvar": 3, + "stake_or_withdraw_authority": 0, + "new_stake_or_withdraw_authority": 0 + }, + "data": { + "instruction_id": 10, + "stake_authorize": 1 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "fc71a9bb988196ed145373531e9b2bcd590177a398a102779290d665c8cbd5dbc5e8c9144ff1165d98f241ebc0747c0715b1e43056fabf85f15fc594d5460c0b" + } + }, + { + "description": "Authorize Checked with Seed", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 2 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "ATFXMD5cYiw9yHkvexgx3nf9LNSouEViB5BZBsgwunAv", + "Stake11111111111111111111111111111111111111", + "SysvarC1ock11111111111111111111111111111111" + ], + "blockhash": "5AMCR1wLcR4nVUn3w6h4cK6UYjkdKc6SXNGP9Hj8vNUc", + "instructions": [ + { + "program_index": 2, + "accounts": { + "stake_account": 1, + "stake_or_withdraw_authority": 0, + "clock_sysvar": 3, + "new_stake_or_withdraw_authority": 0 + }, + "data": { + "instruction_id": 11, + "stake_authorize": 0, + "authority_seed": { + "length": 11, + "chars": "authority:1" + }, + "authority_owner": "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS" + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "01e7a9a28036b36b8dbe8a68823c03330558dd8c0627fd5f25d2fa1556b43e47e23885cb71790ad444ab8e603dedbe759faa7312d5ff8921025307c42d8a3100" + } + }, + { + "description": "Set Lockup Checked", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 1 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "ATFXMD5cYiw9yHkvexgx3nf9LNSouEViB5BZBsgwunAv", + "Stake11111111111111111111111111111111111111" + ], + "blockhash": "2UZYH9e662w7SoLiwnGyGZY1Mn5YjEkWEozZGm5ViR6Q", + "instructions": [ + { + "program_index": 2, + "accounts": { + "stake_account": 1, + "lockup_or_withdraw_authority": 0, + "new_lockup_authority": 0 + }, + "data": { + "instruction_id": 12, + "unix_timestamp": { + "is_included": 1, + "value": 482196050 + }, + "epoch": { + "is_included": 1, + "value": 20 + } + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "42b06682b7cc946143dece29c7014e408d37768d8dcd28c5293c0b13c35000cbf771886dfd4a2f1cad487621b46167d4b32ecc51c605bef0f450da6761952e05" + } + }, + { + "description": "Create Stake Account", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 2, + "readonly_signers": 0, + "readonly_non_signers": 3 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "ATFXMD5cYiw9yHkvexgx3nf9LNSouEViB5BZBsgwunAv", + "11111111111111111111111111111111", + "Stake11111111111111111111111111111111111111", + "SysvarRent111111111111111111111111111111111" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 2, + "accounts": { + "funding_account": 0, + "new_account": 1 + }, + "data": { + "instruction_id": 0, + "lamports": 20000000, + "space": 1000, + "owner": "Stake11111111111111111111111111111111111111" + } + }, + { + "program_index": 3, + "accounts": { + "uninitialized_stake_account": 1, + "rent_sysvar": 4 + }, + "data": { + "instruction_id": 0, + "staker": "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "withdrawer": "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "unix_timestamp": 0, + "epoch": 0, + "custodian": "11111111111111111111111111111111" + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "e99a383ce8f9fcd0ebbb03fce2c47db188734bd36613d226110dfa9d95ba28ad55c4e3ff36d1c4936538350d96d7aeff024c3e6afbb5c45dfe921a18e981ea0c" + } + } + ] +} diff --git a/common/tests/fixtures/solana/sign_tx.system_program.json b/common/tests/fixtures/solana/sign_tx.system_program.json new file mode 100644 index 0000000000..5d47a8d0c5 --- /dev/null +++ b/common/tests/fixtures/solana/sign_tx.system_program.json @@ -0,0 +1,586 @@ +{ + "setup": { + "mnemonic": "all all all all all all all all all all all all", + "passphrase": "" + }, + "tests": [ + { + "description": "Create Account", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 2, + "readonly_signers": 0, + "readonly_non_signers": 1 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "AeDJ1BqA7ruBbd6mEcS1QNxFbT8FQbiBVuN9NqK94Taq", + "11111111111111111111111111111111" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 2, + "accounts": { + "funding_account": 0, + "new_account": 1 + }, + "data": { + "instruction_id": 0, + "lamports": 20000000, + "space": 1000, + "owner": "11111111111111111111111111111111" + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "aa5d16f3f67860182ac8170c0a10941c1bf2ae788ea0e9a06f09d8a8be0543bc7d9d1d485f7caed99653a5bb17d9ad70768c2fca14f80c7ab79aad19f6c81a00" + } + }, + { + "description": "Assign", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 1 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "11111111111111111111111111111111" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 1, + "accounts": { + "assigned_account": 0 + }, + "data": { + "instruction_id": 1, + "owner": "11111111111111111111111111111111" + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "d533f38bcc0b302d2353ee1883217f7cdb283b749ca1b7251b365a4e8c8742b49e8847b759ab845abe2d0b37f4cc916a91a566e40559f5679794cb458be1750e" + } + }, + { + "description": "Transfer", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 1 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "ETxHeBBcuw9Yu4dGuP3oXrD12V5RECvmi8ogQ9PkjyVF", + "11111111111111111111111111111111" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 2, + "accounts": { + "funding_account": 0, + "recipient_account": 1 + }, + "data": { + "instruction_id": 2, + "lamports": 200000 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "7d9b551808a878b6dd6255c7b775b7afcd2edb011a1918611d9b72c3fd2f5fe89d8bf30ea41fa6dc91f33e20e9eb07527aadf1e082eb746880167d102a76270c" + } + }, + { + "description": "Create Account With Seed", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 1 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "ByFfsNTE1vJcgfqFmdJz8gXVHbDuNUnKXunSpm1hjKxU", + "11111111111111111111111111111111" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 2, + "accounts": { + "funding_account": 0, + "created_account": 1 + }, + "data": { + "instruction_id": 3, + "base": "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "seed": { + "length": 6, + "chars": "seed:1" + }, + "lamports": 20000000, + "space": 0, + "owner": "11111111111111111111111111111111" + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "7a84a43d6397d8e8ae8fc508c78a02edde84e9a027e74545e9fa338757ffee165adc41c32f56b023fa6e1ce1f0b6e5a2723ddcf84e2bac2bfaccad786d1f310a" + } + }, + { + "description": "Advance Nonce Account", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 2 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "AeDJ1BqA7ruBbd6mEcS1QNxFbT8FQbiBVuN9NqK94Taq", + "11111111111111111111111111111111", + "SysvarRecentB1ockHashes11111111111111111111" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 2, + "accounts": { + "nonce_account": 1, + "recent_blockhashes_sysvar": 3, + "nonce_authority": 0 + }, + "data": { + "instruction_id": 4 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "1e87379f8d601f582c23f84daad03450161c37ab4b64822fa845821e2ed5df5e7c922e8e3a87f51f986252016a5ceef0d443542f0c1ca8479cf4d62aa80cfd09" + } + }, + { + "description": "Withdraw Nonce Account", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 3 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "AeDJ1BqA7ruBbd6mEcS1QNxFbT8FQbiBVuN9NqK94Taq", + "11111111111111111111111111111111", + "SysvarRecentB1ockHashes11111111111111111111", + "SysvarRent111111111111111111111111111111111" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 2, + "accounts": { + "nonce_account": 1, + "recipient_account": 0, + "recent_blockhashes_sysvar": 3, + "rent_sysvar": 4, + "nonce_authority": 0 + }, + "data": { + "instruction_id": 5, + "lamports": 200000 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "c43d76dc84a56f5014c7f853a6a7ed41c094cec70c26b602703ec50f5bfe525b96ddcbf8f69eae16d6290f5aca5096e3c5a515d1742d975000883a1c3d04390e" + } + }, + { + "description": "Initialize Nonce Account", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 3 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "AeDJ1BqA7ruBbd6mEcS1QNxFbT8FQbiBVuN9NqK94Taq", + "11111111111111111111111111111111", + "SysvarRecentB1ockHashes11111111111111111111", + "SysvarRent111111111111111111111111111111111" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 2, + "accounts": { + "nonce_account": 1, + "recent_blockhashes_sysvar": 3, + "rent_sysvar": 4 + }, + "data": { + "instruction_id": 6, + "nonce_authority": "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS" + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "7dc7f032ee3ca32a52b11c8f66e414058b6d14a5b21799a4e44201a4cc1394ed8e9237b1e9bb81f56ccf4bdef3034d9fccb257e58945fce3f63f2539039f1306" + } + }, + { + "description": "Authorize Nonce Account", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 1 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "AeDJ1BqA7ruBbd6mEcS1QNxFbT8FQbiBVuN9NqK94Taq", + "11111111111111111111111111111111" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 2, + "accounts": { + "nonce_account": 1, + "nonce_authority": 0 + }, + "data": { + "instruction_id": 7, + "nonce_authority": "ETxHeBBcuw9Yu4dGuP3oXrD12V5RECvmi8ogQ9PkjyVF" + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "cba3c4a5f24c775fc4e39e4e01395caeec0749a6ed0ab1e2beae3db07ba69f22d71cd4c1f11f743d0d394e8d297fc57788a916d1791eb9acae0533e8b125ba03" + } + }, + { + "description": "Allocate", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 1 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "11111111111111111111111111111111" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 1, + "accounts": { + "new_account": 0 + }, + "data": { + "instruction_id": 8, + "space": 200 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "c910c3be30a17014e31e301c24516d44c8d8fc346de9e5e90505ed97c7c62fd1012353d9bb2a24bf254aa7b6627606a28f0e0402547517e506c873bda218a305" + } + }, + { + "description": "Allocate With Seed", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 1 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "ByFfsNTE1vJcgfqFmdJz8gXVHbDuNUnKXunSpm1hjKxU", + "11111111111111111111111111111111" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 2, + "accounts": { + "allocated_account": 1, + "base_account": 0 + }, + "data": { + "instruction_id": 9, + "base": "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "seed": { + "length": 6, + "chars": "seed:0" + }, + "space": 22200, + "owner": "11111111111111111111111111111111" + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "6beb42dfccb317bae7fa4e8ad09e218d27853686207d25b8462f8760c918a21e44c387a55b6750727305eaa995461eb42a4a17aec8d6d7257b45642ed457da07" + } + }, + { + "description": "Assign With Seed", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 1 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "ByFfsNTE1vJcgfqFmdJz8gXVHbDuNUnKXunSpm1hjKxU", + "11111111111111111111111111111111" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 2, + "accounts": { + "assigned_account": 1, + "base_account": 0 + }, + "data": { + "instruction_id": 10, + "base": "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "seed": { + "length": 6, + "chars": "seed:0" + }, + "owner": "11111111111111111111111111111111" + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "3bf731a9508faa94e194c4d0475a266bf19548ac5292a5fc817a62dee2798313a4a8eec118c6648efd7021e684bf3238eda56279af47cbc8567133acfcbfc804" + } + }, + { + "description": "Transfer With Seed", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 1 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "ByFfsNTE1vJcgfqFmdJz8gXVHbDuNUnKXunSpm1hjKxU", + "11111111111111111111111111111111" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 2, + "accounts": { + "funding_account": 0, + "base_account": 0, + "recipient_account": 1 + }, + "data": { + "instruction_id": 11, + "lamports": 200000, + "from_seed": { + "length": 6, + "chars": "seed:0" + }, + "from_owner": "11111111111111111111111111111111" + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "18e6373c7f0374a0901c72957e6931a45bc8572493c591ff0dad975762fb03dafbc1a99e903291bf5c0de665fe961951e43d5fa0c3f48dfdc6e1e2e7c471310b" + } + }, + { + "description": "Lookup tables", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": 0, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 1 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "11111111111111111111111111111111" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 1, + "accounts": { + "funding_account": 0, + "recipient_account": 2 + }, + "data": { + "instruction_id": 2, + "lamports": 20000000 + } + }, + { + "program_index": 1, + "accounts": { + "funding_account": 0, + "recipient_account": 3 + }, + "data": { + "instruction_id": 2, + "lamports": 30000000 + } + }, + { + "program_index": 1, + "accounts": { + "funding_account": 0, + "recipient_account": 4 + }, + "data": { + "instruction_id": 2, + "lamports": 40000000 + } + } + ], + "luts": [ + { + "account": "AeDJ1BqA7ruBbd6mEcS1QNxFbT8FQbiBVuN9NqK94Taq", + "readwrite": [0, 1], + "readonly": [] + }, + { + "account": "H8JEG2wjU2LnjXJUVkivEokcK1pmtHXTyoGeDaBtazCy", + "readwrite": [0], + "readonly": [] + } + ] + } + }, + "result": { + "expected_signature": "18cfc28c0119e9045b3ead4e82cfee79450ecda7e18835d0461278c1df0e6dee4c75ad01fab32c3d395390703fc755e68f8de1832e8b3f8503c0fbc82359af0b" + } + }, + { + "description": "Upgrade Nonce", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 0 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "11111111111111111111111111111111" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 1, + "accounts": { + "nonce_account": 0 + }, + "data": { + "instruction_id": 12 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "94fc370a351e845aae30832ee8101d6859c0fecff4b88cb7ec2faae1f30f930564724093a6ef924f2584898fbf6c3e54101eeaa9a7b04baab421d961341f220f" + } + } + ] +} diff --git a/common/tests/fixtures/solana/sign_tx.token_program.json b/common/tests/fixtures/solana/sign_tx.token_program.json new file mode 100644 index 0000000000..c187dc583e --- /dev/null +++ b/common/tests/fixtures/solana/sign_tx.token_program.json @@ -0,0 +1,1140 @@ +{ + "setup": { + "mnemonic": "all all all all all all all all all all all all", + "passphrase": "" + }, + "tests": [ + { + "description": "Initialize Account", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 3 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "FUqrjRRtF1LiptdFqaFxipE8R3YfCE4k56xwm5n1piqX", + "6YuhWADZyAAxAaVKPm1G5N51RvDBXsnWo4SfsJ47wSoK", + "SysvarRent111111111111111111111111111111111", + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 4, + "accounts": { + "account_to_initialize": 1, + "mint_account": 2, + "owner": 0, + "rent_sysvar": 3 + }, + "data": { + "instruction_id": 1 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "435dadd1e04b3525a7c6a5e7d61bbf8203a76878565ebdcbfa70af88bde7beabab44a3e47f8dddaf5045dae185ebfc40ca54354e6e9983e2353a96ac818d9205" + } + }, + { + "description": "Initialize Multisig", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 3 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "FUqrjRRtF1LiptdFqaFxipE8R3YfCE4k56xwm5n1piqX", + "ETxHeBBcuw9Yu4dGuP3oXrD12V5RECvmi8ogQ9PkjyVF", + "SysvarRent111111111111111111111111111111111", + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 4, + "accounts": { + "multisig_account": 1, + "rent_sysvar": 3, + "signer_accounts": 0, + "multisig_signers": [2] + }, + "data": { + "instruction_id": 2, + "number_of_signers": 2 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "2e85999e1b0488e7aeca92fec8fdd14490f6778d76f1f3b014554282cf7234e7d5423aa075164da9fe6bc740b8183173681ee9dca5a4b7ffa1554f653607ec0e" + } + }, + { + "description": "Transfer", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 1 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "ETxHeBBcuw9Yu4dGuP3oXrD12V5RECvmi8ogQ9PkjyVF", + "FUqrjRRtF1LiptdFqaFxipE8R3YfCE4k56xwm5n1piqX", + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 3, + "accounts": { + "source_account": 2, + "destination_account": 1, + "owner": 0 + }, + "data": { + "instruction_id": 3, + "amount": 200 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "7b118ca14ee39934340ba4ecd3cf1b14d36d61812c22723fed7216fcd001513941de4fc4cee253ab5a6032a210a217677ec42026d34a09b0ab9e64d99fd7e702" + } + }, + { + "description": "Approve", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 2 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "FUqrjRRtF1LiptdFqaFxipE8R3YfCE4k56xwm5n1piqX", + "ETxHeBBcuw9Yu4dGuP3oXrD12V5RECvmi8ogQ9PkjyVF", + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 3, + "accounts": { + "source_account": 1, + "delegate_account": 2, + "owner": 0 + }, + "data": { + "instruction_id": 4, + "amount": 200 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "25394f53e9c019d8fbb4c0e885fe5397c49405818ba0c6faa88987e019e273643913c6da5206a723b101b149bd3618708725dd8261715b65a238bf8b59619a00" + } + }, + { + "description": "Revoke", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 1 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "FUqrjRRtF1LiptdFqaFxipE8R3YfCE4k56xwm5n1piqX", + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 2, + "accounts": { + "source_account": 1, + "owner": 0, + "multisig_signers": [] + }, + "data": { + "instruction_id": 5 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "60f68379e090f56a87d9a3f874356a1f454a7d30857fd5adcdfea2d5fa04a20f3e9f0bfec6aa8b410a2c872852fa2e4bca52694ae98b017f43fe0da3a45b910f" + } + }, + { + "description": "Revoke - Multisig", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 2, + "readonly_signers": 1, + "readonly_non_signers": 2 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "AeDJ1BqA7ruBbd6mEcS1QNxFbT8FQbiBVuN9NqK94Taq", + "FUqrjRRtF1LiptdFqaFxipE8R3YfCE4k56xwm5n1piqX", + "ATFXMD5cYiw9yHkvexgx3nf9LNSouEViB5BZBsgwunAv", + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 4, + "accounts": { + "source_account": 2, + "owner": 3, + "multisig_signers": [0, 1] + }, + "data": { + "instruction_id": 5 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "3886ec0a2d0d93afeabaedae75983952b37d1c9ed09a24f22d3580d8a7f57c789840ecad9161862491e58b8ce92e8b46bc966da3a2a982e89f84e8b5ac39740d" + } + }, + { + "description": "Set Authority", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 1 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "FUqrjRRtF1LiptdFqaFxipE8R3YfCE4k56xwm5n1piqX", + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 2, + "accounts": { + "mint_account": 1, + "current_authority": 0, + "multisig_signers": [] + }, + "data": { + "instruction_id": 6, + "authority_type": 1, + "new_authority": { + "is_included": true, + "value": "AeDJ1BqA7ruBbd6mEcS1QNxFbT8FQbiBVuN9NqK94Taq" + } + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "7a96fb6cc283a10e26c9d330e8f2b2892d23698e008c959c29eb124a9c835fc0125865af4ee2ee267fe5ed03e51029f4244b05a592fd5c7969f5a9890ceef902" + } + }, + { + "description": "Set Authority - Multisig", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 2, + "readonly_signers": 1, + "readonly_non_signers": 1 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "AeDJ1BqA7ruBbd6mEcS1QNxFbT8FQbiBVuN9NqK94Taq", + "FUqrjRRtF1LiptdFqaFxipE8R3YfCE4k56xwm5n1piqX", + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 3, + "accounts": { + "mint_account": 2, + "current_authority": 0, + "multisig_signers": [0, 1] + }, + "data": { + "instruction_id": 6, + "authority_type": 1, + "new_authority": { + "is_included": true, + "value": "ATFXMD5cYiw9yHkvexgx3nf9LNSouEViB5BZBsgwunAv" + } + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "a12a94f3eb362c680f343713789425f9809c54cf4cb5f5fbfd5330cf9e60731cb45c489fe42a07a2bfd0bff1ec64b6ca3389c94aaee1b618893cc9666dc74c0c" + } + }, + { + "description": "Mint To", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 1 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "6YuhWADZyAAxAaVKPm1G5N51RvDBXsnWo4SfsJ47wSoK", + "ETxHeBBcuw9Yu4dGuP3oXrD12V5RECvmi8ogQ9PkjyVF", + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 3, + "accounts": { + "mint": 1, + "account_to_mint": 2, + "minting_authority": 0 + }, + "data": { + "instruction_id": 7, + "amount": 200 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "7c9b8b8eb897a841ecd55f31663a7692f3a4b956057e1984705400746c25d5733ac047466abfd589ee7a242ff61212dbfa0d0122dcbce6ec11de70ba3d195b03" + } + }, + { + "description": "Burn", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 1 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "6YuhWADZyAAxAaVKPm1G5N51RvDBXsnWo4SfsJ47wSoK", + "FUqrjRRtF1LiptdFqaFxipE8R3YfCE4k56xwm5n1piqX", + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 3, + "accounts": { + "account_to_burn_from": 2, + "token_mint": 1, + "owner": 0 + }, + "data": { + "instruction_id": 8, + "amount": 200 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "f08cd2421495a499bea2a97efb938fdb3ef9d62a60b7cff1a6376337337c807b590e6acdd417970d82ae4c06feb71e62cd85982dadbad118964f44ad09d73b03" + } + }, + { + "description": "Close Account", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 1 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "ETxHeBBcuw9Yu4dGuP3oXrD12V5RECvmi8ogQ9PkjyVF", + "FUqrjRRtF1LiptdFqaFxipE8R3YfCE4k56xwm5n1piqX", + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 3, + "accounts": { + "account_to_close": 2, + "destination_account": 1, + "owner": 0, + "multisig_signers": [] + }, + "data": { + "instruction_id": 9 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "9e35cea2c2906c1af2ccfdee04f957ac78e6f7ac032ace7a714d83af238a7c497a9768f235beab72d3e4a74ed465ac33e9a7816a9a151de8175aabe1023d3e07" + } + }, + { + "description": "Close Account - Multisig", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 2, + "readonly_signers": 1, + "readonly_non_signers": 2 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "AeDJ1BqA7ruBbd6mEcS1QNxFbT8FQbiBVuN9NqK94Taq", + "ETxHeBBcuw9Yu4dGuP3oXrD12V5RECvmi8ogQ9PkjyVF", + "FUqrjRRtF1LiptdFqaFxipE8R3YfCE4k56xwm5n1piqX", + "ATFXMD5cYiw9yHkvexgx3nf9LNSouEViB5BZBsgwunAv", + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 5, + "accounts": { + "account_to_close": 3, + "destination_account": 2, + "owner": 4, + "multisig_signers": [0, 1] + }, + "data": { + "instruction_id": 9 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "9d5295e4fc8edce57d7317b74a75b65d361335b6ef5f6a7d510bce2406fa4e83fff3daee9333d234e1bcf6ef3771b60c98090bb9135e09f2ad5d5ef57a35560b" + } + }, + { + "description": "Freeze Account", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 2 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "FUqrjRRtF1LiptdFqaFxipE8R3YfCE4k56xwm5n1piqX", + "6YuhWADZyAAxAaVKPm1G5N51RvDBXsnWo4SfsJ47wSoK", + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 3, + "accounts": { + "account_to_freeze": 1, + "token_mint": 2, + "freeze_authority": 0, + "multisig_signers": [] + }, + "data": { + "instruction_id": 10 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "ec990ee48a25306f8106c77128e80a2741d91aee5482722631e6d165d90e0cecd83e78497d8c8342657d101bad290a1e4bf6ad7b69e84c19b2ad5f30663cc90c" + } + }, + { + "description": "Freeze Account - Multisig", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 2, + "readonly_signers": 1, + "readonly_non_signers": 3 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "AeDJ1BqA7ruBbd6mEcS1QNxFbT8FQbiBVuN9NqK94Taq", + "FUqrjRRtF1LiptdFqaFxipE8R3YfCE4k56xwm5n1piqX", + "6YuhWADZyAAxAaVKPm1G5N51RvDBXsnWo4SfsJ47wSoK", + "ATFXMD5cYiw9yHkvexgx3nf9LNSouEViB5BZBsgwunAv", + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 5, + "accounts": { + "account_to_freeze": 2, + "token_mint": 3, + "freeze_authority": 4, + "multisig_signers": [0, 1] + }, + "data": { + "instruction_id": 10 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "4db87f2e49b77408ab64fdb6a3d152c6185c485fc75576d107888e8b184383e206190e4e3c65f73b26669926dd0bbf148bdf5abe18e556ff382026541358dc04" + } + }, + { + "description": "Thaw Account", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 2 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "FUqrjRRtF1LiptdFqaFxipE8R3YfCE4k56xwm5n1piqX", + "6YuhWADZyAAxAaVKPm1G5N51RvDBXsnWo4SfsJ47wSoK", + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 3, + "accounts": { + "account_to_freeze": 1, + "token_mint": 2, + "freeze_authority": 0, + "multisig_signers": [] + }, + "data": { + "instruction_id": 11 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "0a8c9e195dfe9d6dc39b944345cd14e6470943b75fa5001322e456d35bbe650a53989f64ef43db1e6bef008dd9ae9f3dca8499d31b841821e63698f8d5160b09" + } + }, + { + "description": "Thaw Account - Multisig", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 2, + "readonly_signers": 1, + "readonly_non_signers": 3 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "AeDJ1BqA7ruBbd6mEcS1QNxFbT8FQbiBVuN9NqK94Taq", + "FUqrjRRtF1LiptdFqaFxipE8R3YfCE4k56xwm5n1piqX", + "6YuhWADZyAAxAaVKPm1G5N51RvDBXsnWo4SfsJ47wSoK", + "ATFXMD5cYiw9yHkvexgx3nf9LNSouEViB5BZBsgwunAv", + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 5, + "accounts": { + "account_to_freeze": 2, + "token_mint": 3, + "freeze_authority": 4, + "multisig_signers": [0, 1] + }, + "data": { + "instruction_id": 11 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "bc4fbbf4fd9aa676e080b1b68c17889c8c2fde3d6c4a7f65594f5c83be79a52bfca28757e9e790ecf01368ff4749c5a4a0419aaf50d30b7d4e4e9ebe58afb80b" + } + }, + { + "description": "Transfer Checked", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 2 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "ETxHeBBcuw9Yu4dGuP3oXrD12V5RECvmi8ogQ9PkjyVF", + "FUqrjRRtF1LiptdFqaFxipE8R3YfCE4k56xwm5n1piqX", + "6YuhWADZyAAxAaVKPm1G5N51RvDBXsnWo4SfsJ47wSoK", + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 4, + "accounts": { + "source_account": 2, + "token_mint": 3, + "destination_account": 1, + "owner": 0, + "multisig_signers": [] + }, + "data": { + "instruction_id": 12, + "amount": 200, + "decimals": 1 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "a4b31286dd0e629e33623cab5b7243cd7557727ef51675cb52039fd0d6da717ebc4d0c5b436264db28f8a07f38121bcc79f1a26ad7674b920e786d00f0a86e03" + } + }, + { + "description": "Transfer Checked - Multisig", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 3, + "readonly_signers": 2, + "readonly_non_signers": 3 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "6kkV8JtbvN41c9VXNKRSzMmS8JJ5n2wC7fZicYB7xqJx", + "AeDJ1BqA7ruBbd6mEcS1QNxFbT8FQbiBVuN9NqK94Taq", + "ETxHeBBcuw9Yu4dGuP3oXrD12V5RECvmi8ogQ9PkjyVF", + "FUqrjRRtF1LiptdFqaFxipE8R3YfCE4k56xwm5n1piqX", + "6YuhWADZyAAxAaVKPm1G5N51RvDBXsnWo4SfsJ47wSoK", + "ATFXMD5cYiw9yHkvexgx3nf9LNSouEViB5BZBsgwunAv", + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 7, + "accounts": { + "source_account": 4, + "token_mint": 5, + "destination_account": 3, + "owner": 6, + "multisig_signers": [0, 2, 1] + }, + "data": { + "instruction_id": 12, + "amount": 200, + "decimals": 1 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "d804122db00e0b9b553705c6642d1b61db45de436fb871883e8483bba33b74b3ac0f196fa625051a56f01585ab6fd6e501709419dbdc58482184bd8fa027b708" + } + }, + { + "description": "Approve Checked", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 3 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "FUqrjRRtF1LiptdFqaFxipE8R3YfCE4k56xwm5n1piqX", + "6YuhWADZyAAxAaVKPm1G5N51RvDBXsnWo4SfsJ47wSoK", + "ETxHeBBcuw9Yu4dGuP3oXrD12V5RECvmi8ogQ9PkjyVF", + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 4, + "accounts": { + "source_account": 1, + "token_mint": 2, + "delegate": 3, + "owner": 0, + "multisig_signers": [] + }, + "data": { + "instruction_id": 13, + "amount": 200, + "decimals": 1 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "11aa5c0ed7a8c8e053fef080b850a5bb04b3ea8abc1422e4e9438f3433d039eb92b02555037974a119f04051198d55ec5d7667cca227f99ad206c2c3b77ce800" + } + }, + { + "description": "Approve Checked - Multisig", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 2, + "readonly_signers": 1, + "readonly_non_signers": 4 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "AeDJ1BqA7ruBbd6mEcS1QNxFbT8FQbiBVuN9NqK94Taq", + "FUqrjRRtF1LiptdFqaFxipE8R3YfCE4k56xwm5n1piqX", + "6YuhWADZyAAxAaVKPm1G5N51RvDBXsnWo4SfsJ47wSoK", + "ATFXMD5cYiw9yHkvexgx3nf9LNSouEViB5BZBsgwunAv", + "ETxHeBBcuw9Yu4dGuP3oXrD12V5RECvmi8ogQ9PkjyVF", + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 6, + "accounts": { + "source_account": 2, + "token_mint": 3, + "delegate": 5, + "owner": 4, + "multisig_signers": [0, 1] + }, + "data": { + "instruction_id": 13, + "amount": 200, + "decimals": 1 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "6ef8747db637d2a861f0bc17cbf67514f258aae901917741a05b5a95c095b5dc849882629fd05da27a81f94ffd5f8422719f9687814c26cb169c9d3ca6bc330a" + } + }, + { + "description": "Mint To Checked", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 1 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "6YuhWADZyAAxAaVKPm1G5N51RvDBXsnWo4SfsJ47wSoK", + "ETxHeBBcuw9Yu4dGuP3oXrD12V5RECvmi8ogQ9PkjyVF", + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 3, + "accounts": { + "mint": 1, + "account_to_mint": 2, + "minting_authority": 0, + "multisig_signers": [] + }, + "data": { + "instruction_id": 14, + "amount": 200, + "decimals": 2 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "f10e8fbe7726f5887cb9753801eccaf5c035bde5b2fa80d3ecd297278e3c263034c120b25d5710fb79ea1aeac7721f8357f9a62820f89f459da33a232293610e" + } + }, + { + "description": "Mint To Checked - Multisig", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 2, + "readonly_signers": 1, + "readonly_non_signers": 2 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "AeDJ1BqA7ruBbd6mEcS1QNxFbT8FQbiBVuN9NqK94Taq", + "6YuhWADZyAAxAaVKPm1G5N51RvDBXsnWo4SfsJ47wSoK", + "ETxHeBBcuw9Yu4dGuP3oXrD12V5RECvmi8ogQ9PkjyVF", + "ATFXMD5cYiw9yHkvexgx3nf9LNSouEViB5BZBsgwunAv", + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 5, + "accounts": { + "mint": 2, + "account_to_mint": 3, + "minting_authority": 4, + "multisig_signers": [0, 1] + }, + "data": { + "instruction_id": 14, + "amount": 200, + "decimals": 2 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "51c1896af29e82c58d5f4162c0ae364036fb80dde462cd2e3733cb597249024500b963ad1df1141cbc4a8c56f0c93c75353ea80aac2a3c8e08bf6bb9d6dc690b" + } + }, + { + "description": "Burn Checked", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 2, + "readonly_signers": 1, + "readonly_non_signers": 1 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "AeDJ1BqA7ruBbd6mEcS1QNxFbT8FQbiBVuN9NqK94Taq", + "6YuhWADZyAAxAaVKPm1G5N51RvDBXsnWo4SfsJ47wSoK", + "FUqrjRRtF1LiptdFqaFxipE8R3YfCE4k56xwm5n1piqX", + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 4, + "accounts": { + "account_to_burn_from": 3, + "token_mint": 2, + "owner": 0, + "multisig_signers": [0, 1] + }, + "data": { + "instruction_id": 15, + "amount": 200, + "decimals": 2 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "e9983f1772a4e1d34867a51f0267f7adbd821ca768d53fef847cb287e9e6e7e008705d0c8ef21a9899990191a21dba2df0dc09b1e4f7fd2b8d5ae163d545ed01" + } + }, + { + "description": "Burn Checked - Multisig", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 2, + "readonly_signers": 1, + "readonly_non_signers": 2 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "AeDJ1BqA7ruBbd6mEcS1QNxFbT8FQbiBVuN9NqK94Taq", + "6YuhWADZyAAxAaVKPm1G5N51RvDBXsnWo4SfsJ47wSoK", + "FUqrjRRtF1LiptdFqaFxipE8R3YfCE4k56xwm5n1piqX", + "ATFXMD5cYiw9yHkvexgx3nf9LNSouEViB5BZBsgwunAv", + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 5, + "accounts": { + "account_to_burn_from": 3, + "token_mint": 2, + "owner": 4, + "multisig_signers": [0, 1] + }, + "data": { + "instruction_id": 15, + "amount": 200, + "decimals": 2 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "b7f8e2bdc3ce311e335f0da714524a814cc778e7c32a8813078c58d32b725761ecd3a721e6998761335ebea7ef04b1e826071f4bc49f4071da28e9c8aa278901" + } + }, + { + "description": "Initialize Token Account 2", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 3 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "FUqrjRRtF1LiptdFqaFxipE8R3YfCE4k56xwm5n1piqX", + "6YuhWADZyAAxAaVKPm1G5N51RvDBXsnWo4SfsJ47wSoK", + "SysvarRent111111111111111111111111111111111", + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 4, + "accounts": { + "account_to_initialize": 1, + "mint_account": 2, + "rent_sysvar": 3 + }, + "data": { + "instruction_id": 16, + "owner": "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS" + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "c4d5b981889a13c5da59fe38414839a6135ed0a623057e6dc55ed04abda77a9fedf877ef83645470e1cc7f27e70d017fecda5a5704f99c090bb7d2ba0f03940d" + } + }, + { + "description": "Sync Native", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 1 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "FUqrjRRtF1LiptdFqaFxipE8R3YfCE4k56xwm5n1piqX", + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 2, + "accounts": { + "token_account": 1 + }, + "data": { + "instruction_id": 17 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "edceab80e0feb58d4135ee0c2d457935bba26e9af4c19d4da490ed8ee808fffca14c0d1ffd3130714408f5d2448a8f47eedcca8be4653eafd9f0698c5643f40e" + } + }, + { + "description": "Initialize Token Account 3", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 2 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "FUqrjRRtF1LiptdFqaFxipE8R3YfCE4k56xwm5n1piqX", + "6YuhWADZyAAxAaVKPm1G5N51RvDBXsnWo4SfsJ47wSoK", + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 3, + "accounts": { + "account_to_initialize": 1, + "mint_account": 2 + }, + "data": { + "instruction_id": 18, + "owner": "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS" + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "9fe446a0309ff62f063e12ed459b51ea36ffb718ccb857c1bb23e5cf91ffc976084c9aebd9ea040cf340e3bf867c9057df8907fb8c295ff4b7c928768436020a" + } + }, + { + "description": "Initialize Immutable Owner", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 1, + "readonly_signers": 0, + "readonly_non_signers": 1 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "FUqrjRRtF1LiptdFqaFxipE8R3YfCE4k56xwm5n1piqX", + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 2, + "accounts": { + "account_to_initialize": 1 + }, + "data": { + "instruction_id": 22 + } + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "7fba86704c3fb19490836ae399598c03ebe3abe83a8938fcd7001664a60dd3fa02900ef1280ac40fb37acc776d4e9b02892b86991b2b73b1241d6b8eade43000" + } + } + ] +} diff --git a/common/tests/fixtures/solana/sign_tx.unknown_instructions.json b/common/tests/fixtures/solana/sign_tx.unknown_instructions.json new file mode 100644 index 0000000000..5408768bad --- /dev/null +++ b/common/tests/fixtures/solana/sign_tx.unknown_instructions.json @@ -0,0 +1,39 @@ +{ + "setup": { + "mnemonic": "all all all all all all all all all all all all", + "passphrase": "" + }, + "tests": [ + { + "description": "Unknown instruction", + "parameters": { + "address": "m/44'/501'/0'/0'", + "construct": { + "version": null, + "header": { + "signers": 2, + "readonly_signers": 0, + "readonly_non_signers": 1 + }, + "accounts": [ + "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS", + "AeDJ1BqA7ruBbd6mEcS1QNxFbT8FQbiBVuN9NqK94Taq", + "AeDJ1BqA7ruBbd6mEcS1QNxFbT8FQbiBVuN9NqK94Taq" + ], + "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak", + "instructions": [ + { + "program_index": 2, + "accounts": [0, 1], + "data": "04deadbeef" + } + ], + "luts": [] + } + }, + "result": { + "expected_signature": "90093762546ad274def9b20ca6c441564193f2c7213cac704aefc6b7d65ebb315415fa7528728279a6688e2c99aa572d5af17b21a15a1d06b94e03df4ce53205" + } + } + ] +} diff --git a/tests/device_tests/solana/construct/custom_constructs.py b/tests/device_tests/solana/construct/custom_constructs.py new file mode 100644 index 0000000000..a1f41805cb --- /dev/null +++ b/tests/device_tests/solana/construct/custom_constructs.py @@ -0,0 +1,92 @@ +from construct import ( + AdaptationError, + Adapter, + Byte, + Bytes, + Construct, + GreedyString, + If, + Int64ul, + Optional, + PaddedString, + Prefixed, + PrefixedArray, + Struct, + Validator, + VarInt, + this, +) + +from trezorlib.tools import b58decode, b58encode + + +def _find_in_context(context, key: str): + if key in context: + return context[key] + elif context._ is not None: + return _find_in_context(context._, key) + else: + return None + + +class VersionEncodingAdapter(Adapter): + def _decode(self, obj: int, context, path) -> str | int: + if obj & 0x80: + return obj - 0x80 + + raise AdaptationError + + def _encode(self, obj: int, context, path) -> int: + return obj | 0x80 + + +Version = Optional(VersionEncodingAdapter(Byte)) + + +class CompactU16Validator(Validator): + def _validate(self, obj: int, context, path) -> bool: + return obj < 0x1_0000 + + +CompactU16 = CompactU16Validator(VarInt) + + +def CompactArray(subcon: Construct): + return PrefixedArray(CompactU16, subcon) + + +def CompactStruct(*subcons, **subconskw): + return Prefixed(CompactU16, Struct(*subcons, **subconskw)) + + +class B58Adapter(Adapter): + def _decode(self, obj: str, context, path) -> str: + # decode/encode is flipped because we are deserializing ("decoding") by representing ("encoding") the bytes in Base58 + return b58encode(obj) + + def _encode(self, obj: str, context, path) -> bytes: + # decode/encode is flipped because we are serializing ("encoding") by parsing ("decoding") the Base58 string + return b58decode(obj) + + +PublicKey = B58Adapter(Bytes(32)) + + +class HexStringAdapter(Adapter): + def _decode(self, obj: bytes, context, path) -> str: + return obj.hex() + + def _encode(self, obj: str, context, path) -> bytes: + return bytes.fromhex(obj) + + +Memo = GreedyString("utf8") + +String = Struct("length" / Int64ul, "chars" / PaddedString(this.length, "utf-8")) + + +def OptionalParameter(subcon: Construct): + return Struct( + "is_included" / Byte, + "value" / Optional(If(this.is_included == 1, subcon)), + ) diff --git a/tests/device_tests/solana/construct/transaction.py b/tests/device_tests/solana/construct/transaction.py new file mode 100644 index 0000000000..285294c269 --- /dev/null +++ b/tests/device_tests/solana/construct/transaction.py @@ -0,0 +1,37 @@ +from construct import Byte, GreedyBytes, If, Int8ul, Prefixed, RawCopy, Struct, this + +from .custom_constructs import CompactArray, CompactU16, PublicKey, Version + +Header = Struct( + "signers" / Int8ul, + "readonly_signers" / Int8ul, + "readonly_non_signers" / Int8ul, +) + +Accounts = CompactArray(PublicKey) + + +Lut = Struct( + "account" / PublicKey, + "readwrite" / CompactArray(Int8ul), + "readonly" / CompactArray(Int8ul), +) + +Luts = CompactArray(Lut) + +RawInstruction = RawCopy( + Struct( + "program_id" / Byte, + "accounts" / CompactArray(Byte), + "data" / Prefixed(CompactU16, GreedyBytes), + ) +) + +Message = Struct( + "version" / Version, + "header" / Header, + "accounts" / Accounts, + "blockhash" / PublicKey, + "instructions" / CompactArray(RawInstruction), + "luts" / If(this.version != None, Luts), # noqa: E711 +) diff --git a/tests/device_tests/solana/test_sign_tx.py b/tests/device_tests/solana/test_sign_tx.py new file mode 100644 index 0000000000..d59f24bd99 --- /dev/null +++ b/tests/device_tests/solana/test_sign_tx.py @@ -0,0 +1,77 @@ +# This file is part of the Trezor project. +# +# Copyright (C) 2012-2023 SatoshiLabs and contributors +# +# This library is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the License along with this library. +# If not, see . + +import pytest + +from trezorlib.debuglink import TrezorClientDebugLink as Client +from trezorlib.solana import sign_tx +from trezorlib.tools import parse_path + +from ...common import parametrize_using_common_fixtures +from .construct.instructions import PROGRAMS, UnknownInstruction +from .construct.transaction import Message, RawInstruction + +pytestmark = [ + pytest.mark.altcoin, + pytest.mark.solana, + pytest.mark.skip_t1, +] + + +@parametrize_using_common_fixtures( + "solana/sign_tx.system_program.json", + "solana/sign_tx.stake_program.json", + "solana/sign_tx.associated_token_account_program.json", + "solana/sign_tx.memo_program.json", + "solana/sign_tx.compute_budget_program.json", + "solana/sign_tx.token_program.json", + "solana/sign_tx.unknown_instructions.json", +) +def test_solana_sign_tx(client: Client, parameters, result): + client.init_device(new_session=True) + + serialized_tx = _serialize_tx(parameters["construct"]) + + actual_result = sign_tx( + client, + address_n=parse_path(parameters["address"]), + serialized_tx=serialized_tx, + ) + + assert actual_result.signature == bytes.fromhex(result["expected_signature"]) + + +def _serialize_tx(tx_construct): + serialized_instructions = [] + for instruction in tx_construct["instructions"]: + program = tx_construct["accounts"][instruction["program_index"]] + builder = PROGRAMS.get(program, UnknownInstruction) + serialized_instruction = builder.build(instruction) + raw_instruction = RawInstruction.parse(serialized_instruction) + serialized_instructions.append(raw_instruction) + + message_construct = { + "version": tx_construct["version"], + "header": tx_construct["header"], + "accounts": tx_construct["accounts"], + "blockhash": tx_construct["blockhash"], + "instructions": serialized_instructions, + "luts": tx_construct["luts"], + } + + return Message.build( + message_construct, + )