1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-18 20:38:10 +00:00

fix(python/trezorctl): do not implicitly import rlp on Python 3.6

This commit is contained in:
matejcik 2022-06-30 15:34:13 +02:00
parent 5977cca202
commit 3141f808dd
2 changed files with 25 additions and 7 deletions

View File

@ -0,0 +1 @@
Fixed dependency error when running trezorctl on Python 3.6 without rlp.

View File

@ -18,10 +18,19 @@ import json
import re
import sys
from decimal import Decimal
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Sequence, TextIO, Tuple
from typing import (
TYPE_CHECKING,
Any,
Dict,
List,
NoReturn,
Optional,
Sequence,
TextIO,
Tuple,
)
import click
import rlp
from .. import ethereum, tools
from . import with_client
@ -60,6 +69,14 @@ ETHER_UNITS = {
_WEB3_INSTANCE: Optional["web3.Web3"] = None
def _print_eth_dependencies_and_die() -> NoReturn:
click.echo("Ethereum requirements not installed.")
click.echo("Please run:")
click.echo()
click.echo(" pip install trezor[ethereum]")
sys.exit(1)
def _get_web3() -> "web3.Web3":
global _WEB3_INSTANCE
if _WEB3_INSTANCE is None:
@ -68,11 +85,7 @@ def _get_web3() -> "web3.Web3":
_WEB3_INSTANCE = web3.Web3()
except ModuleNotFoundError:
click.echo("Ethereum requirements not installed.")
click.echo("Please run:")
click.echo()
click.echo(" pip install web3")
sys.exit(1)
_print_eth_dependencies_and_die()
return _WEB3_INSTANCE
@ -271,6 +284,10 @@ def sign_tx(
try to connect to an ethereum node and auto-fill these values. You can configure
the connection with WEB3_PROVIDER_URI environment variable.
"""
try:
import rlp
except ImportError:
_print_eth_dependencies_and_die()
is_eip1559 = eip2718_type == 2
if (