diff --git a/src/handle_sign_message.c b/src/handle_sign_message.c index f8c50a4a..965e9975 100644 --- a/src/handle_sign_message.c +++ b/src/handle_sign_message.c @@ -125,7 +125,9 @@ static bool check_swap_validity_native(const SummaryItemKind_t kinds[MAX_TRANSAC break; } if (strcmp(G_transaction_summary_title, "Transfer") != 0) { - PRINTF("Refused title '%s', expecting '%s'\n", G_transaction_summary_title, "Transfer"); + PRINTF("Refused title '%s', expecting '%s'\n", + G_transaction_summary_title, + "Transfer"); return false; } if (!check_swap_amount(G_transaction_summary_text)) { @@ -137,7 +139,9 @@ static bool check_swap_validity_native(const SummaryItemKind_t kinds[MAX_TRANSAC case SummaryItemPubkey: if (strcmp(G_transaction_summary_title, "Recipient") != 0) { - PRINTF("Refused title '%s', expecting '%s'\n", G_transaction_summary_title, "Recipient"); + PRINTF("Refused title '%s', expecting '%s'\n", + G_transaction_summary_title, + "Recipient"); return false; } if (!check_swap_recipient(G_transaction_summary_text)) { @@ -186,7 +190,9 @@ static bool check_swap_validity_token(const SummaryItemKind_t kinds[MAX_TRANSACT switch (kinds[i]) { case SummaryItemTokenAmount: if (strcmp(G_transaction_summary_title, "Transfer tokens") != 0) { - PRINTF("Refused title '%s', expecting '%s'\n", G_transaction_summary_title, "Transfer tokens"); + PRINTF("Refused title '%s', expecting '%s'\n", + G_transaction_summary_title, + "Transfer tokens"); return false; } if (!check_swap_amount(G_transaction_summary_text)) { @@ -209,8 +215,9 @@ static bool check_swap_validity_token(const SummaryItemKind_t kinds[MAX_TRANSACT case SummaryItemPubkey: if (strcmp(G_transaction_summary_title, "Create token account") == 0) { - if (strcmp(g_trusted_info.encoded_token_address, G_transaction_summary_text) != 0) { - PRINTF("ATA address of create token account does not match with mint address in descriptor\n"); + if (strcmp(g_trusted_info.encoded_token_address, G_transaction_summary_text) != + 0) { + PRINTF("Create ATA address does not match with address in descriptor\n"); return false; } create_token_account_received = true; @@ -228,8 +235,10 @@ static bool check_swap_validity_token(const SummaryItemKind_t kinds[MAX_TRANSACT break; } else if (strcmp(G_transaction_summary_title, "Token address") == 0) { // MINT - if (strcmp(g_trusted_info.encoded_mint_address, G_transaction_summary_text) != 0) { - // This case should never happen because this is already checked at TX parsing + if (strcmp(g_trusted_info.encoded_mint_address, G_transaction_summary_text) != + 0) { + // This case should never happen because this is already checked at TX + // parsing PRINTF("Mint address does not match with mint address in descriptor\n"); return false; } @@ -239,8 +248,10 @@ static bool check_swap_validity_token(const SummaryItemKind_t kinds[MAX_TRANSACT break; } else if (strcmp(G_transaction_summary_title, "To (token account)") == 0) { // Destination ATA - if (strcmp(g_trusted_info.encoded_token_address, G_transaction_summary_text) != 0) { - // This case should never happen because this is already checked at TX parsing + if (strcmp(g_trusted_info.encoded_token_address, G_transaction_summary_text) != + 0) { + // This case should never happen because this is already checked at TX + // parsing PRINTF("Dest ATA address does not match with ATA in descriptor\n"); return false; } diff --git a/src/swap/handle_check_address.c b/src/swap/handle_check_address.c index 4f964191..29c6bb35 100644 --- a/src/swap/handle_check_address.c +++ b/src/swap/handle_check_address.c @@ -27,11 +27,6 @@ int handle_check_address(const check_address_parameters_t *params) { PRINTF("Inside Solana handle_check_address\n"); PRINTF("Params on the address %d\n", (unsigned int) params); - // if (params->coin_configuration != NULL || params->coin_configuration_length != 0) { - // PRINTF("No coin_configuration expected\n"); - // return 0; - // } - if (params->address_parameters == NULL) { PRINTF("derivation path expected\n"); return 0; diff --git a/src/swap/handle_get_printable_amount.c b/src/swap/handle_get_printable_amount.c index f5938fdd..11225d99 100644 --- a/src/swap/handle_get_printable_amount.c +++ b/src/swap/handle_get_printable_amount.c @@ -3,8 +3,7 @@ #include "swap_utils.h" #include "utils.h" #include "sol/printer.h" - -#define MAX_SWAP_TOKEN_LENGTH 15 +#include "swap_common.h" /* return 0 on error, 1 otherwise */ int handle_get_printable_amount(get_printable_amount_parameters_t* params) { diff --git a/src/swap/handle_swap_sign_transaction.c b/src/swap/handle_swap_sign_transaction.c index c5d4b68c..6c928a4c 100644 --- a/src/swap/handle_swap_sign_transaction.c +++ b/src/swap/handle_swap_sign_transaction.c @@ -4,10 +4,9 @@ #include "swap_lib_calls.h" #include "swap_utils.h" #include "sol/printer.h" +#include "swap_common.h" #include "util.h" -#define MAX_SWAP_TOKEN_LENGTH 15 - typedef struct swap_validated_s { bool initialized; uint8_t decimals; diff --git a/src/swap/swap_common.h b/src/swap/swap_common.h new file mode 100644 index 00000000..c1872da1 --- /dev/null +++ b/src/swap/swap_common.h @@ -0,0 +1,3 @@ +#pragma once + +#define MAX_SWAP_TOKEN_LENGTH 15 diff --git a/tests/python/snapshots/nanosp/test_solana_trusted_name_create/00000.png b/tests/python/snapshots/nanosp/test_solana_trusted_name_create/00000.png new file mode 100644 index 00000000..d13ce91a Binary files /dev/null and b/tests/python/snapshots/nanosp/test_solana_trusted_name_create/00000.png differ diff --git a/tests/python/snapshots/nanosp/test_solana_trusted_name_create/00001.png b/tests/python/snapshots/nanosp/test_solana_trusted_name_create/00001.png new file mode 100644 index 00000000..215ae65e Binary files /dev/null and b/tests/python/snapshots/nanosp/test_solana_trusted_name_create/00001.png differ diff --git a/tests/python/snapshots/nanosp/test_solana_trusted_name_create/00002.png b/tests/python/snapshots/nanosp/test_solana_trusted_name_create/00002.png new file mode 100644 index 00000000..d84c6530 Binary files /dev/null and b/tests/python/snapshots/nanosp/test_solana_trusted_name_create/00002.png differ diff --git a/tests/python/snapshots/nanosp/test_solana_trusted_name_create/00003.png b/tests/python/snapshots/nanosp/test_solana_trusted_name_create/00003.png new file mode 100644 index 00000000..e8534877 Binary files /dev/null and b/tests/python/snapshots/nanosp/test_solana_trusted_name_create/00003.png differ diff --git a/tests/python/snapshots/nanosp/test_solana_trusted_name_create/00004.png b/tests/python/snapshots/nanosp/test_solana_trusted_name_create/00004.png new file mode 100644 index 00000000..4ba85ca6 Binary files /dev/null and b/tests/python/snapshots/nanosp/test_solana_trusted_name_create/00004.png differ diff --git a/tests/python/snapshots/nanosp/test_solana_trusted_name_create/00005.png b/tests/python/snapshots/nanosp/test_solana_trusted_name_create/00005.png new file mode 100644 index 00000000..ea96ac2d Binary files /dev/null and b/tests/python/snapshots/nanosp/test_solana_trusted_name_create/00005.png differ diff --git a/tests/python/snapshots/nanosp/test_solana_trusted_name_create/00006.png b/tests/python/snapshots/nanosp/test_solana_trusted_name_create/00006.png new file mode 100644 index 00000000..d84c6530 Binary files /dev/null and b/tests/python/snapshots/nanosp/test_solana_trusted_name_create/00006.png differ diff --git a/tests/python/snapshots/nanosp/test_solana_trusted_name_create/00007.png b/tests/python/snapshots/nanosp/test_solana_trusted_name_create/00007.png new file mode 100644 index 00000000..9e29289d Binary files /dev/null and b/tests/python/snapshots/nanosp/test_solana_trusted_name_create/00007.png differ diff --git a/tests/python/snapshots/nanosp/test_solana_trusted_name_create/00008.png b/tests/python/snapshots/nanosp/test_solana_trusted_name_create/00008.png new file mode 100644 index 00000000..c81d56b1 Binary files /dev/null and b/tests/python/snapshots/nanosp/test_solana_trusted_name_create/00008.png differ diff --git a/tests/python/snapshots/nanosp/test_solana_trusted_name_create/00009.png b/tests/python/snapshots/nanosp/test_solana_trusted_name_create/00009.png new file mode 100644 index 00000000..53ae6519 Binary files /dev/null and b/tests/python/snapshots/nanosp/test_solana_trusted_name_create/00009.png differ diff --git a/tests/python/snapshots/nanosp/test_solana_trusted_name_create/00010.png b/tests/python/snapshots/nanosp/test_solana_trusted_name_create/00010.png new file mode 100644 index 00000000..890ae49f Binary files /dev/null and b/tests/python/snapshots/nanosp/test_solana_trusted_name_create/00010.png differ diff --git a/tests/python/snapshots/nanox/test_send_spl_trusted_name/00000.png b/tests/python/snapshots/nanox/test_send_spl_trusted_name/00000.png new file mode 100644 index 00000000..5b82b0f8 Binary files /dev/null and b/tests/python/snapshots/nanox/test_send_spl_trusted_name/00000.png differ diff --git a/tests/python/snapshots/nanox/test_send_spl_trusted_name/00001.png b/tests/python/snapshots/nanox/test_send_spl_trusted_name/00001.png new file mode 100644 index 00000000..ea96ac2d Binary files /dev/null and b/tests/python/snapshots/nanox/test_send_spl_trusted_name/00001.png differ diff --git a/tests/python/snapshots/nanox/test_send_spl_trusted_name/00002.png b/tests/python/snapshots/nanox/test_send_spl_trusted_name/00002.png new file mode 100644 index 00000000..d84c6530 Binary files /dev/null and b/tests/python/snapshots/nanox/test_send_spl_trusted_name/00002.png differ diff --git a/tests/python/snapshots/nanox/test_send_spl_trusted_name/00003.png b/tests/python/snapshots/nanox/test_send_spl_trusted_name/00003.png new file mode 100644 index 00000000..9e29289d Binary files /dev/null and b/tests/python/snapshots/nanox/test_send_spl_trusted_name/00003.png differ diff --git a/tests/python/snapshots/nanox/test_send_spl_trusted_name/00004.png b/tests/python/snapshots/nanox/test_send_spl_trusted_name/00004.png new file mode 100644 index 00000000..c81d56b1 Binary files /dev/null and b/tests/python/snapshots/nanox/test_send_spl_trusted_name/00004.png differ diff --git a/tests/python/snapshots/nanox/test_send_spl_trusted_name/00005.png b/tests/python/snapshots/nanox/test_send_spl_trusted_name/00005.png new file mode 100644 index 00000000..53ae6519 Binary files /dev/null and b/tests/python/snapshots/nanox/test_send_spl_trusted_name/00005.png differ diff --git a/tests/python/snapshots/nanox/test_send_spl_trusted_name/00006.png b/tests/python/snapshots/nanox/test_send_spl_trusted_name/00006.png new file mode 100644 index 00000000..890ae49f Binary files /dev/null and b/tests/python/snapshots/nanox/test_send_spl_trusted_name/00006.png differ diff --git a/tests/python/snapshots/nanox/test_solana_trusted_name_create/00000.png b/tests/python/snapshots/nanox/test_solana_trusted_name_create/00000.png new file mode 100644 index 00000000..d13ce91a Binary files /dev/null and b/tests/python/snapshots/nanox/test_solana_trusted_name_create/00000.png differ diff --git a/tests/python/snapshots/nanox/test_solana_trusted_name_create/00001.png b/tests/python/snapshots/nanox/test_solana_trusted_name_create/00001.png new file mode 100644 index 00000000..215ae65e Binary files /dev/null and b/tests/python/snapshots/nanox/test_solana_trusted_name_create/00001.png differ diff --git a/tests/python/snapshots/nanox/test_solana_trusted_name_create/00002.png b/tests/python/snapshots/nanox/test_solana_trusted_name_create/00002.png new file mode 100644 index 00000000..d84c6530 Binary files /dev/null and b/tests/python/snapshots/nanox/test_solana_trusted_name_create/00002.png differ diff --git a/tests/python/snapshots/nanox/test_solana_trusted_name_create/00003.png b/tests/python/snapshots/nanox/test_solana_trusted_name_create/00003.png new file mode 100644 index 00000000..e8534877 Binary files /dev/null and b/tests/python/snapshots/nanox/test_solana_trusted_name_create/00003.png differ diff --git a/tests/python/snapshots/nanox/test_solana_trusted_name_create/00004.png b/tests/python/snapshots/nanox/test_solana_trusted_name_create/00004.png new file mode 100644 index 00000000..4ba85ca6 Binary files /dev/null and b/tests/python/snapshots/nanox/test_solana_trusted_name_create/00004.png differ diff --git a/tests/python/snapshots/nanox/test_solana_trusted_name_create/00005.png b/tests/python/snapshots/nanox/test_solana_trusted_name_create/00005.png new file mode 100644 index 00000000..ea96ac2d Binary files /dev/null and b/tests/python/snapshots/nanox/test_solana_trusted_name_create/00005.png differ diff --git a/tests/python/snapshots/nanox/test_solana_trusted_name_create/00006.png b/tests/python/snapshots/nanox/test_solana_trusted_name_create/00006.png new file mode 100644 index 00000000..d84c6530 Binary files /dev/null and b/tests/python/snapshots/nanox/test_solana_trusted_name_create/00006.png differ diff --git a/tests/python/snapshots/nanox/test_solana_trusted_name_create/00007.png b/tests/python/snapshots/nanox/test_solana_trusted_name_create/00007.png new file mode 100644 index 00000000..9e29289d Binary files /dev/null and b/tests/python/snapshots/nanox/test_solana_trusted_name_create/00007.png differ diff --git a/tests/python/snapshots/nanox/test_solana_trusted_name_create/00008.png b/tests/python/snapshots/nanox/test_solana_trusted_name_create/00008.png new file mode 100644 index 00000000..c81d56b1 Binary files /dev/null and b/tests/python/snapshots/nanox/test_solana_trusted_name_create/00008.png differ diff --git a/tests/python/snapshots/nanox/test_solana_trusted_name_create/00009.png b/tests/python/snapshots/nanox/test_solana_trusted_name_create/00009.png new file mode 100644 index 00000000..53ae6519 Binary files /dev/null and b/tests/python/snapshots/nanox/test_solana_trusted_name_create/00009.png differ diff --git a/tests/python/snapshots/nanox/test_solana_trusted_name_create/00010.png b/tests/python/snapshots/nanox/test_solana_trusted_name_create/00010.png new file mode 100644 index 00000000..890ae49f Binary files /dev/null and b/tests/python/snapshots/nanox/test_solana_trusted_name_create/00010.png differ diff --git a/tests/python/snapshots/stax/test_solana_trusted_name_create/00000.png b/tests/python/snapshots/stax/test_solana_trusted_name_create/00000.png new file mode 100644 index 00000000..fc537864 Binary files /dev/null and b/tests/python/snapshots/stax/test_solana_trusted_name_create/00000.png differ diff --git a/tests/python/snapshots/stax/test_solana_trusted_name_create/00001.png b/tests/python/snapshots/stax/test_solana_trusted_name_create/00001.png new file mode 100644 index 00000000..d6d80e32 Binary files /dev/null and b/tests/python/snapshots/stax/test_solana_trusted_name_create/00001.png differ diff --git a/tests/python/snapshots/stax/test_solana_trusted_name_create/00002.png b/tests/python/snapshots/stax/test_solana_trusted_name_create/00002.png new file mode 100644 index 00000000..9c711b01 Binary files /dev/null and b/tests/python/snapshots/stax/test_solana_trusted_name_create/00002.png differ diff --git a/tests/python/snapshots/stax/test_solana_trusted_name_create/00003.png b/tests/python/snapshots/stax/test_solana_trusted_name_create/00003.png new file mode 100644 index 00000000..6e7d0c75 Binary files /dev/null and b/tests/python/snapshots/stax/test_solana_trusted_name_create/00003.png differ diff --git a/tests/python/snapshots/stax/test_solana_trusted_name_create/00004.png b/tests/python/snapshots/stax/test_solana_trusted_name_create/00004.png new file mode 100644 index 00000000..2d8d38c2 Binary files /dev/null and b/tests/python/snapshots/stax/test_solana_trusted_name_create/00004.png differ diff --git a/tests/python/snapshots/stax/test_solana_trusted_name_create/00005.png b/tests/python/snapshots/stax/test_solana_trusted_name_create/00005.png new file mode 100644 index 00000000..392165d4 Binary files /dev/null and b/tests/python/snapshots/stax/test_solana_trusted_name_create/00005.png differ diff --git a/tests/python/snapshots/stax/test_solana_trusted_name_create/00006.png b/tests/python/snapshots/stax/test_solana_trusted_name_create/00006.png new file mode 100644 index 00000000..c6586bd4 Binary files /dev/null and b/tests/python/snapshots/stax/test_solana_trusted_name_create/00006.png differ