Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
fbeutin-ledger committed Jan 27, 2025
1 parent 9293b09 commit 143dcef
Show file tree
Hide file tree
Showing 41 changed files with 25 additions and 18 deletions.
29 changes: 20 additions & 9 deletions src/handle_sign_message.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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)) {
Expand Down Expand Up @@ -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)) {
Expand All @@ -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;
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down
5 changes: 0 additions & 5 deletions src/swap/handle_check_address.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/swap/handle_get_printable_amount.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions src/swap/handle_swap_sign_transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/swap/swap_common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

#define MAX_SWAP_TOKEN_LENGTH 15
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 143dcef

Please sign in to comment.