make swap handle functions return a value
This commit is contained in:
@@ -6,14 +6,13 @@
|
||||
|
||||
#define ZERO(x) memset(x, 0, sizeof(x))
|
||||
|
||||
void handle_check_address(check_address_parameters_t* params, chain_config_t* chain_config) {
|
||||
int handle_check_address(check_address_parameters_t* params, chain_config_t* chain_config) {
|
||||
PRINTF("Params on the address %d\n", (unsigned int) params);
|
||||
PRINTF("Address to check %s\n", params->address_to_check);
|
||||
PRINTF("Inside handle_check_address\n");
|
||||
params->result = 0;
|
||||
if (params->address_to_check == 0) {
|
||||
PRINTF("Address to check == 0\n");
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t i;
|
||||
@@ -35,7 +34,7 @@ void handle_check_address(check_address_parameters_t* params, chain_config_t* ch
|
||||
if ((bip32PathLength < 0x01) || (bip32PathLength > MAX_BIP32_PATH) ||
|
||||
(bip32PathLength * 4 != params->address_parameters_length - 1)) {
|
||||
PRINTF("Invalid path\n");
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
for (i = 0; i < bip32PathLength; i++) {
|
||||
locals_union1.bip32Path[i] = U4BE(bip32_path_ptr, 0);
|
||||
@@ -70,8 +69,8 @@ void handle_check_address(check_address_parameters_t* params, chain_config_t* ch
|
||||
params->address_to_check + offset_0x,
|
||||
strlen(locals_union1.address)) != 0) {
|
||||
PRINTF("Addresses doesn't match\n");
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
PRINTF("Addresses match\n");
|
||||
params->result = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "swap_lib_calls.h"
|
||||
#include "chainConfig.h"
|
||||
|
||||
void handle_check_address(check_address_parameters_t* check_address_params,
|
||||
chain_config_t* chain_config);
|
||||
int handle_check_address(check_address_parameters_t* check_address_params,
|
||||
chain_config_t* chain_config);
|
||||
|
||||
#endif // _HANDLE_CHECK_ADDRESS_H_
|
||||
@@ -6,21 +6,20 @@
|
||||
#include "string.h"
|
||||
#include <stdint.h>
|
||||
|
||||
void handle_get_printable_amount(get_printable_amount_parameters_t* params,
|
||||
chain_config_t* config) {
|
||||
int handle_get_printable_amount(get_printable_amount_parameters_t* params, chain_config_t* config) {
|
||||
uint8_t decimals;
|
||||
char ticker[MAX_TICKER_LEN];
|
||||
memset(params->printable_amount, 0, sizeof(params->printable_amount));
|
||||
if (params->amount_length > 32) {
|
||||
PRINTF("Amount is too big, 32 bytes max but buffer has %u bytes", params->amount_length);
|
||||
os_lib_end();
|
||||
return 0;
|
||||
}
|
||||
if (!parse_swap_config(params->coin_configuration,
|
||||
params->coin_configuration_length,
|
||||
ticker,
|
||||
&decimals)) {
|
||||
PRINTF("Error while parsing config\n");
|
||||
os_lib_end();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// If the amount is a fee, its value is nominated in ETH even if we're doing an ERC20 swap
|
||||
@@ -38,4 +37,5 @@ void handle_get_printable_amount(get_printable_amount_parameters_t* params,
|
||||
ticker,
|
||||
params->printable_amount,
|
||||
sizeof(params->printable_amount));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "swap_lib_calls.h"
|
||||
#include "chainConfig.h"
|
||||
|
||||
void handle_get_printable_amount(get_printable_amount_parameters_t* get_printable_amount_params,
|
||||
chain_config_t* config);
|
||||
int handle_get_printable_amount(get_printable_amount_parameters_t* get_printable_amount_params,
|
||||
chain_config_t* config);
|
||||
|
||||
#endif // _HANDLE_GET_PRINTABLE_AMOUNT_H_
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "shared_context.h"
|
||||
#include "utils.h"
|
||||
|
||||
void copy_transaction_parameters(create_transaction_parameters_t* sign_transaction_params,
|
||||
bool copy_transaction_parameters(create_transaction_parameters_t* sign_transaction_params,
|
||||
chain_config_t* config) {
|
||||
// first copy parameters to stack, and then to global data.
|
||||
// We need this "trick" as the input data position can overlap with app-ethereum globals
|
||||
@@ -16,7 +16,7 @@ void copy_transaction_parameters(create_transaction_parameters_t* sign_transacti
|
||||
if ((stack_data.fullAddress[sizeof(stack_data.fullAddress) - 1] != '\0') ||
|
||||
(sign_transaction_params->amount_length > 32) ||
|
||||
(sign_transaction_params->fee_amount_length > 8)) {
|
||||
os_lib_end();
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t decimals;
|
||||
@@ -26,7 +26,7 @@ void copy_transaction_parameters(create_transaction_parameters_t* sign_transacti
|
||||
ticker,
|
||||
&decimals)) {
|
||||
PRINTF("Error while parsing config\n");
|
||||
os_lib_end();
|
||||
return false;
|
||||
}
|
||||
amountToString(sign_transaction_params->amount,
|
||||
sign_transaction_params->amount_length,
|
||||
@@ -46,11 +46,10 @@ void copy_transaction_parameters(create_transaction_parameters_t* sign_transacti
|
||||
sizeof(stack_data.maxFee));
|
||||
|
||||
memcpy(&strings.common, &stack_data, sizeof(stack_data));
|
||||
return true;
|
||||
}
|
||||
|
||||
void handle_swap_sign_transaction(create_transaction_parameters_t* sign_transaction_params,
|
||||
chain_config_t* config) {
|
||||
copy_transaction_parameters(sign_transaction_params, config);
|
||||
void handle_swap_sign_transaction(chain_config_t* config) {
|
||||
chainConfig = config;
|
||||
reset_app_context();
|
||||
called_from_swap = true;
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
#include "swap_lib_calls.h"
|
||||
#include "chainConfig.h"
|
||||
|
||||
void handle_swap_sign_transaction(create_transaction_parameters_t* get_printable_amount_params,
|
||||
chain_config_t* config);
|
||||
bool copy_transaction_parameters(create_transaction_parameters_t* sign_transaction_params,
|
||||
chain_config_t* config);
|
||||
|
||||
void handle_swap_sign_transaction(chain_config_t* config);
|
||||
|
||||
#endif // _HANDLE_SWAP_SIGN_TRANSACTION_H_
|
||||
Reference in New Issue
Block a user