|
|
|
@ -145,6 +145,13 @@ def render_file(src, dst, coins, support_info):
|
|
|
|
|
# ====== validation functions ======
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def mark_unsupported(support_info, coins):
|
|
|
|
|
for coin in coins:
|
|
|
|
|
key = coin["key"]
|
|
|
|
|
# checking for explicit False because None means unknown
|
|
|
|
|
coin["unsupported"] = all(v is False for v in support_info[key].values())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def highlight_key(coin, color):
|
|
|
|
|
"""Return a colorful string where the SYMBOL part is bold."""
|
|
|
|
|
keylist = coin["key"].split(":")
|
|
|
|
@ -193,7 +200,6 @@ def check_eth(coins):
|
|
|
|
|
|
|
|
|
|
def check_btc(coins):
|
|
|
|
|
check_passed = True
|
|
|
|
|
support_infos = coin_info.support_info(coins)
|
|
|
|
|
|
|
|
|
|
# validate individual coin data
|
|
|
|
|
for coin in coins:
|
|
|
|
@ -213,7 +219,7 @@ def check_btc(coins):
|
|
|
|
|
color = "green"
|
|
|
|
|
elif name == "Bitcoin":
|
|
|
|
|
color = "red"
|
|
|
|
|
elif coin.get("unsupported"):
|
|
|
|
|
elif coin["unsupported"]:
|
|
|
|
|
color = "grey"
|
|
|
|
|
prefix = crayon("blue", "(X)", bold=True)
|
|
|
|
|
else:
|
|
|
|
@ -239,15 +245,9 @@ def check_btc(coins):
|
|
|
|
|
and not c["name"].endswith("Regtest")
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
have_bitcoin = False
|
|
|
|
|
for coin in mainnets:
|
|
|
|
|
if coin["name"] == "Bitcoin":
|
|
|
|
|
have_bitcoin = True
|
|
|
|
|
if all(v is False for k, v in support_infos[coin["key"]].items()):
|
|
|
|
|
coin["unsupported"] = True
|
|
|
|
|
|
|
|
|
|
supported_mainnets = [c for c in mainnets if not c.get("unsupported")]
|
|
|
|
|
supported_networks = [c for c in bucket if not c.get("unsupported")]
|
|
|
|
|
have_bitcoin = any(coin["name"] == "Bitcoin" for coin in mainnets)
|
|
|
|
|
supported_mainnets = [c for c in mainnets if not c["unsupported"]]
|
|
|
|
|
supported_networks = [c for c in bucket if not c["unsupported"]]
|
|
|
|
|
|
|
|
|
|
if len(mainnets) > 1:
|
|
|
|
|
if (have_bitcoin or strict) and len(supported_networks) > 1:
|
|
|
|
@ -290,7 +290,7 @@ def check_btc(coins):
|
|
|
|
|
return check_passed
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def check_dups(buckets, print_at_level=logging.ERROR):
|
|
|
|
|
def check_dups(buckets, print_at_level=logging.WARNING):
|
|
|
|
|
"""Analyze and pretty-print results of `coin_info.mark_duplicate_shortcuts`.
|
|
|
|
|
|
|
|
|
|
`print_at_level` can be one of logging levels.
|
|
|
|
@ -305,15 +305,19 @@ def check_dups(buckets, print_at_level=logging.ERROR):
|
|
|
|
|
"""Colorize coins. Tokens are cyan, nontokens are red. Coins that are NOT
|
|
|
|
|
marked duplicate get a green asterisk.
|
|
|
|
|
"""
|
|
|
|
|
if coin_info.is_token(coin):
|
|
|
|
|
prefix = ""
|
|
|
|
|
if coin["unsupported"]:
|
|
|
|
|
color = "grey"
|
|
|
|
|
prefix = crayon("blue", "(X)", bold=True)
|
|
|
|
|
elif coin_info.is_token(coin):
|
|
|
|
|
color = "cyan"
|
|
|
|
|
else:
|
|
|
|
|
color = "red"
|
|
|
|
|
highlighted = highlight_key(coin, color)
|
|
|
|
|
|
|
|
|
|
if not coin.get("duplicate"):
|
|
|
|
|
prefix = crayon("green", "*", bold=True)
|
|
|
|
|
else:
|
|
|
|
|
prefix = ""
|
|
|
|
|
prefix = crayon("green", "*", bold=True) + prefix
|
|
|
|
|
|
|
|
|
|
highlighted = highlight_key(coin, color)
|
|
|
|
|
return "{}{}".format(prefix, highlighted)
|
|
|
|
|
|
|
|
|
|
check_passed = True
|
|
|
|
@ -323,17 +327,29 @@ def check_dups(buckets, print_at_level=logging.ERROR):
|
|
|
|
|
if not bucket:
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
supported = [coin for coin in bucket if not coin["unsupported"]]
|
|
|
|
|
nontokens = [coin for coin in bucket if not coin_info.is_token(coin)]
|
|
|
|
|
cleared = not any(coin.get("duplicate") for coin in bucket)
|
|
|
|
|
|
|
|
|
|
# string generation
|
|
|
|
|
dup_str = ", ".join(coin_str(coin) for coin in bucket)
|
|
|
|
|
if not nontokens:
|
|
|
|
|
level = logging.DEBUG
|
|
|
|
|
elif len(nontokens) == 1:
|
|
|
|
|
level = logging.INFO
|
|
|
|
|
else:
|
|
|
|
|
if len(nontokens) > 1:
|
|
|
|
|
# Two or more colliding nontokens. This is always fatal.
|
|
|
|
|
# XXX consider allowing two nontokens as long as only one is supported?
|
|
|
|
|
level = logging.ERROR
|
|
|
|
|
check_passed = False
|
|
|
|
|
elif len(supported) > 1:
|
|
|
|
|
# more than one supported coin in bucket
|
|
|
|
|
if cleared:
|
|
|
|
|
# some previous step has explicitly marked them as non-duplicate
|
|
|
|
|
level = logging.INFO
|
|
|
|
|
else:
|
|
|
|
|
# at most 1 non-token - we tenatively allow token collisions
|
|
|
|
|
# when explicitly marked as supported
|
|
|
|
|
level = logging.WARNING
|
|
|
|
|
else:
|
|
|
|
|
# At most 1 supported coin, at most 1 non-token. This is informational only.
|
|
|
|
|
level = logging.DEBUG
|
|
|
|
|
|
|
|
|
|
# deciding whether to print
|
|
|
|
|
if level < print_at_level:
|
|
|
|
@ -342,7 +358,7 @@ def check_dups(buckets, print_at_level=logging.ERROR):
|
|
|
|
|
if symbol == "_override":
|
|
|
|
|
print_log(level, "force-set duplicates:", dup_str)
|
|
|
|
|
else:
|
|
|
|
|
print_log(level, "duplicate symbol {}:".format(symbol), dup_str)
|
|
|
|
|
print_log(level, "duplicate symbol {}:".format(symbol.upper()), dup_str)
|
|
|
|
|
|
|
|
|
|
return check_passed
|
|
|
|
|
|
|
|
|
@ -571,6 +587,8 @@ def check(backend, icons, show_duplicates):
|
|
|
|
|
raise click.ClickException("Missing requirements for icon check")
|
|
|
|
|
|
|
|
|
|
defs, buckets = coin_info.coin_info_with_duplicates()
|
|
|
|
|
support_info = coin_info.support_info(defs)
|
|
|
|
|
mark_unsupported(support_info, defs.as_list())
|
|
|
|
|
all_checks_passed = True
|
|
|
|
|
|
|
|
|
|
print("Checking BTC-like coins...")
|
|
|
|
@ -586,7 +604,7 @@ def check(backend, icons, show_duplicates):
|
|
|
|
|
elif show_duplicates == "nontoken":
|
|
|
|
|
dup_level = logging.INFO
|
|
|
|
|
else:
|
|
|
|
|
dup_level = logging.ERROR
|
|
|
|
|
dup_level = logging.WARNING
|
|
|
|
|
print("Checking unexpected duplicates...")
|
|
|
|
|
if not check_dups(buckets, dup_level):
|
|
|
|
|
all_checks_passed = False
|
|
|
|
|