mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-18 12:28:09 +00:00
chore(core): import trezor.messages in TYPE_CHECKING branch - saving 1kb
This commit is contained in:
parent
d1732ae9bc
commit
f25119e44d
@ -1,6 +1,6 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from trezor.messages import BinanceAddress, BinanceGetAddress
|
||||
from trezor.messages import BinanceAddress
|
||||
from trezor.ui.layouts import show_address
|
||||
|
||||
from apps.common import paths
|
||||
@ -9,6 +9,7 @@ from apps.common.keychain import Keychain, auto_keychain
|
||||
from .helpers import address_from_public_key
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import BinanceGetAddress
|
||||
from trezor.wire import Context
|
||||
|
||||
|
||||
|
@ -1,13 +1,14 @@
|
||||
from typing import TYPE_CHECKING
|
||||
from ubinascii import hexlify
|
||||
|
||||
from trezor.messages import BinanceGetPublicKey, BinancePublicKey
|
||||
from trezor.messages import BinancePublicKey
|
||||
from trezor.ui.layouts import show_pubkey
|
||||
|
||||
from apps.common import paths
|
||||
from apps.common.keychain import Keychain, auto_keychain
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import BinanceGetPublicKey
|
||||
from trezor.wire import Context
|
||||
|
||||
|
||||
|
@ -4,15 +4,10 @@ from typing import TYPE_CHECKING
|
||||
from trezor import wire
|
||||
from trezor.crypto import bech32
|
||||
from trezor.crypto.scripts import sha256_ripemd160
|
||||
from trezor.messages import (
|
||||
BinanceCancelMsg,
|
||||
BinanceInputOutput,
|
||||
BinanceOrderMsg,
|
||||
BinanceSignTx,
|
||||
BinanceTransferMsg,
|
||||
)
|
||||
from trezor.messages import BinanceCancelMsg, BinanceOrderMsg, BinanceTransferMsg
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import BinanceInputOutput, BinanceSignTx
|
||||
from trezor.protobuf import MessageType
|
||||
|
||||
ENVELOPE_BLUEPRINT = '{{"account_number":"{account_number}","chain_id":"{chain_id}","data":null,"memo":"{memo}","msgs":[{msgs}],"sequence":"{sequence}","source":"{source}"}}'
|
||||
|
@ -1,12 +1,6 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from trezor.enums import BinanceOrderSide, ButtonRequestType
|
||||
from trezor.messages import (
|
||||
BinanceCancelMsg,
|
||||
BinanceInputOutput,
|
||||
BinanceOrderMsg,
|
||||
BinanceTransferMsg,
|
||||
)
|
||||
from trezor.strings import format_amount
|
||||
from trezor.ui.layouts import confirm_properties
|
||||
from trezor.ui.layouts.altcoin import confirm_transfer_binance
|
||||
@ -14,6 +8,12 @@ from trezor.ui.layouts.altcoin import confirm_transfer_binance
|
||||
from . import helpers
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import (
|
||||
BinanceCancelMsg,
|
||||
BinanceInputOutput,
|
||||
BinanceOrderMsg,
|
||||
BinanceTransferMsg,
|
||||
)
|
||||
from trezor.wire import Context
|
||||
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from trezor import wire
|
||||
from trezor.crypto.curve import secp256k1
|
||||
from trezor.crypto.hashlib import sha256
|
||||
@ -6,7 +8,6 @@ from trezor.messages import (
|
||||
BinanceCancelMsg,
|
||||
BinanceOrderMsg,
|
||||
BinanceSignedTx,
|
||||
BinanceSignTx,
|
||||
BinanceTransferMsg,
|
||||
BinanceTxRequest,
|
||||
)
|
||||
@ -16,6 +17,9 @@ from apps.common.keychain import Keychain, auto_keychain
|
||||
|
||||
from . import helpers, layout
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import BinanceSignTx
|
||||
|
||||
|
||||
@auto_keychain(__name__)
|
||||
async def sign_tx(
|
||||
|
@ -5,7 +5,6 @@ from trezor.crypto import base58, cashaddr
|
||||
from trezor.crypto.curve import bip340
|
||||
from trezor.crypto.hashlib import sha256
|
||||
from trezor.enums import InputScriptType
|
||||
from trezor.messages import MultisigRedeemScriptType
|
||||
from trezor.utils import HashWriter
|
||||
|
||||
from apps.common import address_type
|
||||
@ -16,6 +15,7 @@ from .multisig import multisig_get_pubkeys, multisig_pubkey_index
|
||||
from .scripts import output_script_native_segwit, write_output_script_multisig
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import MultisigRedeemScriptType
|
||||
from trezor.crypto import bip32
|
||||
|
||||
|
||||
|
@ -1,22 +1,14 @@
|
||||
from micropython import const
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from trezor import wire
|
||||
from trezor.enums import ButtonRequestType
|
||||
from trezor.messages import AuthorizeCoinJoin, Success
|
||||
from trezor.ui.layouts import confirm_coinjoin, confirm_metadata
|
||||
|
||||
from apps.common import authorization, safety_checks
|
||||
from apps.common.keychain import FORBIDDEN_KEY_PATH
|
||||
from apps.common.paths import SLIP25_PURPOSE, validate_path
|
||||
|
||||
from .authorization import FEE_RATE_DECIMALS
|
||||
from .common import BIP32_WALLET_DEPTH, format_fee_rate
|
||||
from .keychain import validate_path_against_script_type, with_keychain
|
||||
from .keychain import with_keychain
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import AuthorizeCoinJoin, Success
|
||||
from apps.common.coininfo import CoinInfo
|
||||
from apps.common.keychain import Keychain
|
||||
from trezor import wire
|
||||
|
||||
_MAX_COORDINATOR_LEN = const(36)
|
||||
_MAX_ROUNDS = const(500)
|
||||
@ -27,6 +19,18 @@ _MAX_COORDINATOR_FEE_RATE = 5 * pow(10, FEE_RATE_DECIMALS) # 5 %
|
||||
async def authorize_coinjoin(
|
||||
ctx: wire.Context, msg: AuthorizeCoinJoin, keychain: Keychain, coin: CoinInfo
|
||||
) -> Success:
|
||||
from trezor import wire
|
||||
from trezor.enums import ButtonRequestType
|
||||
from trezor.messages import Success
|
||||
from trezor.ui.layouts import confirm_coinjoin, confirm_metadata
|
||||
|
||||
from apps.common import authorization, safety_checks
|
||||
from apps.common.keychain import FORBIDDEN_KEY_PATH
|
||||
from apps.common.paths import SLIP25_PURPOSE, validate_path
|
||||
|
||||
from .keychain import validate_path_against_script_type
|
||||
from .common import BIP32_WALLET_DEPTH, format_fee_rate
|
||||
|
||||
if len(msg.coordinator) > _MAX_COORDINATOR_LEN or not all(
|
||||
32 <= ord(x) <= 126 for x in msg.coordinator
|
||||
):
|
||||
|
@ -13,8 +13,7 @@ from .keychain import validate_path_against_script_type, with_keychain
|
||||
from .multisig import multisig_pubkey_index
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import GetAddress
|
||||
from trezor.messages import HDNodeType
|
||||
from trezor.messages import GetAddress, HDNodeType
|
||||
from trezor import wire
|
||||
from apps.common.keychain import Keychain
|
||||
from apps.common.coininfo import CoinInfo
|
||||
|
@ -2,7 +2,7 @@ from typing import TYPE_CHECKING
|
||||
|
||||
from trezor import wire
|
||||
from trezor.enums import InputScriptType
|
||||
from trezor.messages import GetOwnershipId, OwnershipId
|
||||
from trezor.messages import OwnershipId
|
||||
|
||||
from apps.common.paths import validate_path
|
||||
|
||||
@ -11,6 +11,7 @@ from .keychain import validate_path_against_script_type, with_keychain
|
||||
from .ownership import get_identifier
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import GetOwnershipId
|
||||
from apps.common.coininfo import CoinInfo
|
||||
from apps.common.keychain import Keychain
|
||||
|
||||
|
@ -2,7 +2,7 @@ from typing import TYPE_CHECKING
|
||||
|
||||
from trezor import ui, wire
|
||||
from trezor.enums import InputScriptType
|
||||
from trezor.messages import GetOwnershipProof, OwnershipProof
|
||||
from trezor.messages import OwnershipProof
|
||||
from trezor.ui.layouts import confirm_action, confirm_blob
|
||||
|
||||
from apps.common.paths import validate_path
|
||||
@ -12,6 +12,7 @@ from .keychain import validate_path_against_script_type, with_keychain
|
||||
from .ownership import generate_proof, get_identifier
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import GetOwnershipProof
|
||||
from apps.common.coininfo import CoinInfo
|
||||
from apps.common.keychain import Keychain
|
||||
from .authorization import CoinJoinAuthorization
|
||||
|
@ -1,13 +1,17 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from trezor import wire
|
||||
from trezor.crypto import bip32
|
||||
from trezor.crypto.hashlib import sha256
|
||||
from trezor.messages import HDNodeType, MultisigRedeemScriptType
|
||||
from trezor.utils import HashWriter
|
||||
|
||||
from apps.common import paths
|
||||
|
||||
from .writers import write_bytes_fixed, write_uint32
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import HDNodeType, MultisigRedeemScriptType
|
||||
|
||||
|
||||
def multisig_fingerprint(multisig: MultisigRedeemScriptType) -> bytes:
|
||||
if multisig.nodes:
|
||||
|
@ -21,11 +21,7 @@ from .tx_info import OriginalTxInfo, TxInfo
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.crypto import bip32
|
||||
|
||||
from trezor.messages import SignTx
|
||||
from trezor.messages import TxInput
|
||||
from trezor.messages import TxOutput
|
||||
from trezor.messages import TxAckPaymentRequest
|
||||
from trezor.messages import SignTx, TxInput, TxOutput, TxAckPaymentRequest
|
||||
|
||||
from apps.common.coininfo import CoinInfo
|
||||
from apps.common.keychain import Keychain
|
||||
|
@ -1,7 +1,6 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from trezor import wire
|
||||
from trezor.messages import PrevTx, SignTx, TxInput
|
||||
|
||||
from apps.common.writers import write_compact_size
|
||||
|
||||
@ -12,6 +11,7 @@ from .bitcoin import Bitcoin
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Sequence
|
||||
from trezor.messages import PrevTx, SignTx, TxInput
|
||||
from .tx_info import OriginalTxInfo, TxInfo
|
||||
|
||||
|
||||
|
@ -3,10 +3,6 @@ from typing import TYPE_CHECKING
|
||||
from trezor import utils, wire
|
||||
from trezor.enums import InputScriptType, OutputScriptType, RequestType
|
||||
from trezor.messages import (
|
||||
PrevInput,
|
||||
PrevOutput,
|
||||
PrevTx,
|
||||
SignTx,
|
||||
TxAckInput,
|
||||
TxAckOutput,
|
||||
TxAckPaymentRequest,
|
||||
@ -14,9 +10,6 @@ from trezor.messages import (
|
||||
TxAckPrevInput,
|
||||
TxAckPrevMeta,
|
||||
TxAckPrevOutput,
|
||||
TxInput,
|
||||
TxOutput,
|
||||
TxRequest,
|
||||
)
|
||||
|
||||
from apps.common import paths
|
||||
@ -30,6 +23,15 @@ if TYPE_CHECKING:
|
||||
from typing import Any, Awaitable
|
||||
from trezor.enums import AmountUnit
|
||||
|
||||
from trezor.messages import (
|
||||
PrevInput,
|
||||
PrevOutput,
|
||||
PrevTx,
|
||||
SignTx,
|
||||
TxInput,
|
||||
TxOutput,
|
||||
TxRequest,
|
||||
)
|
||||
|
||||
# Machine instructions
|
||||
# ===
|
||||
|
@ -1,7 +1,6 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from trezor.crypto.hashlib import sha256
|
||||
from trezor.messages import PrevTx, SignTx, TxInput, TxOutput
|
||||
from trezor.utils import HashWriter
|
||||
|
||||
from apps.common import coininfo
|
||||
@ -12,6 +11,7 @@ from ..common import tagged_hashwriter
|
||||
if TYPE_CHECKING:
|
||||
from typing import Protocol, Sequence
|
||||
from ..common import SigHashType
|
||||
from trezor.messages import PrevTx, SignTx, TxInput, TxOutput
|
||||
|
||||
class SigHasher(Protocol):
|
||||
def add_input(self, txi: TxInput, script_pubkey: bytes) -> None:
|
||||
|
@ -4,7 +4,6 @@ from typing import TYPE_CHECKING
|
||||
|
||||
from trezor import wire
|
||||
from trezor.crypto.hashlib import blake2b
|
||||
from trezor.messages import PrevTx, SignTx, TxInput, TxOutput
|
||||
from trezor.utils import HashWriter, ensure
|
||||
|
||||
from apps.common.coininfo import CoinInfo
|
||||
@ -25,6 +24,7 @@ from . import approvers, helpers
|
||||
from .bitcoinlike import Bitcoinlike
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import PrevTx, SignTx, TxInput, TxOutput
|
||||
from typing import Sequence
|
||||
from apps.common import coininfo
|
||||
from .sig_hasher import SigHasher
|
||||
|
@ -1,13 +1,18 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import storage
|
||||
import storage.device
|
||||
from trezor import config, wire
|
||||
from trezor.crypto import bip39, slip39
|
||||
from trezor.enums import BackupType
|
||||
from trezor.messages import LoadDevice, Success
|
||||
from trezor.messages import Success
|
||||
from trezor.ui.layouts import confirm_action
|
||||
|
||||
from apps.management import backup_types
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import LoadDevice
|
||||
|
||||
|
||||
async def load_device(ctx: wire.Context, msg: LoadDevice) -> Success:
|
||||
word_count = _validate(msg)
|
||||
|
@ -2,7 +2,7 @@ from typing import TYPE_CHECKING
|
||||
|
||||
from trezor import wire
|
||||
from trezor.crypto.curve import secp256k1
|
||||
from trezor.messages import EosGetPublicKey, EosPublicKey
|
||||
from trezor.messages import EosPublicKey
|
||||
|
||||
from apps.common import paths
|
||||
from apps.common.keychain import Keychain, auto_keychain
|
||||
@ -11,6 +11,7 @@ from .helpers import public_key_to_wif
|
||||
from .layout import require_get_public_key
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import EosGetPublicKey
|
||||
from trezor.crypto import bip32
|
||||
|
||||
|
||||
|
@ -1,5 +1,9 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from trezor import wire
|
||||
from trezor.crypto import base58
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import EosAsset
|
||||
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from trezor import wire
|
||||
from trezor.crypto.curve import secp256k1
|
||||
from trezor.crypto.hashlib import sha256
|
||||
from trezor.messages import EosSignedTx, EosSignTx, EosTxActionAck, EosTxActionRequest
|
||||
from trezor.messages import EosSignedTx, EosTxActionAck, EosTxActionRequest
|
||||
from trezor.utils import HashWriter
|
||||
|
||||
from apps.common import paths
|
||||
@ -12,6 +14,9 @@ from .actions import process_action
|
||||
from .helpers import base58_encode
|
||||
from .layout import require_sign_tx
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import EosSignTx
|
||||
|
||||
|
||||
@auto_keychain(__name__)
|
||||
async def sign_tx(ctx: wire.Context, msg: EosSignTx, keychain: Keychain) -> EosSignedTx:
|
||||
|
@ -3,9 +3,9 @@ from ubinascii import hexlify, unhexlify
|
||||
|
||||
from trezor import wire
|
||||
from trezor.enums import EthereumDataType
|
||||
from trezor.messages import EthereumFieldType
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import EthereumFieldType
|
||||
from .networks import NetworkInfo
|
||||
|
||||
|
||||
|
@ -3,7 +3,6 @@ from ubinascii import hexlify
|
||||
|
||||
from trezor import ui
|
||||
from trezor.enums import ButtonRequestType, EthereumDataType
|
||||
from trezor.messages import EthereumFieldType, EthereumStructMember
|
||||
from trezor.strings import format_amount, format_plural
|
||||
from trezor.ui.layouts import (
|
||||
confirm_action,
|
||||
@ -23,6 +22,7 @@ from .helpers import address_from_bytes, decode_typed_data, get_type_name
|
||||
if TYPE_CHECKING:
|
||||
from typing import Awaitable, Iterable
|
||||
|
||||
from trezor.messages import EthereumFieldType, EthereumStructMember
|
||||
from trezor.wire import Context
|
||||
|
||||
|
||||
|
@ -4,7 +4,7 @@ from trezor import wire
|
||||
from trezor.crypto import rlp
|
||||
from trezor.crypto.curve import secp256k1
|
||||
from trezor.crypto.hashlib import sha3_256
|
||||
from trezor.messages import EthereumSignTx, EthereumTxAck, EthereumTxRequest
|
||||
from trezor.messages import EthereumTxAck, EthereumTxRequest
|
||||
from trezor.utils import HashWriter
|
||||
|
||||
from apps.common import paths
|
||||
@ -21,6 +21,7 @@ from .layout import (
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from apps.common.keychain import Keychain
|
||||
from trezor.messages import EthereumSignTx
|
||||
|
||||
from .keychain import EthereumSignTxAny
|
||||
|
||||
|
@ -7,7 +7,6 @@ from trezor.crypto.hashlib import sha3_256
|
||||
from trezor.enums import EthereumDataType
|
||||
from trezor.messages import (
|
||||
EthereumFieldType,
|
||||
EthereumSignTypedData,
|
||||
EthereumTypedDataSignature,
|
||||
EthereumTypedDataStructAck,
|
||||
EthereumTypedDataStructRequest,
|
||||
@ -33,6 +32,8 @@ if TYPE_CHECKING:
|
||||
from apps.common.keychain import Keychain
|
||||
from trezor.wire import Context
|
||||
|
||||
from trezor.messages import EthereumSignTypedData
|
||||
|
||||
|
||||
# Maximum data size we support
|
||||
_MAX_VALUE_BYTE_SIZE = const(1024)
|
||||
|
@ -1,9 +1,14 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import storage.device
|
||||
from trezor import ui, wire
|
||||
from trezor.enums import ButtonRequestType
|
||||
from trezor.messages import GetNextU2FCounter, NextU2FCounter
|
||||
from trezor.messages import NextU2FCounter
|
||||
from trezor.ui.layouts import confirm_action
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import GetNextU2FCounter
|
||||
|
||||
|
||||
async def get_next_u2f_counter(
|
||||
ctx: wire.Context, msg: GetNextU2FCounter
|
||||
|
@ -1,7 +1,12 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from storage import cache
|
||||
from trezor import wire
|
||||
from trezor.crypto import random
|
||||
from trezor.messages import GetNonce, Nonce
|
||||
from trezor.messages import Nonce
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import GetNonce
|
||||
|
||||
|
||||
async def get_nonce(ctx: wire.Context, msg: GetNonce) -> Nonce:
|
||||
|
@ -2,14 +2,13 @@ from typing import TYPE_CHECKING
|
||||
|
||||
import storage.device
|
||||
from trezor import io, loop, utils, wire
|
||||
from trezor.messages import RebootToBootloader, Success
|
||||
from trezor.messages import Success
|
||||
from trezor.ui.layouts import confirm_action
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import RebootToBootloader
|
||||
from typing import NoReturn
|
||||
|
||||
pass
|
||||
|
||||
|
||||
async def reboot_to_bootloader(ctx: wire.Context, msg: RebootToBootloader) -> NoReturn:
|
||||
if not storage.device.get_experimental_features():
|
||||
|
@ -1,9 +1,14 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import storage.device
|
||||
from trezor import ui, wire
|
||||
from trezor.enums import ButtonRequestType
|
||||
from trezor.messages import SetU2FCounter, Success
|
||||
from trezor.messages import Success
|
||||
from trezor.ui.layouts import confirm_action
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import SetU2FCounter
|
||||
|
||||
|
||||
async def set_u2f_counter(ctx: wire.Context, msg: SetU2FCounter) -> Success:
|
||||
if not storage.device.is_initialized():
|
||||
|
@ -1,11 +1,12 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from trezor import ui, wire, workflow
|
||||
from trezor.messages import FirmwareHash, GetFirmwareHash
|
||||
from trezor.messages import FirmwareHash
|
||||
from trezor.ui.layouts import draw_simple_text
|
||||
from trezor.utils import DISABLE_ANIMATION, firmware_hash
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import GetFirmwareHash
|
||||
from trezor.wire import Context
|
||||
|
||||
|
||||
|
@ -18,7 +18,7 @@ from micropython import const
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from trezor import utils, wire
|
||||
from trezor.messages import MoneroGetTxKeyAck, MoneroGetTxKeyRequest
|
||||
from trezor.messages import MoneroGetTxKeyAck
|
||||
|
||||
from apps.common import paths
|
||||
from apps.common.keychain import auto_keychain
|
||||
@ -28,6 +28,7 @@ from apps.monero.xmr import chacha_poly, crypto, crypto_helpers
|
||||
_GET_TX_KEY_REASON_TX_DERIVATION = const(1)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import MoneroGetTxKeyRequest
|
||||
from apps.common.keychain import Keychain
|
||||
|
||||
|
||||
|
@ -1,14 +1,13 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from . import layout, serialize
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import (
|
||||
NEMMosaicCreation,
|
||||
NEMMosaicSupplyChange,
|
||||
NEMTransactionCommon,
|
||||
)
|
||||
|
||||
from . import layout, serialize
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.wire import Context
|
||||
|
||||
|
||||
|
@ -2,12 +2,6 @@ from typing import TYPE_CHECKING
|
||||
|
||||
from trezor import ui
|
||||
from trezor.enums import NEMMosaicLevy, NEMSupplyChangeType
|
||||
from trezor.messages import (
|
||||
NEMMosaicCreation,
|
||||
NEMMosaicDefinition,
|
||||
NEMMosaicSupplyChange,
|
||||
NEMTransactionCommon,
|
||||
)
|
||||
from trezor.ui.layouts import confirm_properties
|
||||
|
||||
from ..layout import (
|
||||
@ -18,6 +12,12 @@ from ..layout import (
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import (
|
||||
NEMMosaicCreation,
|
||||
NEMMosaicDefinition,
|
||||
NEMMosaicSupplyChange,
|
||||
NEMTransactionCommon,
|
||||
)
|
||||
from trezor.wire import Context
|
||||
|
||||
|
||||
|
@ -1,11 +1,5 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from trezor.messages import (
|
||||
NEMMosaicCreation,
|
||||
NEMMosaicSupplyChange,
|
||||
NEMTransactionCommon,
|
||||
)
|
||||
|
||||
from ..helpers import (
|
||||
NEM_TRANSACTION_TYPE_MOSAIC_CREATION,
|
||||
NEM_TRANSACTION_TYPE_MOSAIC_SUPPLY_CHANGE,
|
||||
@ -18,6 +12,11 @@ from ..writers import (
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import (
|
||||
NEMMosaicCreation,
|
||||
NEMMosaicSupplyChange,
|
||||
NEMTransactionCommon,
|
||||
)
|
||||
from trezor.utils import Writer
|
||||
|
||||
|
||||
|
@ -1,10 +1,13 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from trezor.messages import NEMAggregateModification, NEMSignTx, NEMTransactionCommon
|
||||
|
||||
from . import layout, serialize
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import (
|
||||
NEMAggregateModification,
|
||||
NEMSignTx,
|
||||
NEMTransactionCommon,
|
||||
)
|
||||
from trezor.wire import Context
|
||||
|
||||
|
||||
|
@ -3,12 +3,16 @@ from typing import TYPE_CHECKING
|
||||
from trezor import ui
|
||||
from trezor.crypto import nem
|
||||
from trezor.enums import ButtonRequestType, NEMModificationType
|
||||
from trezor.messages import NEMAggregateModification, NEMSignTx, NEMTransactionCommon
|
||||
from trezor.ui.layouts import confirm_address
|
||||
|
||||
from ..layout import require_confirm_fee, require_confirm_final, require_confirm_text
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import (
|
||||
NEMAggregateModification,
|
||||
NEMSignTx,
|
||||
NEMTransactionCommon,
|
||||
)
|
||||
from trezor.wire import Context
|
||||
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from trezor.crypto import hashlib, nem
|
||||
from trezor.messages import NEMAggregateModification, NEMTransactionCommon
|
||||
|
||||
from ..helpers import (
|
||||
NEM_TRANSACTION_TYPE_AGGREGATE_MODIFICATION,
|
||||
@ -11,6 +10,7 @@ from ..helpers import (
|
||||
from ..writers import serialize_tx_common, write_bytes_with_len, write_uint32_le
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import NEMAggregateModification, NEMTransactionCommon
|
||||
from trezor.utils import Writer
|
||||
|
||||
|
||||
|
@ -1,10 +1,9 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from trezor.messages import NEMProvisionNamespace, NEMTransactionCommon
|
||||
|
||||
from . import layout, serialize
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import NEMProvisionNamespace, NEMTransactionCommon
|
||||
from trezor.wire import Context
|
||||
|
||||
|
||||
|
@ -1,10 +1,9 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from trezor.messages import NEMProvisionNamespace, NEMTransactionCommon
|
||||
|
||||
from ..layout import require_confirm_content, require_confirm_fee, require_confirm_final
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import NEMProvisionNamespace, NEMTransactionCommon
|
||||
from trezor.wire import Context
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
from trezor.messages import NEMProvisionNamespace, NEMTransactionCommon
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ..helpers import NEM_TRANSACTION_TYPE_PROVISION_NAMESPACE
|
||||
from ..writers import (
|
||||
@ -8,6 +8,9 @@ from ..writers import (
|
||||
write_uint64_le,
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import NEMProvisionNamespace, NEMTransactionCommon
|
||||
|
||||
|
||||
def serialize_provision_namespace(
|
||||
common: NEMTransactionCommon, namespace: NEMProvisionNamespace, public_key: bytes
|
||||
|
@ -2,7 +2,7 @@ from typing import TYPE_CHECKING
|
||||
|
||||
from trezor import wire
|
||||
from trezor.crypto.curve import ed25519
|
||||
from trezor.messages import NEMSignedTx, NEMSignTx
|
||||
from trezor.messages import NEMSignedTx
|
||||
|
||||
from apps.common import seed
|
||||
from apps.common.keychain import with_slip44_keychain
|
||||
@ -13,6 +13,7 @@ from .helpers import NEM_HASH_ALG, check_path
|
||||
from .validators import validate
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import NEMSignTx
|
||||
from apps.common.keychain import Keychain
|
||||
|
||||
|
||||
|
@ -1,10 +1,9 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from trezor.messages import NEMImportanceTransfer, NEMTransactionCommon, NEMTransfer
|
||||
|
||||
from . import layout, serialize
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import NEMImportanceTransfer, NEMTransactionCommon, NEMTransfer
|
||||
from trezor.wire import Context
|
||||
from trezor.crypto import bip32
|
||||
|
||||
|
@ -2,12 +2,6 @@ from typing import TYPE_CHECKING
|
||||
|
||||
from trezor import ui
|
||||
from trezor.enums import ButtonRequestType, NEMImportanceTransferMode, NEMMosaicLevy
|
||||
from trezor.messages import (
|
||||
NEMImportanceTransfer,
|
||||
NEMMosaic,
|
||||
NEMTransactionCommon,
|
||||
NEMTransfer,
|
||||
)
|
||||
from trezor.strings import format_amount
|
||||
from trezor.ui.layouts import (
|
||||
confirm_action,
|
||||
@ -25,6 +19,12 @@ from ..layout import require_confirm_final, require_confirm_text
|
||||
from ..mosaic.helpers import get_mosaic_definition, is_nem_xem_mosaic
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import (
|
||||
NEMImportanceTransfer,
|
||||
NEMMosaic,
|
||||
NEMTransactionCommon,
|
||||
NEMTransfer,
|
||||
)
|
||||
from trezor.wire import Context
|
||||
from ..mosaic.nem_mosaics import MosaicLevy
|
||||
|
||||
|
@ -1,15 +1,7 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from trezor.crypto import nem
|
||||
from trezor.enums import NEMModificationType
|
||||
from trezor.messages import (
|
||||
NEMAggregateModification,
|
||||
NEMImportanceTransfer,
|
||||
NEMMosaicCreation,
|
||||
NEMMosaicSupplyChange,
|
||||
NEMProvisionNamespace,
|
||||
NEMSignTx,
|
||||
NEMTransactionCommon,
|
||||
NEMTransfer,
|
||||
)
|
||||
from trezor.wire import ProcessError
|
||||
|
||||
from .helpers import (
|
||||
@ -23,6 +15,18 @@ from .helpers import (
|
||||
NEM_PUBLIC_KEY_SIZE,
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import (
|
||||
NEMAggregateModification,
|
||||
NEMImportanceTransfer,
|
||||
NEMMosaicCreation,
|
||||
NEMMosaicSupplyChange,
|
||||
NEMProvisionNamespace,
|
||||
NEMSignTx,
|
||||
NEMTransactionCommon,
|
||||
NEMTransfer,
|
||||
)
|
||||
|
||||
|
||||
def validate(msg: NEMSignTx) -> None:
|
||||
_validate_single_tx(msg)
|
||||
|
@ -1,10 +1,9 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from trezor.messages import NEMTransactionCommon
|
||||
|
||||
from apps.common.writers import write_bytes_unchecked, write_uint32_le, write_uint64_le
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import NEMTransactionCommon
|
||||
from trezor.utils import Writer
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from trezor.messages import RippleAddress, RippleGetAddress
|
||||
from trezor.messages import RippleAddress
|
||||
from trezor.ui.layouts import show_address
|
||||
|
||||
from apps.common import paths
|
||||
@ -9,6 +9,7 @@ from apps.common.keychain import auto_keychain
|
||||
from .helpers import address_from_public_key
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import RippleGetAddress
|
||||
from apps.common.keychain import Keychain
|
||||
from trezor.wire import Context
|
||||
|
||||
|
@ -11,11 +11,10 @@
|
||||
from micropython import const
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from trezor.messages import RippleSignTx
|
||||
|
||||
from . import helpers
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import RippleSignTx
|
||||
from trezor.utils import Writer
|
||||
|
||||
|
||||
|
@ -3,7 +3,7 @@ from typing import TYPE_CHECKING
|
||||
from trezor.crypto import der
|
||||
from trezor.crypto.curve import secp256k1
|
||||
from trezor.crypto.hashlib import sha512
|
||||
from trezor.messages import RippleSignedTx, RippleSignTx
|
||||
from trezor.messages import RippleSignedTx
|
||||
from trezor.wire import ProcessError
|
||||
|
||||
from apps.common import paths
|
||||
@ -13,6 +13,7 @@ from . import helpers, layout
|
||||
from .serialize import serialize
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import RippleSignTx
|
||||
from apps.common.keychain import Keychain
|
||||
from trezor.wire import Context
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from trezor.crypto import hashlib
|
||||
from trezor.messages import TezosAddress, TezosGetAddress
|
||||
from trezor.messages import TezosAddress
|
||||
from trezor.ui.layouts import show_address
|
||||
|
||||
from apps.common import paths, seed
|
||||
@ -10,6 +10,7 @@ from apps.common.keychain import with_slip44_keychain
|
||||
from . import CURVE, PATTERNS, SLIP44_ID, helpers
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import TezosGetAddress
|
||||
from apps.common.keychain import Keychain
|
||||
from trezor.wire import Context
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from trezor.messages import TezosGetPublicKey, TezosPublicKey
|
||||
from trezor.messages import TezosPublicKey
|
||||
from trezor.ui.layouts import show_pubkey
|
||||
|
||||
from apps.common import paths, seed
|
||||
@ -9,6 +9,7 @@ from apps.common.keychain import with_slip44_keychain
|
||||
from . import CURVE, PATTERNS, SLIP44_ID, helpers
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import TezosGetPublicKey
|
||||
from apps.common.keychain import Keychain
|
||||
from trezor.wire import Context
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import storage.device
|
||||
from trezor import wire
|
||||
from trezor.messages import Success, WebAuthnAddResidentCredential
|
||||
from trezor.messages import Success
|
||||
from trezor.ui.components.common.webauthn import ConfirmInfo
|
||||
from trezor.ui.layouts import show_error_and_raise
|
||||
from trezor.ui.layouts.webauthn import confirm_webauthn
|
||||
@ -8,6 +10,9 @@ from trezor.ui.layouts.webauthn import confirm_webauthn
|
||||
from .credential import Fido2Credential
|
||||
from .resident_credentials import store_resident_credential
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import WebAuthnAddResidentCredential
|
||||
|
||||
|
||||
class ConfirmAddCredential(ConfirmInfo):
|
||||
def __init__(self, cred: Fido2Credential):
|
||||
|
@ -1,13 +1,14 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from trezor import wire
|
||||
from trezor.messages import (
|
||||
WebAuthnCredential,
|
||||
WebAuthnCredentials,
|
||||
WebAuthnListResidentCredentials,
|
||||
)
|
||||
from trezor.messages import WebAuthnCredential, WebAuthnCredentials
|
||||
from trezor.ui.layouts import confirm_action
|
||||
|
||||
from . import resident_credentials
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import WebAuthnListResidentCredentials
|
||||
|
||||
|
||||
async def list_resident_credentials(
|
||||
ctx: wire.Context, msg: WebAuthnListResidentCredentials
|
||||
|
@ -1,13 +1,18 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import storage.device
|
||||
import storage.resident_credentials
|
||||
from trezor import wire
|
||||
from trezor.messages import Success, WebAuthnRemoveResidentCredential
|
||||
from trezor.messages import Success
|
||||
from trezor.ui.components.common.webauthn import ConfirmInfo
|
||||
from trezor.ui.layouts.webauthn import confirm_webauthn
|
||||
|
||||
from .credential import Fido2Credential
|
||||
from .resident_credentials import get_resident_credential
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import WebAuthnRemoveResidentCredential
|
||||
|
||||
|
||||
class ConfirmRemoveCredential(ConfirmInfo):
|
||||
def __init__(self, cred: Fido2Credential):
|
||||
|
@ -3,9 +3,7 @@ from common import *
|
||||
from trezor.crypto import hashlib
|
||||
|
||||
if not utils.BITCOIN_ONLY:
|
||||
from trezor.messages import NEMSignTx
|
||||
from trezor.messages import NEMMosaicCreation
|
||||
from trezor.messages import NEMMosaicDefinition
|
||||
from trezor.messages import NEMSignTx, NEMMosaicCreation, NEMMosaicDefinition, NEMTransactionCommon
|
||||
from apps.nem.helpers import *
|
||||
from apps.nem.mosaic import *
|
||||
from apps.nem.mosaic.serialize import *
|
||||
|
@ -6,9 +6,7 @@ if not utils.BITCOIN_ONLY:
|
||||
from apps.nem.helpers import *
|
||||
from apps.nem.mosaic import *
|
||||
from apps.nem.mosaic.serialize import *
|
||||
from trezor.messages import NEMSignTx
|
||||
from trezor.messages import NEMMosaicSupplyChange
|
||||
|
||||
from trezor.messages import NEMSignTx, NEMMosaicSupplyChange, NEMTransactionCommon
|
||||
|
||||
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
|
||||
class TestNemMosaicSupplyChange(unittest.TestCase):
|
||||
|
@ -6,11 +6,7 @@ if not utils.BITCOIN_ONLY:
|
||||
from apps.nem.multisig.serialize import *
|
||||
from apps.nem.namespace import *
|
||||
from apps.nem.namespace.serialize import *
|
||||
from trezor.messages import NEMSignTx
|
||||
from trezor.messages import NEMAggregateModification
|
||||
from trezor.messages import NEMProvisionNamespace
|
||||
from trezor.messages import NEMCosignatoryModification
|
||||
|
||||
from trezor.messages import NEMSignTx, NEMAggregateModification, NEMProvisionNamespace, NEMCosignatoryModification, NEMTransactionCommon
|
||||
|
||||
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
|
||||
class TestNemMultisig(unittest.TestCase):
|
||||
|
@ -6,7 +6,7 @@ if not utils.BITCOIN_ONLY:
|
||||
from apps.nem.helpers import *
|
||||
from apps.nem.namespace import *
|
||||
from apps.nem.namespace.serialize import *
|
||||
from trezor.messages import NEMProvisionNamespace
|
||||
from trezor.messages import NEMProvisionNamespace, NEMTransactionCommon
|
||||
from trezor.messages import NEMSignTx
|
||||
|
||||
|
||||
|
@ -3,24 +3,12 @@ from common import *
|
||||
if not utils.BITCOIN_ONLY:
|
||||
from trezor.messages import RipplePayment
|
||||
from trezor.messages import RippleSignTx
|
||||
from apps.ripple.serialize import serialize, serialize_amount
|
||||
from apps.ripple.sign_tx import get_network_prefix
|
||||
from apps.ripple.serialize import serialize
|
||||
from apps.ripple import helpers
|
||||
|
||||
|
||||
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
|
||||
class TestRippleSerializer(unittest.TestCase):
|
||||
def test_amount(self):
|
||||
# https://github.com/ripple/ripple-binary-codec/blob/4581f1b41e712f545ba08be15e188a557c731ecf/test/fixtures/data-driven-tests.json#L2494
|
||||
self.assertEqual(serialize_amount(0), unhexlify("4000000000000000"))
|
||||
self.assertEqual(serialize_amount(1), unhexlify("4000000000000001"))
|
||||
self.assertEqual(serialize_amount(93493429243), unhexlify("40000015c4a483fb"))
|
||||
with self.assertRaises(ValueError):
|
||||
serialize_amount(1000000000000000000) # too large
|
||||
with self.assertRaises(ValueError):
|
||||
serialize_amount(-1) # negative not supported
|
||||
with self.assertRaises(Exception):
|
||||
serialize_amount(1.1) # float numbers not supported
|
||||
|
||||
def test_transactions(self):
|
||||
# from https://github.com/miracle2k/ripple-python
|
||||
source_address = "r3P9vH81KBayazSTrQj6S25jW6kDb779Gi"
|
||||
@ -146,7 +134,8 @@ class TestRippleSerializer(unittest.TestCase):
|
||||
"ed5f5ac8b98974a3ca843326d9b88cebd0560177b973ee0b149f782cfaa06dc66a"
|
||||
),
|
||||
)
|
||||
tx = get_network_prefix() + tx
|
||||
network_prefix = helpers.HASH_TX_SIGN.to_bytes(4, "big")
|
||||
tx = network_prefix + tx
|
||||
|
||||
self.assertEqual(tx[0:4], unhexlify("53545800")) # signing prefix
|
||||
self.assertEqual(tx[4:7], unhexlify("120000")) # transaction type
|
||||
|
Loading…
Reference in New Issue
Block a user