From 1b24fc2eca3180446e70ca5762e45ad017e557b7 Mon Sep 17 00:00:00 2001 From: Lucas PASCAL Date: Fri, 14 Jan 2022 13:48:05 +0100 Subject: [PATCH] [fix] Get printable amount handle should not parse configuration for ticker and decimal if the amount is a fee --- src/handle_get_printable_amount.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/handle_get_printable_amount.c b/src/handle_get_printable_amount.c index 689b62e..13acc28 100644 --- a/src/handle_get_printable_amount.c +++ b/src/handle_get_printable_amount.c @@ -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,