Skip to content

Commit adbe34c

Browse files
Merge pull request #536 from LedgerHQ/feat/apa/explicit_unknown_ticker
Explicit unknown ticker
2 parents 8a1ce2f + 9ea5d42 commit adbe34c

File tree

53 files changed

+15
-109
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+15
-109
lines changed

src/handle_get_printable_amount.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ void handle_get_printable_amount(get_printable_amount_parameters_t* params,
3131
}
3232
// If the amount is a fee, the ticker should be the chain's native currency
3333
if (params->is_fee) {
34+
// fallback mechanism in the absence of chain ID in swap config
35+
if (chain_id == 0) {
36+
chain_id = config->chainId;
37+
}
3438
strlcpy(ticker, get_displayable_ticker(&chain_id, config), sizeof(ticker));
3539
decimals = WEI_TO_ETHER;
3640
}

src/handle_swap_sign_transaction.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ bool copy_transaction_parameters(create_transaction_parameters_t* sign_transacti
4949
return false;
5050
}
5151

52+
// fallback mechanism in the absence of chain ID in swap config
53+
if (chain_id == 0) {
54+
chain_id = config->chainId;
55+
}
5256
// If the amount is a fee, its value is nominated in ETH even if we're doing an ERC20 swap
5357
strlcpy(ticker, get_displayable_ticker(&chain_id, config), sizeof(ticker));
5458
decimals = WEI_TO_ETHER;

src/network.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ typedef struct network_info_s {
1111
uint64_t chain_id;
1212
} network_info_t;
1313

14+
static const char *unknown_ticker = "???";
15+
1416
// Mappping of chain ids to networks.
1517
static const network_info_t NETWORK_MAPPING[] = {
1618
{.chain_id = 1, .name = "Ethereum", .ticker = "ETH"},
@@ -140,7 +142,11 @@ const char *get_displayable_ticker(const uint64_t *chain_id, const chain_config_
140142
const char *ticker = get_network_ticker_from_chain_id(chain_id);
141143

142144
if (ticker == NULL) {
143-
ticker = chain_cfg->coinName;
145+
if (*chain_id == chain_cfg->chainId) {
146+
ticker = chain_cfg->coinName;
147+
} else {
148+
ticker = unknown_ticker;
149+
}
144150
}
145151
return ticker;
146152
}
-10 Bytes
-14 Bytes
-10 Bytes
-14 Bytes
113 Bytes
-374 Bytes
Binary file not shown.
-330 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)