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
|
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):
|
def check_backends(coins):
|
||||||
check_passed = True
|
check_passed = True
|
||||||
for coin in coins:
|
for coin in coins:
|
||||||
@ -250,7 +272,8 @@ def check(missing_support, backend, icons):
|
|||||||
if icons and not CAN_BUILD_DEFS:
|
if icons and not CAN_BUILD_DEFS:
|
||||||
raise click.ClickException("Missing requirements for icon check")
|
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
|
all_checks_passed = True
|
||||||
|
|
||||||
print("Checking BTC-like coins...")
|
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):
|
# if not check_support(defs, support_data, fail_missing=missing_support):
|
||||||
# all_checks_passed = False
|
# all_checks_passed = False
|
||||||
|
|
||||||
|
print("Checking unexpected duplicates...")
|
||||||
|
if not check_dups(buckets):
|
||||||
|
all_checks_passed = False
|
||||||
|
|
||||||
if icons:
|
if icons:
|
||||||
print("Checking icon files...")
|
print("Checking icon files...")
|
||||||
if not check_icons(defs.coins):
|
if not check_icons(defs.coins):
|
||||||
|
@ -42,11 +42,14 @@ def print_support(coin):
|
|||||||
key, name, shortcut = coin["key"], coin["name"], coin["shortcut"]
|
key, name, shortcut = coin["key"], coin["name"], coin["shortcut"]
|
||||||
print(f"{key} - {name} ({shortcut})")
|
print(f"{key} - {name} ({shortcut})")
|
||||||
if coin.get("duplicate"):
|
if coin.get("duplicate"):
|
||||||
print(" * DUPLICATE SYMBOL (no support)")
|
if key.startswith("erc20:"):
|
||||||
else:
|
print(" * DUPLICATE SYMBOL (no support)")
|
||||||
for dev, where in SUPPORT_INFO.items():
|
return
|
||||||
missing_means_no = dev in MISSING_MEANS_NO
|
else:
|
||||||
print(" *", dev, ":", support_value(where, key, missing_means_no))
|
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 ====== #
|
# ====== validation functions ====== #
|
||||||
|
Loading…
Reference in New Issue
Block a user