From 4ca8f7b0d6baf7d411c217865793145cc1e4cfba Mon Sep 17 00:00:00 2001 From: matejcik Date: Tue, 11 Aug 2020 15:55:05 +0200 Subject: [PATCH] style(core): use relative imports everywhere except Monero, which has a rather complex structure and I don't want to search&replace mess with it in case some of the things break memory layout --- core/src/apps/binance/get_address.py | 3 ++- core/src/apps/binance/get_public_key.py | 3 ++- core/src/apps/binance/sign_tx.py | 3 ++- core/src/apps/eos/actions/__init__.py | 4 ++-- core/src/apps/eos/actions/layout.py | 4 ++-- core/src/apps/eos/get_public_key.py | 7 ++++--- core/src/apps/eos/sign_tx.py | 9 ++++---- core/src/apps/ethereum/address.py | 3 ++- core/src/apps/ethereum/get_address.py | 7 ++++--- core/src/apps/ethereum/get_public_key.py | 5 +++-- core/src/apps/ethereum/layout.py | 5 +++-- core/src/apps/ethereum/sign_message.py | 5 +++-- core/src/apps/ethereum/sign_tx.py | 13 +++++------- core/src/apps/ethereum/verify_message.py | 5 +++-- core/src/apps/lisk/get_address.py | 2 +- core/src/apps/lisk/get_public_key.py | 5 +++-- core/src/apps/lisk/sign_message.py | 5 +++-- core/src/apps/lisk/sign_tx.py | 5 +++-- core/src/apps/management/backup_device.py | 3 ++- .../management/recovery_device/__init__.py | 6 ++---- .../management/recovery_device/homescreen.py | 5 ++--- .../apps/management/recovery_device/layout.py | 2 +- .../management/recovery_device/recover.py | 2 +- .../recovery_device/word_validity.py | 2 +- .../apps/management/reset_device/__init__.py | 6 +++--- core/src/apps/nem/get_address.py | 7 ++++--- core/src/apps/nem/sign_tx.py | 7 ++++--- core/src/apps/ripple/get_address.py | 3 ++- core/src/apps/ripple/sign_tx.py | 5 +++-- core/src/apps/stellar/get_address.py | 3 ++- core/src/apps/stellar/layout.py | 3 ++- core/src/apps/stellar/operations/__init__.py | 4 ++-- core/src/apps/stellar/operations/layout.py | 4 ++-- core/src/apps/stellar/operations/serialize.py | 2 +- core/src/apps/stellar/sign_tx.py | 5 +++-- core/src/apps/tezos/get_address.py | 3 ++- core/src/apps/tezos/get_public_key.py | 3 ++- core/src/apps/tezos/layout.py | 3 ++- core/src/apps/tezos/sign_tx.py | 3 ++- core/src/apps/webauthn/__init__.py | 2 +- .../apps/webauthn/add_resident_credential.py | 7 ++++--- core/src/apps/webauthn/confirm.py | 2 +- core/src/apps/webauthn/credential.py | 7 ++++--- core/src/apps/webauthn/fido2.py | 21 +++++++------------ .../webauthn/list_resident_credentials.py | 3 ++- .../webauthn/remove_resident_credential.py | 7 ++++--- .../src/apps/webauthn/resident_credentials.py | 2 +- 47 files changed, 121 insertions(+), 104 deletions(-) diff --git a/core/src/apps/binance/get_address.py b/core/src/apps/binance/get_address.py index dedf843c0..07ee96d01 100644 --- a/core/src/apps/binance/get_address.py +++ b/core/src/apps/binance/get_address.py @@ -1,11 +1,12 @@ from trezor.messages.BinanceAddress import BinanceAddress from trezor.messages.BinanceGetAddress import BinanceGetAddress -from apps.binance import CURVE, SLIP44_ID, helpers from apps.common import paths from apps.common.keychain import Keychain, with_slip44_keychain from apps.common.layout import address_n_to_str, show_address, show_qr +from . import CURVE, SLIP44_ID, helpers + @with_slip44_keychain(SLIP44_ID, CURVE, allow_testnet=True) async def get_address(ctx, msg: BinanceGetAddress, keychain: Keychain): diff --git a/core/src/apps/binance/get_public_key.py b/core/src/apps/binance/get_public_key.py index 61633d0b6..8e8f155d2 100644 --- a/core/src/apps/binance/get_public_key.py +++ b/core/src/apps/binance/get_public_key.py @@ -1,10 +1,11 @@ from trezor.messages.BinanceGetPublicKey import BinanceGetPublicKey from trezor.messages.BinancePublicKey import BinancePublicKey -from apps.binance import CURVE, SLIP44_ID, helpers from apps.common import layout, paths from apps.common.keychain import Keychain, with_slip44_keychain +from . import CURVE, SLIP44_ID, helpers + @with_slip44_keychain(SLIP44_ID, CURVE, allow_testnet=True) async def get_public_key(ctx, msg: BinanceGetPublicKey, keychain: Keychain): diff --git a/core/src/apps/binance/sign_tx.py b/core/src/apps/binance/sign_tx.py index 0f6409e01..e6386b432 100644 --- a/core/src/apps/binance/sign_tx.py +++ b/core/src/apps/binance/sign_tx.py @@ -8,10 +8,11 @@ from trezor.messages.BinanceSignedTx import BinanceSignedTx from trezor.messages.BinanceTransferMsg import BinanceTransferMsg from trezor.messages.BinanceTxRequest import BinanceTxRequest -from apps.binance import CURVE, SLIP44_ID, helpers, layout from apps.common import paths from apps.common.keychain import Keychain, with_slip44_keychain +from . import CURVE, SLIP44_ID, helpers, layout + @with_slip44_keychain(SLIP44_ID, CURVE, allow_testnet=True) async def sign_tx(ctx, envelope, keychain: Keychain): diff --git a/core/src/apps/eos/actions/__init__.py b/core/src/apps/eos/actions/__init__.py index 8f43ac747..5400448c0 100644 --- a/core/src/apps/eos/actions/__init__.py +++ b/core/src/apps/eos/actions/__init__.py @@ -3,8 +3,8 @@ from trezor.messages.EosTxActionAck import EosTxActionAck from trezor.messages.EosTxActionRequest import EosTxActionRequest from trezor.utils import HashWriter -from apps.eos import helpers, writers -from apps.eos.actions import layout +from .. import helpers, writers +from . import layout if False: from trezor import wire diff --git a/core/src/apps/eos/actions/layout.py b/core/src/apps/eos/actions/layout.py index f6342582a..eee591155 100644 --- a/core/src/apps/eos/actions/layout.py +++ b/core/src/apps/eos/actions/layout.py @@ -7,8 +7,8 @@ from trezor.ui.scroll import Paginated from trezor.ui.text import Text from trezor.utils import chunks -from apps.eos import helpers -from apps.eos.layout import require_confirm +from .. import helpers +from ..layout import require_confirm if False: from typing import List diff --git a/core/src/apps/eos/get_public_key.py b/core/src/apps/eos/get_public_key.py index 9d2e30a6b..14f0f19f5 100644 --- a/core/src/apps/eos/get_public_key.py +++ b/core/src/apps/eos/get_public_key.py @@ -5,9 +5,10 @@ from trezor.messages.EosPublicKey import EosPublicKey from apps.common import paths from apps.common.keychain import Keychain, with_slip44_keychain -from apps.eos import CURVE, SLIP44_ID -from apps.eos.helpers import public_key_to_wif, validate_full_path -from apps.eos.layout import require_get_public_key + +from . import CURVE, SLIP44_ID +from .helpers import public_key_to_wif, validate_full_path +from .layout import require_get_public_key if False: from typing import Tuple diff --git a/core/src/apps/eos/sign_tx.py b/core/src/apps/eos/sign_tx.py index 024141b03..e90fa4148 100644 --- a/core/src/apps/eos/sign_tx.py +++ b/core/src/apps/eos/sign_tx.py @@ -9,10 +9,11 @@ from trezor.utils import HashWriter from apps.common import paths from apps.common.keychain import Keychain, with_slip44_keychain -from apps.eos import CURVE, SLIP44_ID, writers -from apps.eos.actions import process_action -from apps.eos.helpers import base58_encode, validate_full_path -from apps.eos.layout import require_sign_tx + +from . import CURVE, SLIP44_ID, writers +from .actions import process_action +from .helpers import base58_encode, validate_full_path +from .layout import require_sign_tx @with_slip44_keychain(SLIP44_ID, CURVE) diff --git a/core/src/apps/ethereum/address.py b/core/src/apps/ethereum/address.py index ad0b21bc8..cfb2e70c1 100644 --- a/core/src/apps/ethereum/address.py +++ b/core/src/apps/ethereum/address.py @@ -3,7 +3,8 @@ from ubinascii import unhexlify from trezor import wire from apps.common import HARDENED, paths -from apps.ethereum import networks + +from . import networks """ diff --git a/core/src/apps/ethereum/get_address.py b/core/src/apps/ethereum/get_address.py index d8f09adc7..c553ae276 100644 --- a/core/src/apps/ethereum/get_address.py +++ b/core/src/apps/ethereum/get_address.py @@ -4,9 +4,10 @@ from trezor.messages.EthereumAddress import EthereumAddress from apps.common import paths from apps.common.layout import address_n_to_str, show_address, show_qr -from apps.ethereum import CURVE, networks -from apps.ethereum.address import address_from_bytes, validate_full_path -from apps.ethereum.keychain import with_keychain_from_path + +from . import CURVE, networks +from .address import address_from_bytes, validate_full_path +from .keychain import with_keychain_from_path @with_keychain_from_path diff --git a/core/src/apps/ethereum/get_public_key.py b/core/src/apps/ethereum/get_public_key.py index 14f9e8c21..9be1447f4 100644 --- a/core/src/apps/ethereum/get_public_key.py +++ b/core/src/apps/ethereum/get_public_key.py @@ -2,8 +2,9 @@ from trezor.messages.EthereumPublicKey import EthereumPublicKey from trezor.messages.HDNodeType import HDNodeType from apps.common import coins, layout, paths -from apps.ethereum import CURVE, address -from apps.ethereum.keychain import with_keychain_from_path + +from . import CURVE, address +from .keychain import with_keychain_from_path @with_keychain_from_path diff --git a/core/src/apps/ethereum/layout.py b/core/src/apps/ethereum/layout.py index 8fd3199cd..363c81bd7 100644 --- a/core/src/apps/ethereum/layout.py +++ b/core/src/apps/ethereum/layout.py @@ -8,8 +8,9 @@ from trezor.utils import chunks from apps.common.confirm import require_confirm, require_hold_to_confirm from apps.common.layout import split_address -from apps.ethereum import networks, tokens -from apps.ethereum.address import address_from_bytes + +from . import networks, tokens +from .address import address_from_bytes async def require_confirm_tx(ctx, to_bytes, value, chain_id, token=None, tx_type=None): diff --git a/core/src/apps/ethereum/sign_message.py b/core/src/apps/ethereum/sign_message.py index a7eec046b..e975dd0a3 100644 --- a/core/src/apps/ethereum/sign_message.py +++ b/core/src/apps/ethereum/sign_message.py @@ -5,8 +5,9 @@ from trezor.utils import HashWriter from apps.common import paths from apps.common.signverify import require_confirm_sign_message -from apps.ethereum import CURVE, address -from apps.ethereum.keychain import with_keychain_from_path + +from . import CURVE, address +from .keychain import with_keychain_from_path def message_digest(message): diff --git a/core/src/apps/ethereum/sign_tx.py b/core/src/apps/ethereum/sign_tx.py index 839e777b5..7e2ab5751 100644 --- a/core/src/apps/ethereum/sign_tx.py +++ b/core/src/apps/ethereum/sign_tx.py @@ -8,14 +8,11 @@ from trezor.messages.EthereumTxRequest import EthereumTxRequest from trezor.utils import HashWriter from apps.common import paths -from apps.ethereum import CURVE, address, tokens -from apps.ethereum.address import validate_full_path -from apps.ethereum.keychain import with_keychain_from_chain_id -from apps.ethereum.layout import ( - require_confirm_data, - require_confirm_fee, - require_confirm_tx, -) + +from . import CURVE, address, tokens +from .address import validate_full_path +from .keychain import with_keychain_from_chain_id +from .layout import require_confirm_data, require_confirm_fee, require_confirm_tx # maximum supported chain id MAX_CHAIN_ID = 2147483629 diff --git a/core/src/apps/ethereum/verify_message.py b/core/src/apps/ethereum/verify_message.py index 733565d66..d17773829 100644 --- a/core/src/apps/ethereum/verify_message.py +++ b/core/src/apps/ethereum/verify_message.py @@ -4,8 +4,9 @@ from trezor.crypto.hashlib import sha3_256 from trezor.messages.Success import Success from apps.common.signverify import require_confirm_verify_message -from apps.ethereum.address import address_from_bytes, bytes_from_address -from apps.ethereum.sign_message import message_digest + +from .address import address_from_bytes, bytes_from_address +from .sign_message import message_digest async def verify_message(ctx, msg): diff --git a/core/src/apps/lisk/get_address.py b/core/src/apps/lisk/get_address.py index 9419b4101..e5cba1543 100644 --- a/core/src/apps/lisk/get_address.py +++ b/core/src/apps/lisk/get_address.py @@ -3,8 +3,8 @@ from trezor.messages.LiskAddress import LiskAddress from apps.common import paths from apps.common.keychain import with_slip44_keychain from apps.common.layout import address_n_to_str, show_address, show_qr -from apps.lisk import CURVE, SLIP44_ID +from . import CURVE, SLIP44_ID from .helpers import get_address_from_public_key, validate_full_path diff --git a/core/src/apps/lisk/get_public_key.py b/core/src/apps/lisk/get_public_key.py index e22c81470..80d1f6bc9 100644 --- a/core/src/apps/lisk/get_public_key.py +++ b/core/src/apps/lisk/get_public_key.py @@ -2,8 +2,9 @@ from trezor.messages.LiskPublicKey import LiskPublicKey from apps.common import layout, paths from apps.common.keychain import with_slip44_keychain -from apps.lisk import CURVE, SLIP44_ID -from apps.lisk.helpers import validate_full_path + +from . import CURVE, SLIP44_ID +from .helpers import validate_full_path @with_slip44_keychain(SLIP44_ID, CURVE, allow_testnet=True) diff --git a/core/src/apps/lisk/sign_message.py b/core/src/apps/lisk/sign_message.py index f07489419..074ac2f9c 100644 --- a/core/src/apps/lisk/sign_message.py +++ b/core/src/apps/lisk/sign_message.py @@ -7,8 +7,9 @@ from apps.common import paths from apps.common.keychain import with_slip44_keychain from apps.common.signverify import require_confirm_sign_message from apps.common.writers import write_bitcoin_varint -from apps.lisk import CURVE, SLIP44_ID -from apps.lisk.helpers import validate_full_path + +from . import CURVE, SLIP44_ID +from .helpers import validate_full_path def message_digest(message): diff --git a/core/src/apps/lisk/sign_tx.py b/core/src/apps/lisk/sign_tx.py index 754cd11d5..7224017ae 100644 --- a/core/src/apps/lisk/sign_tx.py +++ b/core/src/apps/lisk/sign_tx.py @@ -9,8 +9,9 @@ from trezor.utils import HashWriter from apps.common import paths from apps.common.keychain import with_slip44_keychain -from apps.lisk import CURVE, SLIP44_ID, layout -from apps.lisk.helpers import get_address_from_public_key, validate_full_path + +from . import CURVE, SLIP44_ID, layout +from .helpers import get_address_from_public_key, validate_full_path @with_slip44_keychain(SLIP44_ID, CURVE, allow_testnet=True) diff --git a/core/src/apps/management/backup_device.py b/core/src/apps/management/backup_device.py index d7f2c4c28..fa5c399f7 100644 --- a/core/src/apps/management/backup_device.py +++ b/core/src/apps/management/backup_device.py @@ -4,7 +4,8 @@ from trezor import wire from trezor.messages.Success import Success from apps.common import mnemonic -from apps.management.reset_device import backup_seed, layout + +from .reset_device import backup_seed, layout async def backup_device(ctx, msg): diff --git a/core/src/apps/management/recovery_device/__init__.py b/core/src/apps/management/recovery_device/__init__.py index 5d83d532a..97f41b8a4 100644 --- a/core/src/apps/management/recovery_device/__init__.py +++ b/core/src/apps/management/recovery_device/__init__.py @@ -13,10 +13,8 @@ from apps.common.request_pin import ( request_pin_and_sd_salt, request_pin_confirm, ) -from apps.management.recovery_device.homescreen import ( - recovery_homescreen, - recovery_process, -) + +from .homescreen import recovery_homescreen, recovery_process if False: from trezor.messages.RecoveryDevice import RecoveryDevice diff --git a/core/src/apps/management/recovery_device/homescreen.py b/core/src/apps/management/recovery_device/homescreen.py index f1ca0c3a7..434a64043 100644 --- a/core/src/apps/management/recovery_device/homescreen.py +++ b/core/src/apps/management/recovery_device/homescreen.py @@ -12,10 +12,9 @@ from trezor.messages.Success import Success from apps.common import mnemonic from apps.common.layout import show_success from apps.homescreen.homescreen import homescreen -from apps.management import backup_types -from apps.management.recovery_device import layout -from . import recover +from .. import backup_types +from . import layout, recover if False: from typing import Optional, Tuple diff --git a/core/src/apps/management/recovery_device/layout.py b/core/src/apps/management/recovery_device/layout.py index bbd03e45b..c8ffbe18c 100644 --- a/core/src/apps/management/recovery_device/layout.py +++ b/core/src/apps/management/recovery_device/layout.py @@ -9,8 +9,8 @@ from trezor.ui.word_select import WordSelector from apps.common import button_request from apps.common.confirm import confirm, info_confirm, require_confirm from apps.common.layout import show_success, show_warning -from apps.management import backup_types +from .. import backup_types from . import word_validity from .keyboard_bip39 import Bip39Keyboard from .keyboard_slip39 import Slip39Keyboard diff --git a/core/src/apps/management/recovery_device/recover.py b/core/src/apps/management/recovery_device/recover.py index 98d09230a..ac9e3a8cb 100644 --- a/core/src/apps/management/recovery_device/recover.py +++ b/core/src/apps/management/recovery_device/recover.py @@ -3,7 +3,7 @@ import storage.recovery_shares from trezor.crypto import bip39, slip39 from trezor.errors import MnemonicError -from apps.management import backup_types +from .. import backup_types if False: from trezor.messages.ResetDevice import EnumTypeBackupType diff --git a/core/src/apps/management/recovery_device/word_validity.py b/core/src/apps/management/recovery_device/word_validity.py index f1d278cd5..a72310718 100644 --- a/core/src/apps/management/recovery_device/word_validity.py +++ b/core/src/apps/management/recovery_device/word_validity.py @@ -1,7 +1,7 @@ import storage.recovery from trezor.messages import BackupType -from apps.management.recovery_device import recover +from . import recover if False: from typing import List, Optional diff --git a/core/src/apps/management/reset_device/__init__.py b/core/src/apps/management/reset_device/__init__.py index e94b1b858..781952cd5 100644 --- a/core/src/apps/management/reset_device/__init__.py +++ b/core/src/apps/management/reset_device/__init__.py @@ -8,9 +8,9 @@ from trezor.messages.EntropyRequest import EntropyRequest from trezor.messages.Success import Success from trezor.pin import pin_to_int -from apps.management import backup_types -from apps.management.change_pin import request_pin_confirm -from apps.management.reset_device import layout +from .. import backup_types +from ..change_pin import request_pin_confirm +from . import layout if __debug__: from apps import debug diff --git a/core/src/apps/nem/get_address.py b/core/src/apps/nem/get_address.py index 079cb076f..99ae7d6c1 100644 --- a/core/src/apps/nem/get_address.py +++ b/core/src/apps/nem/get_address.py @@ -3,9 +3,10 @@ from trezor.messages.NEMAddress import NEMAddress from apps.common.keychain import with_slip44_keychain from apps.common.layout import address_n_to_str, show_address, show_qr from apps.common.paths import validate_path -from apps.nem import CURVE, SLIP44_ID -from apps.nem.helpers import check_path, get_network_str -from apps.nem.validators import validate_network + +from . import CURVE, SLIP44_ID +from .helpers import check_path, get_network_str +from .validators import validate_network @with_slip44_keychain(SLIP44_ID, CURVE, allow_testnet=True) diff --git a/core/src/apps/nem/sign_tx.py b/core/src/apps/nem/sign_tx.py index d7c305452..73be9f9de 100644 --- a/core/src/apps/nem/sign_tx.py +++ b/core/src/apps/nem/sign_tx.py @@ -6,9 +6,10 @@ from trezor.messages.NEMSignTx import NEMSignTx from apps.common import seed from apps.common.keychain import with_slip44_keychain from apps.common.paths import validate_path -from apps.nem import CURVE, SLIP44_ID, mosaic, multisig, namespace, transfer -from apps.nem.helpers import NEM_HASH_ALG, check_path -from apps.nem.validators import validate + +from . import CURVE, SLIP44_ID, mosaic, multisig, namespace, transfer +from .helpers import NEM_HASH_ALG, check_path +from .validators import validate @with_slip44_keychain(SLIP44_ID, CURVE, allow_testnet=True) diff --git a/core/src/apps/ripple/get_address.py b/core/src/apps/ripple/get_address.py index 11664a1af..28fce0de4 100644 --- a/core/src/apps/ripple/get_address.py +++ b/core/src/apps/ripple/get_address.py @@ -4,7 +4,8 @@ from trezor.messages.RippleGetAddress import RippleGetAddress from apps.common import paths from apps.common.keychain import with_slip44_keychain from apps.common.layout import address_n_to_str, show_address, show_qr -from apps.ripple import CURVE, SLIP44_ID, helpers + +from . import CURVE, SLIP44_ID, helpers @with_slip44_keychain(SLIP44_ID, CURVE, allow_testnet=True) diff --git a/core/src/apps/ripple/sign_tx.py b/core/src/apps/ripple/sign_tx.py index 10627d3c2..ad03953a0 100644 --- a/core/src/apps/ripple/sign_tx.py +++ b/core/src/apps/ripple/sign_tx.py @@ -7,8 +7,9 @@ from trezor.wire import ProcessError from apps.common import paths from apps.common.keychain import with_slip44_keychain -from apps.ripple import CURVE, SLIP44_ID, helpers, layout -from apps.ripple.serialize import serialize + +from . import CURVE, SLIP44_ID, helpers, layout +from .serialize import serialize @with_slip44_keychain(SLIP44_ID, CURVE, allow_testnet=True) diff --git a/core/src/apps/stellar/get_address.py b/core/src/apps/stellar/get_address.py index 020cf282d..197609adc 100644 --- a/core/src/apps/stellar/get_address.py +++ b/core/src/apps/stellar/get_address.py @@ -4,7 +4,8 @@ from trezor.messages.StellarGetAddress import StellarGetAddress from apps.common import paths, seed from apps.common.keychain import with_slip44_keychain from apps.common.layout import address_n_to_str, show_address, show_qr -from apps.stellar import CURVE, SLIP44_ID, helpers + +from . import CURVE, SLIP44_ID, helpers @with_slip44_keychain(SLIP44_ID, CURVE, allow_testnet=True) diff --git a/core/src/apps/stellar/layout.py b/core/src/apps/stellar/layout.py index 4744e7d16..626124571 100644 --- a/core/src/apps/stellar/layout.py +++ b/core/src/apps/stellar/layout.py @@ -3,7 +3,8 @@ from trezor.messages import ButtonRequestType from trezor.ui.text import Text from apps.common.confirm import require_confirm, require_hold_to_confirm -from apps.stellar import consts + +from . import consts async def require_confirm_init( diff --git a/core/src/apps/stellar/operations/__init__.py b/core/src/apps/stellar/operations/__init__.py index ac1a6c83a..d8438baa4 100644 --- a/core/src/apps/stellar/operations/__init__.py +++ b/core/src/apps/stellar/operations/__init__.py @@ -1,5 +1,5 @@ -from apps.stellar import consts, writers -from apps.stellar.operations import layout, serialize +from .. import consts, writers +from . import layout, serialize async def process_operation(ctx, w, op): diff --git a/core/src/apps/stellar/operations/layout.py b/core/src/apps/stellar/operations/layout.py index fae0828d6..f52837656 100644 --- a/core/src/apps/stellar/operations/layout.py +++ b/core/src/apps/stellar/operations/layout.py @@ -16,8 +16,8 @@ from trezor.messages.StellarSetOptionsOp import StellarSetOptionsOp from trezor.ui.text import Text from trezor.wire import ProcessError -from apps.stellar import consts, helpers -from apps.stellar.layout import format_amount, require_confirm, split, trim_to_rows, ui +from .. import consts, helpers +from ..layout import format_amount, require_confirm, split, trim_to_rows, ui async def confirm_source_account(ctx, source_account: bytes): diff --git a/core/src/apps/stellar/operations/serialize.py b/core/src/apps/stellar/operations/serialize.py index 2ab3e8e5d..05a846d8c 100644 --- a/core/src/apps/stellar/operations/serialize.py +++ b/core/src/apps/stellar/operations/serialize.py @@ -12,7 +12,7 @@ from trezor.messages.StellarPaymentOp import StellarPaymentOp from trezor.messages.StellarSetOptionsOp import StellarSetOptionsOp from trezor.wire import ProcessError -from apps.stellar import consts, writers +from .. import consts, writers def write_account_merge_op(w, msg: StellarAccountMergeOp): diff --git a/core/src/apps/stellar/sign_tx.py b/core/src/apps/stellar/sign_tx.py index 21f3fa63f..b4633d65e 100644 --- a/core/src/apps/stellar/sign_tx.py +++ b/core/src/apps/stellar/sign_tx.py @@ -9,8 +9,9 @@ from trezor.wire import ProcessError from apps.common import paths, seed from apps.common.keychain import with_slip44_keychain -from apps.stellar import CURVE, SLIP44_ID, consts, helpers, layout, writers -from apps.stellar.operations import process_operation + +from . import CURVE, SLIP44_ID, consts, helpers, layout, writers +from .operations import process_operation @with_slip44_keychain(SLIP44_ID, CURVE, allow_testnet=True) diff --git a/core/src/apps/tezos/get_address.py b/core/src/apps/tezos/get_address.py index 0a9e0caf6..c8682b0e5 100644 --- a/core/src/apps/tezos/get_address.py +++ b/core/src/apps/tezos/get_address.py @@ -4,7 +4,8 @@ from trezor.messages.TezosAddress import TezosAddress from apps.common import paths, seed from apps.common.keychain import with_slip44_keychain from apps.common.layout import address_n_to_str, show_address, show_qr -from apps.tezos import CURVE, SLIP44_ID, helpers + +from . import CURVE, SLIP44_ID, helpers @with_slip44_keychain(SLIP44_ID, CURVE, allow_testnet=True) diff --git a/core/src/apps/tezos/get_public_key.py b/core/src/apps/tezos/get_public_key.py index 1bfef7050..d2cffdf9b 100644 --- a/core/src/apps/tezos/get_public_key.py +++ b/core/src/apps/tezos/get_public_key.py @@ -7,7 +7,8 @@ from trezor.utils import chunks from apps.common import paths, seed from apps.common.confirm import require_confirm from apps.common.keychain import with_slip44_keychain -from apps.tezos import CURVE, SLIP44_ID, helpers + +from . import CURVE, SLIP44_ID, helpers @with_slip44_keychain(SLIP44_ID, CURVE, allow_testnet=True) diff --git a/core/src/apps/tezos/layout.py b/core/src/apps/tezos/layout.py index 1eb679bbe..460efa302 100644 --- a/core/src/apps/tezos/layout.py +++ b/core/src/apps/tezos/layout.py @@ -6,7 +6,8 @@ from trezor.ui.text import Text from trezor.utils import chunks from apps.common.confirm import require_confirm, require_hold_to_confirm -from apps.tezos.helpers import TEZOS_AMOUNT_DECIMALS + +from .helpers import TEZOS_AMOUNT_DECIMALS async def require_confirm_tx(ctx, to, value): diff --git a/core/src/apps/tezos/sign_tx.py b/core/src/apps/tezos/sign_tx.py index 0d60062bb..ae9422559 100644 --- a/core/src/apps/tezos/sign_tx.py +++ b/core/src/apps/tezos/sign_tx.py @@ -9,7 +9,8 @@ from trezor.messages.TezosSignedTx import TezosSignedTx from apps.common import paths from apps.common.keychain import with_slip44_keychain from apps.common.writers import write_bytes_unchecked, write_uint8, write_uint32_be -from apps.tezos import CURVE, SLIP44_ID, helpers, layout + +from . import CURVE, SLIP44_ID, helpers, layout PROPOSAL_LENGTH = const(32) diff --git a/core/src/apps/webauthn/__init__.py b/core/src/apps/webauthn/__init__.py index 733a83d76..5a5a916f9 100644 --- a/core/src/apps/webauthn/__init__.py +++ b/core/src/apps/webauthn/__init__.py @@ -1,7 +1,7 @@ from trezor import loop, wire from trezor.messages import MessageType -from apps.webauthn.fido2 import handle_reports +from .fido2 import handle_reports def boot() -> None: diff --git a/core/src/apps/webauthn/add_resident_credential.py b/core/src/apps/webauthn/add_resident_credential.py index acbc72360..c5d958c64 100644 --- a/core/src/apps/webauthn/add_resident_credential.py +++ b/core/src/apps/webauthn/add_resident_credential.py @@ -5,9 +5,10 @@ from trezor.messages.WebAuthnAddResidentCredential import WebAuthnAddResidentCre from trezor.ui.text import Text from apps.common.confirm import require_confirm -from apps.webauthn.confirm import ConfirmContent, ConfirmInfo -from apps.webauthn.credential import Fido2Credential -from apps.webauthn.resident_credentials import store_resident_credential + +from .confirm import ConfirmContent, ConfirmInfo +from .credential import Fido2Credential +from .resident_credentials import store_resident_credential if False: from typing import Optional diff --git a/core/src/apps/webauthn/confirm.py b/core/src/apps/webauthn/confirm.py index 536d200b1..f81cc026c 100644 --- a/core/src/apps/webauthn/confirm.py +++ b/core/src/apps/webauthn/confirm.py @@ -23,7 +23,7 @@ class ConfirmInfo: def load_icon(self, rp_id_hash: bytes) -> None: from trezor import res - from apps.webauthn import knownapps + from . import knownapps fido_app = knownapps.by_rp_id_hash(rp_id_hash) if fido_app is not None and fido_app.icon is not None: diff --git a/core/src/apps/webauthn/credential.py b/core/src/apps/webauthn/credential.py index 5834255ac..e8bf799c5 100644 --- a/core/src/apps/webauthn/credential.py +++ b/core/src/apps/webauthn/credential.py @@ -8,7 +8,8 @@ from trezor.crypto import bip32, chacha20poly1305, der, hashlib, hmac, random from trezor.crypto.curve import ed25519, nist256p1 from apps.common import HARDENED, cbor, seed -from apps.webauthn import common + +from . import common if False: from typing import Iterable, Optional @@ -258,7 +259,7 @@ class Fido2Credential(Credential): ) def app_name(self) -> str: - from apps.webauthn import knownapps + from . import knownapps app = knownapps.by_rp_id_hash(self.rp_id_hash) if app is not None: @@ -400,7 +401,7 @@ class U2fCredential(Credential): self.id = keypath + mac.digest() def app_name(self) -> str: - from apps.webauthn import knownapps + from . import knownapps app = knownapps.by_rp_id_hash(self.rp_id_hash) if app is not None: diff --git a/core/src/apps/webauthn/fido2.py b/core/src/apps/webauthn/fido2.py index 58b9f2017..014cfb604 100644 --- a/core/src/apps/webauthn/fido2.py +++ b/core/src/apps/webauthn/fido2.py @@ -14,18 +14,11 @@ from trezor.ui.text import Text from apps.base import set_homescreen from apps.common import cbor -from apps.webauthn import common -from apps.webauthn.confirm import ConfirmContent, ConfirmInfo -from apps.webauthn.credential import ( - CRED_ID_MAX_LENGTH, - Credential, - Fido2Credential, - U2fCredential, -) -from apps.webauthn.resident_credentials import ( - find_by_rp_id_hash, - store_resident_credential, -) + +from . import common +from .confirm import ConfirmContent, ConfirmInfo +from .credential import CRED_ID_MAX_LENGTH, Credential, Fido2Credential, U2fCredential +from .resident_credentials import find_by_rp_id_hash, store_resident_credential if False: from typing import ( @@ -1481,7 +1474,7 @@ def cbor_make_credential(req: Cmd, dialog_mgr: DialogManager) -> Optional[Cmd]: def cbor_make_credential_process( req: Cmd, dialog_mgr: DialogManager ) -> Union[State, Cmd]: - from apps.webauthn import knownapps + from . import knownapps if not storage.device.is_initialized(): if __debug__: @@ -1588,7 +1581,7 @@ def cbor_make_credential_process( def use_self_attestation(rp_id_hash: bytes) -> bool: - from apps.webauthn import knownapps + from . import knownapps app = knownapps.by_rp_id_hash(rp_id_hash) if app is not None and app.use_self_attestation is not None: diff --git a/core/src/apps/webauthn/list_resident_credentials.py b/core/src/apps/webauthn/list_resident_credentials.py index 3bf3cfac4..538b7b842 100644 --- a/core/src/apps/webauthn/list_resident_credentials.py +++ b/core/src/apps/webauthn/list_resident_credentials.py @@ -7,7 +7,8 @@ from trezor.messages.WebAuthnListResidentCredentials import ( from trezor.ui.text import Text from apps.common.confirm import require_confirm -from apps.webauthn import resident_credentials + +from . import resident_credentials async def list_resident_credentials( diff --git a/core/src/apps/webauthn/remove_resident_credential.py b/core/src/apps/webauthn/remove_resident_credential.py index 5d55e8f72..b18af0324 100644 --- a/core/src/apps/webauthn/remove_resident_credential.py +++ b/core/src/apps/webauthn/remove_resident_credential.py @@ -7,9 +7,10 @@ from trezor.messages.WebAuthnRemoveResidentCredential import ( ) from apps.common.confirm import require_confirm -from apps.webauthn.confirm import ConfirmContent, ConfirmInfo -from apps.webauthn.credential import Fido2Credential -from apps.webauthn.resident_credentials import get_resident_credential + +from .confirm import ConfirmContent, ConfirmInfo +from .credential import Fido2Credential +from .resident_credentials import get_resident_credential if False: from typing import Optional diff --git a/core/src/apps/webauthn/resident_credentials.py b/core/src/apps/webauthn/resident_credentials.py index 826990397..3f04804cb 100644 --- a/core/src/apps/webauthn/resident_credentials.py +++ b/core/src/apps/webauthn/resident_credentials.py @@ -3,7 +3,7 @@ from micropython import const import storage.resident_credentials from storage.resident_credentials import MAX_RESIDENT_CREDENTIALS -from apps.webauthn.credential import Fido2Credential +from .credential import Fido2Credential if False: from typing import Iterator, Optional