1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-14 03:30:02 +00:00

defs: add 'chain' key to Ethereum networks, tooling support

'chain' is a "slug"-like string that matches the 'chain' field in token
definitions. It is also unique so it can be used as a URL slug in
Connect / webwallet
This commit is contained in:
matejcik 2018-09-07 13:17:47 +02:00
parent ab58324dc0
commit cfbe5a5dd1
2 changed files with 41 additions and 4 deletions

View File

@ -1,5 +1,6 @@
[
{
"chain": "eth",
"chain_id": 1,
"slip44": 60,
"shortcut": "ETH",
@ -8,6 +9,7 @@
"url": "https://www.ethereum.org"
},
{
"chain": "exp",
"chain_id": 2,
"slip44": 40,
"shortcut": "EXP",
@ -16,6 +18,7 @@
"url": "https://expanse.tech"
},
{
"chain": "rop",
"chain_id": 3,
"slip44": 1,
"shortcut": "tROP",
@ -24,6 +27,7 @@
"url": "https://www.ethereum.org"
},
{
"chain": "rin",
"chain_id": 4,
"slip44": 1,
"shortcut": "tRIN",
@ -32,6 +36,7 @@
"url": "https://www.ethereum.org"
},
{
"chain": "ubq",
"chain_id": 8,
"slip44": 108,
"shortcut": "UBQ",
@ -40,6 +45,7 @@
"url": "https://ubiqsmart.com"
},
{
"chain": "eosc",
"chain_id": 20,
"slip44": 2018,
"shortcut": "EOSC",
@ -48,6 +54,7 @@
"url": "https://eos-classic.io"
},
{
"chain": "etsc",
"chain_id": 28,
"slip44": 1128,
"shortcut": "ETSC",
@ -56,6 +63,7 @@
"url": "https://ethereumsocial.kr"
},
{
"chain": "rsk",
"chain_id": 30,
"slip44": 137,
"shortcut": "RSK",
@ -64,6 +72,7 @@
"url": "https://www.rsk.co"
},
{
"chain": "trsk",
"chain_id": 31,
"slip44": 37310,
"shortcut": "tRSK",
@ -72,6 +81,7 @@
"url": "https://www.rsk.co"
},
{
"chain": "kov",
"chain_id": 42,
"slip44": 1,
"shortcut": "tKOV",
@ -80,6 +90,7 @@
"url": "https://www.ethereum.org"
},
{
"chain": "go",
"chain_id": 60,
"slip44": 6060,
"shortcut": "GO",
@ -88,6 +99,7 @@
"url": "https://gochain.io"
},
{
"chain": "etc",
"chain_id": 61,
"slip44": 61,
"shortcut": "ETC",
@ -96,6 +108,7 @@
"url": "https://ethereumclassic.github.io"
},
{
"chain": "tetc",
"chain_id": 62,
"slip44": 1,
"shortcut": "tETC",
@ -104,6 +117,7 @@
"url": "https://ethereumclassic.github.io"
},
{
"chain": "ella",
"chain_id": 64,
"slip44": 163,
"shortcut": "ELLA",
@ -112,6 +126,7 @@
"url": "https://ellaism.org"
},
{
"chain": "clo",
"chain_id": 820,
"slip44": 820,
"shortcut": "CLO",
@ -120,6 +135,7 @@
"url": "https://callisto.network"
},
{
"chain": "ath",
"chain_id": 1620,
"slip44": 1620,
"shortcut": "ATH",
@ -128,6 +144,7 @@
"url": "https://atheios.com"
},
{
"chain": "egem",
"chain_id": 1987,
"slip44": 1987,
"shortcut": "EGEM",
@ -136,6 +153,7 @@
"url": "https://egem.io"
},
{
"chain": "esn",
"chain_id": 31102,
"slip44": 31102,
"shortcut": "ESN",
@ -144,6 +162,7 @@
"url": "https://ethersocial.org"
},
{
"chain": "akroma",
"chain_id": 200625,
"slip44": 200625,
"shortcut": "AKA",
@ -152,6 +171,7 @@
"url": "https://akroma.io"
},
{
"chain": "music",
"chain_id": 7762959,
"slip44": 184,
"shortcut": "MUSIC",
@ -160,6 +180,7 @@
"url": "https://musicoin.org"
},
{
"chain": "etho",
"chain_id": 1313114,
"slip44": 1313114,
"shortcut": "ETHO",
@ -168,6 +189,7 @@
"url": "https://ether1.org"
},
{
"chain": "pirl",
"chain_id": 3125659152,
"slip44": 164,
"shortcut": "PIRL",

View File

@ -154,7 +154,7 @@ def highlight_key(coin, color):
return f"{key} {name}"
def find_address_collisions(coins, field):
def find_collisions(coins, field):
"""Detects collisions in a given field. Returns buckets of colliding coins."""
collisions = defaultdict(list)
for coin in coins:
@ -163,6 +163,17 @@ def find_address_collisions(coins, field):
return {k: v for k, v in collisions.items() if len(v) > 1}
def check_eth(coins):
check_passed = True
chains = find_collisions(coins, "chain")
for key, bucket in chains.items():
bucket_str = ", ".join(f"{coin['key']} ({coin['name']})" for coin in bucket)
chain_name_str = "colliding chain name " + crayon(None, key, bold=True) + ":"
print_log(logging.ERROR, chain_name_str, bucket_str)
check_passed = False
return check_passed
def check_btc(coins):
check_passed = True
support_infos = coin_info.support_info(coins)
@ -233,7 +244,7 @@ def check_btc(coins):
# slip44 collisions
print("Checking SLIP44 prefix collisions...")
slip44 = find_address_collisions(coins, "slip44")
slip44 = find_collisions(coins, "slip44")
if print_collision_buckets(slip44, "key"):
check_passed = False
@ -241,12 +252,12 @@ def check_btc(coins):
nocashaddr = [coin for coin in coins if not coin.get("cashaddr_prefix")]
print("Checking address_type collisions...")
address_type = find_address_collisions(nocashaddr, "address_type")
address_type = find_collisions(nocashaddr, "address_type")
if print_collision_buckets(address_type, "address type"):
check_passed = False
print("Checking address_type_p2sh collisions...")
address_type_p2sh = find_address_collisions(nocashaddr, "address_type_p2sh")
address_type_p2sh = find_collisions(nocashaddr, "address_type_p2sh")
# we ignore failed checks on P2SH, because reasons
print_collision_buckets(address_type_p2sh, "address type", logging.WARNING)
@ -506,6 +517,10 @@ def check(backend, icons, show_duplicates):
if not check_btc(defs.bitcoin):
all_checks_passed = False
print("Checking Ethereum networks...")
if not check_eth(defs.eth):
all_checks_passed = False
if show_duplicates == "all":
dup_level = logging.DEBUG
elif show_duplicates == "nontoken":