1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-17 21:22:10 +00:00

feat(common): remove "soon" as support status

This commit is contained in:
matejcik 2021-09-20 12:37:56 +02:00 committed by matejcik
parent 1a291660e5
commit d329052334
6 changed files with 22 additions and 61 deletions

View File

@ -149,18 +149,10 @@ Each coin on each device can be in one of four support states:
dictionary. The value is a string with reason for not supporting.
For connect and suite, if the key is not listed at all, it is also considered unsupported.
ERC20 tokens detected as duplicates are also considered unsupported.
* **soon**: coin's key is listed in the device's `supported` dictionary, with
the value `"soon"`.
ERC20 tokens that are not listed at all are also considered `soon`, unless detected
as duplicates.
* **unknown**: coin's key is not listed at all.
_Supported_ and _soon_ coins are used in code generation (i.e., included in built firmware).
_Supported_ coins are used in code generation (i.e., included in built firmware).
_Unsupported_ and _unknown_ coins are excluded from code generation.
That means that new ERC20 tokens are included as soon as you update the tokens repository.
New coin definitions, on the other hand, are not included until someone sets their
support status to _soon_ (or a version) explicitly.
You can edit `support.json` manually, but it is usually better to use the `support.py` tool.
See [tools docs](../tools) for details.

View File

@ -72,9 +72,7 @@ support_info = coin_info.support_info(defs.misc)
for key, support in support_info.values():
t2_support = support["trezor2"]
coin_name = dict_by_coin_key[key]
if t2_support == "soon":
print(coin_name, "will be supported soon!")
elif t2_support:
if t2_support:
print(coin_name, "is supported since version", t2_support)
else:
print(coin_name, "is not supported")
@ -97,15 +95,15 @@ fee.
# Release Workflow
This entails collecting information on coins whose support status is unknown,
marking coins whose support status is `soon`, and including new ERC20 tokens.
This entails collecting information on coins whose support status is unknown and
including new Ethereum chains and ERC20 tokens.
## Maintaining Support Status
When a new coin definition is added, its support status is _unknown_. It is excluded
from code generation by default. If you want to include a coin in a firmware build,
you need to switch it to _soon_ first. You can set multiple support statuses at the
same time:
you need to switch it to supported in a particular version first. You can set multiple
support statuses at the same time:
```
$ ./support.py show Ontology
@ -115,20 +113,17 @@ misc:ONT - Ontology (ONT)
* trezor2 : support info missing
* suite : NO
$ ./support.py set misc:ONT trezor1=no -r "not planned on T1" trezor2=soon
$ ./support.py set misc:ONT trezor1=no -r "not planned on T1" trezor2=2.4.7
misc:ONT - Ontology (ONT)
* connect : NO
* trezor1 : NO (reason: not planned on T1)
* trezor2 : SOON
* trezor2 : 2.4.7
* suite : NO
```
Afterwards, review and commit changes to `defs/support.json`, and update the `trezor-common`
submodule in your target firmware.
If you're adding multiple coins at once, you can use `support.py release 1 --soon` to automatically
add all currently-unknown coins to _soon_. (The `1` indicates that this is for Trezor One)
ERC20 tokens in _unknown_ state are considered _soon_ as well, unless their symbols
are duplicates. Use `support.py fix` to synchronize duplicate status in `support.json` file.
Or mark them as unsupported explicitly.

View File

@ -362,15 +362,13 @@ def support_info_single(support_data, coin):
top-level key.
The support value for each device is determined in order of priority:
* if the coin is a duplicate ERC20 token, all support values are `None`
* if the coin has an entry in `unsupported`, its support is `None`
* if the coin has an entry in `unsupported`, its support is `False`
* if the coin has an entry in `supported` its support is that entry
(usually a version string, or `True` for connect/suite)
* otherwise support is presumed "soon"
* if the coin doesn't have an entry, its support status is `None`
"""
support_info = {}
key = coin["key"]
dup = coin.get("duplicate")
for device, values in support_data.items():
if key in values["unsupported"]:
support_value = False
@ -378,13 +376,6 @@ def support_info_single(support_data, coin):
support_value = values["supported"][key]
elif device in MISSING_SUPPORT_MEANS_NO:
support_value = False
elif is_token(coin):
if dup:
# if duplicate token that is not explicitly listed, it's unsupported
support_value = False
else:
# otherwise implicitly supported in next
support_value = "soon"
else:
support_value = None
support_info[device] = support_value

View File

@ -14,7 +14,7 @@ import marketcap
LOG = logging.getLogger(__name__)
OPTIONAL_KEYS = ("links", "notes", "wallet")
ALLOWED_SUPPORT_STATUS = ("yes", "no", "planned", "soon")
ALLOWED_SUPPORT_STATUS = ("yes", "no")
WALLETS = coin_info.load_json("wallets.json")
OVERRIDES = coin_info.load_json("coins_details.override.json")
@ -78,18 +78,9 @@ def summary(coins, api_key):
def _is_supported(support, trezor_version):
version = VERSIONS[trezor_version]
nominal = support.get(trezor_version)
if nominal is None:
return "no"
elif isinstance(nominal, bool):
return "yes" if nominal else "no"
try:
nominal_version = tuple(map(int, nominal.split(".")))
return "yes" if nominal_version <= version else "soon"
except ValueError:
return nominal
# True or version string means YES
# False or None means NO
return "yes" if support.get(trezor_version) else "no"
def _suite_support(coin, support):
@ -227,10 +218,10 @@ def check_missing_data(coins):
LOG.log(level, f"{k}: Missing homepage")
hide = True
if coin["t1_enabled"] not in ALLOWED_SUPPORT_STATUS:
LOG.warning(f"{k}: Unknown t1_enabled")
LOG.error(f"{k}: Unknown t1_enabled: {coin['t1_enabled']}")
hide = True
if coin["t2_enabled"] not in ALLOWED_SUPPORT_STATUS:
LOG.warning(f"{k}: Unknown t2_enabled")
LOG.error(f"{k}: Unknown t2_enabled: {coin['t2_enabled']}")
hide = True
# check wallets

View File

@ -104,12 +104,7 @@ def ascii_filter(s):
def make_support_filter(support_info):
def supported_on(device, coins):
for coin in coins:
supp = support_info[coin.key].get(device)
if not supp:
continue
if coin_info.is_token(coin) or supp != "soon":
yield coin
return (c for c in coins if support_info[c.key].get(device))
return supported_on

View File

@ -67,8 +67,6 @@ def print_support(coin):
val = where["supported"][key]
if val is True:
return "YES"
elif val == "soon":
return "SOON"
elif VERSION_RE.match(val):
return f"YES since {val}"
else:
@ -98,10 +96,8 @@ def check_support_values():
if not isinstance(value, str):
raise ValueError(f"non-str value: {value}")
is_version = VERSION_RE.match(value)
is_soon = value == "soon"
if not (is_version or is_soon):
raise ValueError(f"expected version or 'soon', found '{value}'")
if not VERSION_RE.match(value):
raise ValueError(f"expected version, found '{value}'")
errors = []
for device, values in SUPPORT_INFO.items():
@ -437,14 +433,15 @@ def set_support_value(key, entries, reason):
"""Set a support info variable.
Examples:
support.py set coin:BTC trezor1=soon trezor2=2.0.7 suite=yes connect=no
support.py set coin:BTC trezor1=1.10.5 trezor2=2.4.7 suite=yes connect=no
support.py set coin:LTC trezor1=yes connect=
Setting a variable to "yes", "true" or "1" sets support to true.
Setting a variable to "no", "false" or "0" sets support to false.
(or null, in case of trezor1/2)
Setting variable to empty ("trezor1=") will set to null, or clear the entry.
Setting to "soon", "planned", "2.1.1" etc. will set the literal string.
Setting a variable to a particular version string (e.g., "2.4.7") will set that
particular version.
"""
defs, _ = coin_info.coin_info_with_duplicates()
coins = defs.as_dict()