1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-22 22:38:08 +00:00

ethereum: don't show unrecognized ERC-20 tokens as sending message

This commit is contained in:
Pavol Rusnak 2017-07-05 14:22:00 +02:00
parent ba2b2f24da
commit 2ecc36cd89
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
3 changed files with 9 additions and 1 deletions

View File

@ -203,6 +203,10 @@ static void ethereumFormatAmount(const bignum256 *amnt, const TokenType *token,
bn_read_uint32(1000000000, &bn1e9);
const char *suffix = NULL;
int decimals = 18;
if (token == UnknownToken) {
strlcpy(buf, "Unrecognized Token", buflen);
return;
} else
if (token != NULL) {
suffix = token->ticker;
decimals = token->decimals;

View File

@ -84,6 +84,8 @@ const TokenType tokens[TOKENS_COUNT] = {
{61, "\x08\x5f\xb4\xf2\x40\x31\xea\xed\xbc\x2b\x61\x1a\xa5\x28\xf2\x23\x43\xeb\x52\xdb", " BEC", 8},
};
const TokenType *UnknownToken = (const TokenType *)1;
const TokenType *tokenByChainAddress(uint8_t chain_id, const uint8_t *address)
{
if (!address) return 0;
@ -92,5 +94,5 @@ const TokenType *tokenByChainAddress(uint8_t chain_id, const uint8_t *address)
return &(tokens[i]);
}
}
return 0;
return UnknownToken;
}

View File

@ -33,6 +33,8 @@ typedef struct {
extern const TokenType tokens[TOKENS_COUNT];
extern const TokenType *UnknownToken;
const TokenType *tokenByChainAddress(uint8_t chain_id, const uint8_t *address);
#endif