[fix] Get printable amount handle should not parse configuration for ticker and decimal if the amount is a fee

This commit is contained in:
Lucas PASCAL
2022-01-14 13:48:05 +01:00
parent 858ff08e6e
commit 1b24fc2eca

View File

@@ -15,13 +15,6 @@ int handle_get_printable_amount(get_printable_amount_parameters_t* params, chain
PRINTF("Amount is too big, 32 bytes max but buffer has %u bytes", params->amount_length);
return 0;
}
if (!parse_swap_config(params->coin_configuration,
params->coin_configuration_length,
ticker,
&decimals)) {
PRINTF("Error while parsing config\n");
return 0;
}
// If the amount is a fee, its value is nominated in ETH even if we're doing an ERC20 swap
if (params->is_fee) {
@@ -30,6 +23,15 @@ int handle_get_printable_amount(get_printable_amount_parameters_t* params, chain
ticker[ticker_len] = ' ';
ticker[ticker_len + 1] = '\0';
decimals = WEI_TO_ETHER;
} else {
// If the amount is *not* a fee, decimals and ticker are built from the given config
if (!parse_swap_config(params->coin_configuration,
params->coin_configuration_length,
ticker,
&decimals)) {
PRINTF("Error while parsing config\n");
return 0;
}
}
amountToString(params->amount,