1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-18 05:28:40 +00:00
trezor-firmware/firmware/ethereum_tokens-gen.py
2017-05-19 14:28:35 +02:00

30 lines
896 B
Python
Executable File

#!/usr/bin/env python3
import requests
subst = {
( 1, 'BeerCoin \U0001F37A '): 'BEER',
( 1, 'CryptoCarbon'): 'CCRB',
( 1, 'DAO_extraBalance'): 'DAOe',
( 1, 'DGX 1.0'): 'DGX1',
( 1, 'Unicorn \U0001F984 '): 'UNCRN',
}
def get_tokens(chain):
URL = 'https://raw.githubusercontent.com/kvhnuke/etherwallet/mercury/app/scripts/tokens/%sTokens.json' % chain
r = requests.get(URL)
return r.json()
def print_tokens(chain, chain_id):
tokens = get_tokens(chain)
for t in tokens:
address, symbol, decimal = t['address'], t['symbol'], t['decimal']
s = (chain_id, symbol)
if s in subst:
symbol = subst[s]
address = '\\x'.join([address[i:i + 2] for i in range(0, len(address), 2)])[2:].lower()
print('\t{%2d, "%s", " %s", %d},' % (chain_id, address, symbol, decimal))
print_tokens('eth', 1)
print_tokens('etc', 61)