diff --git a/src/apps/ethereum/layout.py b/src/apps/ethereum/layout.py index 25fceda83e..faf4045ff2 100644 --- a/src/apps/ethereum/layout.py +++ b/src/apps/ethereum/layout.py @@ -27,7 +27,7 @@ async def require_confirm_fee(ctx, spending, gas_price, gas_limit, chain_id, tok ui.NORMAL, 'Gas price:', ui.BOLD, format_ethereum_amount(gas_price, None, chain_id, tx_type), ui.NORMAL, 'Maximum fee:', - ui.BOLD, format_ethereum_amount(gas_price *gas_limit, None, chain_id, tx_type), + ui.BOLD, format_ethereum_amount(gas_price * gas_limit, None, chain_id, tx_type), icon_color=ui.GREEN) await require_hold_to_confirm(ctx, content, ButtonRequestType.SignTx) diff --git a/src/apps/ethereum/networks.py b/src/apps/ethereum/networks.py index f3a378fe62..9f8a603b4d 100644 --- a/src/apps/ethereum/networks.py +++ b/src/apps/ethereum/networks.py @@ -13,7 +13,7 @@ suffixes = { def suffix_by_chain_id(chain_id, tx_type=None): - if (tx_type==1 or tx_type==6) and (chain_id==1 or chain_id==3): - return"WAN" + if tx_type in [1, 6] and chain_id in [1, 3]: + return 'WAN' else: return suffixes.get(chain_id, 'UNKN') diff --git a/src/apps/ethereum/sign_tx.py b/src/apps/ethereum/sign_tx.py index 10188748e4..762ddcc870 100644 --- a/src/apps/ethereum/sign_tx.py +++ b/src/apps/ethereum/sign_tx.py @@ -46,7 +46,7 @@ async def ethereum_sign_tx(ctx, msg): sha = HashWriter(sha3_256) sha.extend(rlp.encode_length(total_length, True)) # total length - if not msg.tx_type is None: + if msg.tx_type is not None: sha.extend(rlp.encode(msg.tx_type)) for field in [msg.nonce, msg.gas_price, msg.gas_limit, msg.to, msg.value]: @@ -75,7 +75,7 @@ async def ethereum_sign_tx(ctx, msg): def get_total_length(msg: EthereumSignTx, data_total: int) -> int: length = 0 - if not msg.tx_type is None: + if msg.tx_type is not None: length += rlp.field_length(1, [msg.tx_type]) for field in [msg.nonce, msg.gas_price, msg.gas_limit, msg.to, msg.value]: @@ -130,10 +130,10 @@ def node_derive(root, address_n: list): def check(msg: EthereumSignTx): if msg.tx_type not in [1, 6, None]: - raise ValueError(FailureType.DataError, 'Txtype out of bounds') + raise wire.DataError('tx_type out of bounds') if msg.chain_id < 0 or msg.chain_id > MAX_CHAIN_ID: - raise wire.DataError('Chain id out of bounds') + raise wire.DataError('chain_id out of bounds') if msg.data_length > 0: if not msg.data_initial_chunk: diff --git a/src/apps/management/recovery_device.py b/src/apps/management/recovery_device.py index b4c377805c..432edd6650 100644 --- a/src/apps/management/recovery_device.py +++ b/src/apps/management/recovery_device.py @@ -2,7 +2,6 @@ from trezor import config, ui, wire from trezor.crypto import bip39 from trezor.messages.ButtonRequest import ButtonRequest from trezor.messages.ButtonRequestType import MnemonicWordCount, MnemonicInput -from trezor.messages.FailureType import ProcessError, UnexpectedMessage from trezor.messages.Success import Success from trezor.messages.wire_types import ButtonAck from trezor.pin import pin_to_int diff --git a/src/apps/wallet/sign_message.py b/src/apps/wallet/sign_message.py index 83128ba572..dc6b0b696f 100644 --- a/src/apps/wallet/sign_message.py +++ b/src/apps/wallet/sign_message.py @@ -1,7 +1,6 @@ from trezor import ui, wire from trezor.crypto.curve import secp256k1 from trezor.messages.InputScriptType import SPENDADDRESS, SPENDP2SHWITNESS, SPENDWITNESS -from trezor.messages.FailureType import ProcessError from trezor.messages.MessageSignature import MessageSignature from trezor.ui.text import Text from apps.common import coins, seed