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
pull/1328/head
matejcik 4 years ago committed by matejcik
parent 7fe5c804ff
commit 4ca8f7b0d6

@ -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):

@ -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):

@ -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):

@ -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

@ -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

@ -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

@ -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)

@ -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
"""

@ -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

@ -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

@ -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):

@ -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):

@ -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

@ -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):

@ -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

@ -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)

@ -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):

@ -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)

@ -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):

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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)

@ -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)

@ -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)

@ -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)

@ -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)

@ -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(

@ -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):

@ -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):

@ -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):

@ -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)

@ -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)

@ -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)

@ -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):

@ -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)

@ -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:

@ -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

@ -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:

@ -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:

@ -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:

@ -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(

@ -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

@ -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

Loading…
Cancel
Save