Skip to content

Commit

Permalink
Removes useless space at the end of tickers
Browse files Browse the repository at this point in the history
  • Loading branch information
apaillier-ledger committed Jan 10, 2023
1 parent 41c5d3e commit 74f880d
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 73 deletions.
6 changes: 1 addition & 5 deletions src/eth_plugin_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,8 @@ void eth_plugin_prepare_query_contract_UI(ethQueryContractUI_t *queryContractUI,
queryContractUI->item2 = &tmpCtx.transactionContext.extraInfo[0];
}

strlcpy(queryContractUI->network_ticker, get_network_ticker(), MAX_TICKER_LEN);

queryContractUI->screenIndex = screenIndex;
strlcpy(queryContractUI->network_ticker,
get_network_ticker(),
sizeof(queryContractUI->network_ticker));
strlcpy(queryContractUI->network_ticker, get_network_ticker(), MAX_TICKER_LEN);
queryContractUI->title = title;
queryContractUI->titleLength = titleLength;
queryContractUI->msg = msg;
Expand Down
3 changes: 1 addition & 2 deletions src/handle_get_printable_amount.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ int handle_get_printable_amount(get_printable_amount_parameters_t* params, chain
if (params->is_fee) {
uint8_t ticker_len = strnlen(config->coinName, sizeof(config->coinName));
memcpy(ticker, config->coinName, ticker_len);
ticker[ticker_len] = ' ';
ticker[ticker_len + 1] = '\0';
ticker[ticker_len] = '\0';
decimals = WEI_TO_ETHER;
} else {
// If the amount is *not* a fee, decimals and ticker are built from the given config
Expand Down
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ void app_exit() {

void init_coin_config(chain_config_t *coin_config) {
memset(coin_config, 0, sizeof(chain_config_t));
strcpy(coin_config->coinName, CHAINID_COINNAME " ");
strcpy(coin_config->coinName, CHAINID_COINNAME);
coin_config->chainId = CHAIN_ID;
coin_config->kind = CHAIN_KIND;
}
Expand Down
2 changes: 1 addition & 1 deletion src/tokens.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <stdint.h>
#include "ethUstream.h"

#define MAX_TICKER_LEN 12 // 10 characters + ' ' + '\0'
#define MAX_TICKER_LEN 11 // 10 characters + '\0'
#define MAX_ITEMS 2

typedef struct tokenDefinition_t {
Expand Down
6 changes: 4 additions & 2 deletions src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ void amountToString(const uint8_t *amount,
uint8_t ticker_len = strnlen(ticker, MAX_TICKER_LEN);

memcpy(out_buffer, ticker, MIN(out_buffer_size, ticker_len));
if (ticker_len > 0) {
out_buffer[ticker_len++] = ' ';
}

if (adjustDecimals(tmp_buffer,
amount_len,
Expand All @@ -155,8 +158,7 @@ bool parse_swap_config(const uint8_t *config, uint8_t config_len, char *ticker,
}
memcpy(ticker, config + offset, ticker_len);
offset += ticker_len;
ticker[ticker_len] = ' ';
ticker[ticker_len + 1] = '\0';
ticker[ticker_len] = '\0';

if (config_len - offset < 1) {
return false;
Expand Down
108 changes: 54 additions & 54 deletions src_common/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,60 +8,60 @@
#include "utils.h"

// Mappping of chain ids to networks.
const network_info_t NETWORK_MAPPING[] = {
{.chain_id = 1, .name = "Ethereum", .ticker = "ETH "},
{.chain_id = 3, .name = "Ropsten", .ticker = "ETH "},
{.chain_id = 4, .name = "Rinkeby", .ticker = "ETH "},
{.chain_id = 5, .name = "Goerli", .ticker = "ETH "},
{.chain_id = 10, .name = "Optimism", .ticker = "ETH "},
{.chain_id = 42, .name = "Kovan", .ticker = "ETH "},
{.chain_id = 56, .name = "BSC", .ticker = "BNB "},
{.chain_id = 100, .name = "xDai", .ticker = "xDAI "},
{.chain_id = 137, .name = "Polygon", .ticker = "MATIC "},
{.chain_id = 250, .name = "Fantom", .ticker = "FTM "},
{.chain_id = 42161, .name = "Arbitrum", .ticker = "AETH "},
{.chain_id = 42220, .name = "Celo", .ticker = "CELO "},
{.chain_id = 43114, .name = "Avalanche", .ticker = "AVAX "},
{.chain_id = 44787, .name = "Celo Alfajores", .ticker = "aCELO "},
{.chain_id = 62320, .name = "Celo Baklava", .ticker = "bCELO "},
{.chain_id = 11297108109, .name = "Palm Network", .ticker = "PALM "},
{.chain_id = 1818, .name = "Cube", .ticker = "CUBE "},
{.chain_id = 336, .name = "Shiden", .ticker = "SDN "},
{.chain_id = 592, .name = "Astar", .ticker = "ASTR "},
{.chain_id = 50, .name = "XDC", .ticker = "XDC "},
{.chain_id = 82, .name = "Meter", .ticker = "MTR "},
{.chain_id = 62621, .name = "Multivac", .ticker = "MTV "},
{.chain_id = 20531812, .name = "Tecra", .ticker = "TCR "},
{.chain_id = 20531811, .name = "TecraTestnet", .ticker = "TCR "},
{.chain_id = 51, .name = "Apothemnetwork", .ticker = "XDC "},
{.chain_id = 199, .name = "BTTC", .ticker = "BTT "},
{.chain_id = 1030, .name = "Conflux", .ticker = "CFX "},
{.chain_id = 61, .name = "Ethereum Classic", .ticker = "ETC "},
{.chain_id = 246, .name = "EnergyWebChain", .ticker = "EWC "},
{.chain_id = 14, .name = "Flare", .ticker = "FLR "},
{.chain_id = 16, .name = "Flare Coston", .ticker = "FLR "},
{.chain_id = 24, .name = "KardiaChain", .ticker = "KAI "},
{.chain_id = 1284, .name = "Moonbeam", .ticker = "GLMR "},
{.chain_id = 1285, .name = "Moonriver", .ticker = "MOVR "},
{.chain_id = 66, .name = "OKXChain", .ticker = "OKT "},
{.chain_id = 99, .name = "POA", .ticker = "POA "},
{.chain_id = 7341, .name = "Shyft", .ticker = "SHFT "},
{.chain_id = 19, .name = "Songbird", .ticker = "SGB "},
{.chain_id = 73799, .name = "Volta", .ticker = "VOLTA "},
{.chain_id = 25, .name = "Cronos", .ticker = "CRO "},
{.chain_id = 534354, .name = "Scroll (Pre-Alpha)", .ticker = "SCR "},
{.chain_id = 534353, .name = "Scroll (Goerli)", .ticker = "SCR "},
{.chain_id = 534352, .name = "Scroll", .ticker = "SCR "},
{.chain_id = 321, .name = "KCC", .ticker = "KCS "},
{.chain_id = 30, .name = "Rootstock", .ticker = "RBTC "},
{.chain_id = 9001, .name = "Evmos", .ticker = "EVMOS "},
{.chain_id = 1088, .name = "Metis Andromeda", .ticker = "METIS "},
{.chain_id = 2222, .name = "Kava EVM", .ticker = "KAVA "},
{.chain_id = 8217, .name = "Klaytn Cypress", .ticker = "KLAY "},
{.chain_id = 57, .name = "Syscoin", .ticker = "SYS "},
{.chain_id = 106, .name = "Velas EVM", .ticker = "VLX "},
{.chain_id = 288, .name = "Boba Network", .ticker = "ETH "},
{.chain_id = 39797, .name = "Energi", .ticker = "NRG "}};
static const network_info_t NETWORK_MAPPING[] = {
{.chain_id = 1, .name = "Ethereum", .ticker = "ETH"},
{.chain_id = 3, .name = "Ropsten", .ticker = "ETH"},
{.chain_id = 4, .name = "Rinkeby", .ticker = "ETH"},
{.chain_id = 5, .name = "Goerli", .ticker = "ETH"},
{.chain_id = 10, .name = "Optimism", .ticker = "ETH"},
{.chain_id = 42, .name = "Kovan", .ticker = "ETH"},
{.chain_id = 56, .name = "BSC", .ticker = "BNB"},
{.chain_id = 100, .name = "xDai", .ticker = "xDAI"},
{.chain_id = 137, .name = "Polygon", .ticker = "MATIC"},
{.chain_id = 250, .name = "Fantom", .ticker = "FTM"},
{.chain_id = 42161, .name = "Arbitrum", .ticker = "AETH"},
{.chain_id = 42220, .name = "Celo", .ticker = "CELO"},
{.chain_id = 43114, .name = "Avalanche", .ticker = "AVAX"},
{.chain_id = 44787, .name = "Celo Alfajores", .ticker = "aCELO"},
{.chain_id = 62320, .name = "Celo Baklava", .ticker = "bCELO"},
{.chain_id = 11297108109, .name = "Palm Network", .ticker = "PALM"},
{.chain_id = 1818, .name = "Cube", .ticker = "CUBE"},
{.chain_id = 336, .name = "Shiden", .ticker = "SDN"},
{.chain_id = 592, .name = "Astar", .ticker = "ASTR"},
{.chain_id = 50, .name = "XDC", .ticker = "XDC"},
{.chain_id = 82, .name = "Meter", .ticker = "MTR"},
{.chain_id = 62621, .name = "Multivac", .ticker = "MTV"},
{.chain_id = 20531812, .name = "Tecra", .ticker = "TCR"},
{.chain_id = 20531811, .name = "TecraTestnet", .ticker = "TCR"},
{.chain_id = 51, .name = "Apothemnetwork", .ticker = "XDC"},
{.chain_id = 199, .name = "BTTC", .ticker = "BTT"},
{.chain_id = 1030, .name = "Conflux", .ticker = "CFX"},
{.chain_id = 61, .name = "Ethereum Classic", .ticker = "ETC"},
{.chain_id = 246, .name = "EnergyWebChain", .ticker = "EWC"},
{.chain_id = 14, .name = "Flare", .ticker = "FLR"},
{.chain_id = 16, .name = "Flare Coston", .ticker = "FLR"},
{.chain_id = 24, .name = "KardiaChain", .ticker = "KAI"},
{.chain_id = 1284, .name = "Moonbeam", .ticker = "GLMR"},
{.chain_id = 1285, .name = "Moonriver", .ticker = "MOVR"},
{.chain_id = 66, .name = "OKXChain", .ticker = "OKT"},
{.chain_id = 99, .name = "POA", .ticker = "POA"},
{.chain_id = 7341, .name = "Shyft", .ticker = "SHFT"},
{.chain_id = 19, .name = "Songbird", .ticker = "SGB"},
{.chain_id = 73799, .name = "Volta", .ticker = "VOLTA"},
{.chain_id = 25, .name = "Cronos", .ticker = "CRO"},
{.chain_id = 534354, .name = "Scroll (Pre-Alpha)", .ticker = "SCR"},
{.chain_id = 534353, .name = "Scroll (Goerli)", .ticker = "SCR"},
{.chain_id = 534352, .name = "Scroll", .ticker = "SCR"},
{.chain_id = 321, .name = "KCC", .ticker = "KCS"},
{.chain_id = 30, .name = "Rootstock", .ticker = "RBTC"},
{.chain_id = 9001, .name = "Evmos", .ticker = "EVMOS"},
{.chain_id = 1088, .name = "Metis Andromeda", .ticker = "METIS"},
{.chain_id = 2222, .name = "Kava EVM", .ticker = "KAVA"},
{.chain_id = 8217, .name = "Klaytn Cypress", .ticker = "KLAY"},
{.chain_id = 57, .name = "Syscoin", .ticker = "SYS"},
{.chain_id = 106, .name = "Velas EVM", .ticker = "VLX"},
{.chain_id = 288, .name = "Boba Network", .ticker = "ETH"},
{.chain_id = 39797, .name = "Energi", .ticker = "NRG"}};

uint64_t get_chain_id(void) {
uint64_t chain_id = 0;
Expand Down
2 changes: 0 additions & 2 deletions src_common/network.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#include "tokens.h"
#include "shared_context.h"

#define MAX_NETWORK_TICKER_LEN 8

typedef struct network_info_s {
const char *name;
const char *ticker;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ void handleProvideErc20TokenInformation(uint8_t p1,
}
cx_hash((cx_hash_t *) &sha256, 0, workBuffer + offset, tickerLength, NULL, 0);
memmove(token->ticker, workBuffer + offset, tickerLength);
token->ticker[tickerLength] = ' ';
token->ticker[tickerLength + 1] = '\0';
token->ticker[tickerLength] = '\0';
offset += tickerLength;
dataLength -= tickerLength;

Expand Down Expand Up @@ -136,8 +135,7 @@ void handleProvideErc20TokenInformation(uint8_t p1,
}
cx_hash_sha256(workBuffer + offset, tickerLength + 20 + 4 + 4, hash, 32);
memmove(token->ticker, workBuffer + offset, tickerLength);
token->ticker[tickerLength] = ' ';
token->ticker[tickerLength + 1] = '\0';
token->ticker[tickerLength] = '\0';
offset += tickerLength;
dataLength -= tickerLength;
memmove(token->address, workBuffer + offset, 20);
Expand Down
1 change: 1 addition & 0 deletions src_features/signTx/logic_signTx.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ static void feesToString(uint256_t *rawFee, char *displayBuffer, uint32_t displa
displayBuffer[tickerOffset] = feeTicker[tickerOffset];
tickerOffset++;
}
if ((uint32_t) tickerOffset < displayBufferSize) displayBuffer[tickerOffset++] = ' ';
while (G_io_apdu_buffer[i]) {
if ((uint32_t) (tickerOffset) + i >= displayBufferSize) {
break;
Expand Down
5 changes: 3 additions & 2 deletions src_plugins/starkware/starkware_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,11 @@ void starkware_print_amount(uint8_t *amountData,
}
tostring256(&amount, 10, (char *) (G_io_apdu_buffer + 100), 100);
strlcpy(destination, ticker, destinationLength);
strlcat(destination, " ", destinationLength);
adjustDecimals((char *) (G_io_apdu_buffer + 100),
strlen((char *) (G_io_apdu_buffer + 100)),
destination + strlen(ticker),
destinationLength - strlen(ticker),
destination + strlen(ticker) + 1,
destinationLength - strlen(ticker) - 1,
decimals);
}

Expand Down

0 comments on commit 74f880d

Please sign in to comment.