2018-07-30 15:40:07 +00:00
|
|
|
// This file is automatically generated from ethereum_tokens.c.mako
|
|
|
|
// DO NOT EDIT
|
|
|
|
|
|
|
|
#include <string.h>
|
2023-02-03 13:50:29 +00:00
|
|
|
#include "ethereum.h"
|
2018-07-30 15:40:07 +00:00
|
|
|
#include "ethereum_tokens.h"
|
|
|
|
|
2023-08-28 14:46:57 +00:00
|
|
|
<% erc20_list = list(supported_on("T1B1", erc20)) %>\
|
2023-02-03 13:50:29 +00:00
|
|
|
#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
|
|
|
|
};
|
|
|
|
|
2023-02-03 13:50:29 +00:00
|
|
|
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
|
|
|
|
2023-02-03 13:50:29 +00:00
|
|
|
const EthereumTokenInfo *ethereum_token_by_address(uint64_t chain_id, const uint8_t *address)
|
2018-07-30 15:40:07 +00:00
|
|
|
{
|
2023-02-03 13:50:29 +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
|
|
|
}
|