1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-24 07:18:09 +00:00
trezor-firmware/legacy/firmware/ethereum_tokens.c.mako

52 lines
1.3 KiB
Plaintext
Raw Normal View History

2018-07-30 15:40:07 +00:00
// This file is automatically generated from ethereum_tokens.c.mako
// DO NOT EDIT
#include <string.h>
#include "ethereum.h"
2018-07-30 15:40:07 +00:00
#include "ethereum_tokens.h"
<% erc20_list = list(supported_on("T1B1", erc20)) %>\
#define TOKENS_COUNT ${len(erc20_list)}
static const EthereumTokenInfo tokens[TOKENS_COUNT] = {
% for t in sorted(erc20_list, key=lambda token: (token.chain_id, token.name)):
{
.symbol = "${ascii(t.symbol)}",
.decimals = ${t.decimals},
.address = {
.size = 20,
.bytes = ${c_str(t.address_bytes)}
},
.chain_id = ${t.chain_id},
## .name = "${t.name}"
.name = "",
},
2018-07-30 15:40:07 +00:00
% endfor
};
const EthereumTokenInfo UNKNOWN_TOKEN = {
.symbol = "Wei UNKN",
.decimals = 0,
.address = {
.size = 20,
.bytes = "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff",
},
.chain_id = CHAIN_ID_UNKNOWN,
.name = "",
};
2018-07-30 15:40:07 +00:00
const EthereumTokenInfo *ethereum_token_by_address(uint64_t chain_id, const uint8_t *address)
2018-07-30 15:40:07 +00:00
{
if (!address) return 0;
for (int i = 0; i < TOKENS_COUNT; i++) {
if (chain_id == tokens[i].chain_id && memcmp(address, tokens[i].address.bytes, sizeof(tokens[i].address.bytes)) == 0) {
return &(tokens[i]);
}
}
return &UNKNOWN_TOKEN;
}
bool is_unknown_token(const EthereumTokenInfo *token) {
return token->chain_id == CHAIN_ID_UNKNOWN;
2018-07-30 15:40:07 +00:00
}