mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 23:48:12 +00:00
tools: add better duplicate checking
This commit is contained in:
parent
81513f47b6
commit
6cbc2a94ee
@ -127,6 +127,28 @@ def check_btc(coins):
|
||||
return check_passed
|
||||
|
||||
|
||||
def check_dups(buckets):
|
||||
check_passed = True
|
||||
for bucket in buckets.values():
|
||||
nontokens = [coin for coin in bucket if not coin["key"].startswith("erc20")]
|
||||
token_list = [coin["key"] for coin in bucket if coin["key"].startswith("erc20")]
|
||||
if not nontokens:
|
||||
continue
|
||||
if len(nontokens) == 1:
|
||||
coin = nontokens[0]
|
||||
print(
|
||||
f"Coin {coin['key']} ({coin['name']}) is duplicate with",
|
||||
", ".join(token_list),
|
||||
"and that is OK.",
|
||||
)
|
||||
else:
|
||||
nontoken_list = [f"{coin['key']} ({coin['name']})" for coin in nontokens]
|
||||
print("Duplicate shortcuts for", ", ".join(nontoken_list))
|
||||
check_passed = False
|
||||
|
||||
return check_passed
|
||||
|
||||
|
||||
def check_backends(coins):
|
||||
check_passed = True
|
||||
for coin in coins:
|
||||
@ -250,7 +272,8 @@ def check(missing_support, backend, icons):
|
||||
if icons and not CAN_BUILD_DEFS:
|
||||
raise click.ClickException("Missing requirements for icon check")
|
||||
|
||||
defs = coin_info.get_all()
|
||||
defs = coin_info.get_all(deduplicate=False)
|
||||
buckets = coin_info.mark_duplicate_shortcuts(defs.as_list())
|
||||
all_checks_passed = True
|
||||
|
||||
print("Checking BTC-like coins...")
|
||||
@ -263,6 +286,10 @@ def check(missing_support, backend, icons):
|
||||
# if not check_support(defs, support_data, fail_missing=missing_support):
|
||||
# all_checks_passed = False
|
||||
|
||||
print("Checking unexpected duplicates...")
|
||||
if not check_dups(buckets):
|
||||
all_checks_passed = False
|
||||
|
||||
if icons:
|
||||
print("Checking icon files...")
|
||||
if not check_icons(defs.coins):
|
||||
|
@ -42,11 +42,14 @@ def print_support(coin):
|
||||
key, name, shortcut = coin["key"], coin["name"], coin["shortcut"]
|
||||
print(f"{key} - {name} ({shortcut})")
|
||||
if coin.get("duplicate"):
|
||||
print(" * DUPLICATE SYMBOL (no support)")
|
||||
else:
|
||||
for dev, where in SUPPORT_INFO.items():
|
||||
missing_means_no = dev in MISSING_MEANS_NO
|
||||
print(" *", dev, ":", support_value(where, key, missing_means_no))
|
||||
if key.startswith("erc20:"):
|
||||
print(" * DUPLICATE SYMBOL (no support)")
|
||||
return
|
||||
else:
|
||||
print(" * DUPLICATE SYMBOL")
|
||||
for dev, where in SUPPORT_INFO.items():
|
||||
missing_means_no = dev in MISSING_MEANS_NO
|
||||
print(" *", dev, ":", support_value(where, key, missing_means_no))
|
||||
|
||||
|
||||
# ====== validation functions ====== #
|
||||
|
Loading…
Reference in New Issue
Block a user