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

feat(common): cointool: add new-definitions command

[no changelog]
This commit is contained in:
Martin Milata 2023-09-14 19:10:25 +02:00
parent efab85a963
commit 10b248b18f
2 changed files with 23 additions and 0 deletions

View File

@ -21,6 +21,9 @@ from coin_info import Coin, CoinBuckets, Coins, CoinsInfo, FidoApps, SupportInfo
DEFINITIONS_TIMESTAMP_PATH = (
coin_info.DEFS_DIR / "ethereum" / "released-definitions-timestamp.txt"
)
DEFINITIONS_LATEST_URL = (
"https://raw.githubusercontent.com/trezor/definitions/main/definitions-latest.json"
)
try:
import termcolor
@ -912,5 +915,24 @@ def render(
do_render(file, dst)
@cli.command()
# fmt: off
@click.option("-v", "--verbose", is_flag=True, help="Print timestamp and merkle root")
# fmt: on
def new_definitions(verbose: bool) -> None:
"""Update timestamp of external coin definitions."""
assert requests is not None
eth_defs = requests.get(DEFINITIONS_LATEST_URL).json()
eth_defs_date = eth_defs["metadata"]["datetime"]
if verbose:
click.echo(
f"Latest definitions from {eth_defs_date}: {eth_defs['metadata']['merkle_root']}"
)
eth_defs_date = datetime.datetime.fromisoformat(eth_defs_date)
DEFINITIONS_TIMESTAMP_PATH.write_text(
eth_defs_date.isoformat(timespec="seconds") + "\n"
)
if __name__ == "__main__":
cli()

View File

@ -7,6 +7,7 @@ trap "rm -r $CHECK_OUTPUT" EXIT
$HERE/cointool.py check > $CHECK_OUTPUT/pre.txt
$HERE/cointool.py new-definitions -v
$HERE/support.py release
$HERE/cointool.py check > $CHECK_OUTPUT/post.txt