diff --git a/common/protob/pb2py b/common/protob/pb2py index 904890db7c..24566c4544 100755 --- a/common/protob/pb2py +++ b/common/protob/pb2py @@ -10,13 +10,12 @@ import shutil import subprocess import sys import tempfile -from collections import namedtuple +from collections import namedtuple, defaultdict + +import attr from google.protobuf import descriptor_pb2 -ProtoField = namedtuple( - "ProtoField", "name, number, proto_type, py_type, repeated, required, orig" -) AUTO_HEADER = "# Automatically generated by pb2py\n" @@ -24,7 +23,7 @@ AUTO_HEADER = "# Automatically generated by pb2py\n" FIELD_TYPES = { descriptor_pb2.FieldDescriptorProto.TYPE_UINT64: ('p.UVarintType', 'int'), descriptor_pb2.FieldDescriptorProto.TYPE_UINT32: ('p.UVarintType', 'int'), - descriptor_pb2.FieldDescriptorProto.TYPE_ENUM: ('p.UVarintType', 'int'), +# descriptor_pb2.FieldDescriptorProto.TYPE_ENUM: ('p.UVarintType', 'int'), descriptor_pb2.FieldDescriptorProto.TYPE_SINT32: ('p.SVarintType', 'int'), descriptor_pb2.FieldDescriptorProto.TYPE_SINT64: ('p.SVarintType', 'int'), descriptor_pb2.FieldDescriptorProto.TYPE_STRING: ('p.UnicodeType', 'str'), @@ -42,6 +41,53 @@ PROTOC_PREFIX = os.path.dirname(os.path.dirname(PROTOC)) PROTOC_INCLUDE = os.path.join(PROTOC_PREFIX, "include") +@attr.s +class ProtoField: + name = attr.ib() + number = attr.ib() + orig = attr.ib() + repeated = attr.ib() + required = attr.ib() + type_name = attr.ib() + proto_type = attr.ib() + py_type = attr.ib() + + @classmethod + def from_field(cls, descriptor, field): + repeated = field.label == field.LABEL_REPEATED + required = field.label == field.LABEL_REQUIRED + # ignore package path + type_name = field.type_name.rsplit(".")[-1] + + if field.type == field.TYPE_MESSAGE: + proto_type = py_type = type_name + elif field.type == field.TYPE_ENUM: + valuestr = ", ".join(str(v) for v in descriptor.enum_types[type_name]) + proto_type = 'p.EnumType("{}", ({}))'.format(type_name, valuestr) + py_type = "EnumType" + type_name + else: + try: + proto_type, py_type = FIELD_TYPES[field.type] + except KeyError: + raise ValueError( + "Unknown field type {} for field {}".format(field.type, field.name) + ) from None + + if repeated: + py_type = "List[{}]".format(py_type) + + return cls( + name=field.name, + number=field.number, + orig=field, + repeated=repeated, + required=required, + type_name=type_name, + proto_type=proto_type, + py_type=py_type, + ) + + def protoc(files, additional_includes=()): """Compile code with protoc and return the data.""" include_dirs = set() @@ -113,6 +159,7 @@ class Descriptor: # find messages and enums self.messages = [] self.enums = [] + self.enum_types = defaultdict(set) for file in self.files: self.messages += file.message_type self.enums += file.enum_type @@ -136,9 +183,7 @@ class Descriptor: def find_message_types(self, message_type): message_types = {} try: - message_type_enum = next( - enum for enum in self.enums if enum.name == message_type - ) + message_type_enum = next(e for e in self.enums if e.name == message_type) for value in message_type_enum.value: name = strip_leader(value.name, message_type) message_types[name] = value.number @@ -151,38 +196,10 @@ class Descriptor: return message_types - def parse_field(self, field): - repeated = field.label == field.LABEL_REPEATED - required = field.label == field.LABEL_REQUIRED - if field.type == field.TYPE_MESSAGE: - # ignore package path - type_name = field.type_name.rsplit(".")[-1] - proto_type = py_type = type_name - else: - try: - proto_type, py_type = FIELD_TYPES[field.type] - except KeyError: - raise ValueError( - "Unknown field type {} for field {}".format(field.type, field.name) - ) from None - - if repeated: - py_type = "List[{}]".format(py_type) - - return ProtoField( - name=field.name, - number=field.number, - proto_type=proto_type, - py_type=py_type, - repeated=repeated, - required=required, - orig=field, - ) - def create_message_import(self, name): return "from .{0} import {0}".format(name) - def process_message_imports(self, fields): + def process_subtype_imports(self, fields): imports = set( field.proto_type for field in fields @@ -251,16 +268,26 @@ class Descriptor: # "from .. import protobuf as p" yield self.protobuf_import + " as p" - fields = [self.parse_field(field) for field in message.field] + fields = [ProtoField.from_field(self, field) for field in message.field] - yield from self.process_message_imports(fields) + yield from self.process_subtype_imports(fields) yield "" yield "if __debug__:" yield " try:" yield " from typing import Dict, List, Optional" + yield " from typing_extensions import Literal # noqa: F401" + + all_enums = [field for field in fields if field.type_name in self.enum_types] + for field in all_enums: + allowed_values = self.enum_types[field.type_name] + valuestr = ", ".join(str(v) for v in sorted(allowed_values)) + yield " {} = Literal[{}]".format(field.py_type, valuestr) + yield " except ImportError:" yield " Dict, List, Optional = None, None, None # type: ignore" + for field in all_enums: + yield " {} = None # type: ignore".format(field.py_type) yield "" yield "" @@ -294,6 +321,7 @@ class Descriptor: enum_prefix, _ = enum_prefix.rsplit("Type", 1) name = strip_leader(name, enum_prefix) + self.enum_types[enum.name].add(value.number) yield "{} = {}".format(name, value.number) def process_messages(self, messages): @@ -325,8 +353,8 @@ class Descriptor: def write_classes(self, out_dir, init_py=True): self.out_dir = out_dir - self.process_messages(self.messages) self.process_enums(self.enums) + self.process_messages(self.messages) if init_py: self.write_init_py() diff --git a/core/src/protobuf.py b/core/src/protobuf.py index 17fa08a8eb..0bb1a37901 100644 --- a/core/src/protobuf.py +++ b/core/src/protobuf.py @@ -121,6 +121,19 @@ class BoolType: WIRE_TYPE = 0 +class EnumType: + WIRE_TYPE = 0 + + def __init__(self, _, enum_values): + self.enum_values = enum_values + + def validate(self, fvalue: int) -> int: + if fvalue in self.enum_values: + return fvalue + else: + raise TypeError("Invalid enum value") + + class BytesType: WIRE_TYPE = 2 @@ -210,6 +223,8 @@ async def load_message( fvalue = uint_to_sint(ivalue) elif ftype is BoolType: fvalue = bool(ivalue) + elif isinstance(ftype, EnumType): + fvalue = ftype.validate(ivalue) elif ftype is BytesType: fvalue = bytearray(ivalue) await reader.areadinto(fvalue) @@ -258,7 +273,7 @@ async def dump_message( repvalue[0] = fvalue fvalue = repvalue - if issubclass(ftype, MessageType): + if isinstance(ftype, type) and issubclass(ftype, MessageType): ffields = ftype.get_fields() else: ffields = None @@ -275,6 +290,9 @@ async def dump_message( elif ftype is BoolType: await dump_uvarint(writer, int(svalue)) + elif isinstance(ftype, EnumType): + await dump_uvarint(writer, svalue) + elif ftype is BytesType: if isinstance(svalue, list): await dump_uvarint(writer, _count_bytes_list(svalue)) @@ -332,6 +350,10 @@ def count_message(msg: MessageType, fields: Dict = None) -> int: for svalue in fvalue: nbytes += count_uvarint(int(svalue)) + elif isinstance(ftype, EnumType): + for svalue in fvalue: + nbytes += count_uvarint(svalue) + elif ftype is BytesType: for svalue in fvalue: if isinstance(svalue, list): diff --git a/core/src/trezor/messages/Address.py b/core/src/trezor/messages/Address.py index 3a780556d8..fca64e347c 100644 --- a/core/src/trezor/messages/Address.py +++ b/core/src/trezor/messages/Address.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/ApplyFlags.py b/core/src/trezor/messages/ApplyFlags.py index 85272f4b69..cb4da674e2 100644 --- a/core/src/trezor/messages/ApplyFlags.py +++ b/core/src/trezor/messages/ApplyFlags.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/ApplySettings.py b/core/src/trezor/messages/ApplySettings.py index 0835c69700..42a118aadf 100644 --- a/core/src/trezor/messages/ApplySettings.py +++ b/core/src/trezor/messages/ApplySettings.py @@ -5,8 +5,11 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypePassphraseSourceType = Literal[0, 1, 2] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypePassphraseSourceType = None # type: ignore class ApplySettings(p.MessageType): @@ -18,7 +21,7 @@ class ApplySettings(p.MessageType): label: str = None, use_passphrase: bool = None, homescreen: bytes = None, - passphrase_source: int = None, + passphrase_source: EnumTypePassphraseSourceType = None, auto_lock_delay_ms: int = None, display_rotation: int = None, ) -> None: @@ -37,7 +40,7 @@ class ApplySettings(p.MessageType): 2: ('label', p.UnicodeType, 0), 3: ('use_passphrase', p.BoolType, 0), 4: ('homescreen', p.BytesType, 0), - 5: ('passphrase_source', p.UVarintType, 0), + 5: ('passphrase_source', p.EnumType("PassphraseSourceType", (0, 1, 2)), 0), 6: ('auto_lock_delay_ms', p.UVarintType, 0), 7: ('display_rotation', p.UVarintType, 0), } diff --git a/core/src/trezor/messages/BackupDevice.py b/core/src/trezor/messages/BackupDevice.py index 98b614a1f5..6032038263 100644 --- a/core/src/trezor/messages/BackupDevice.py +++ b/core/src/trezor/messages/BackupDevice.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/BinanceAddress.py b/core/src/trezor/messages/BinanceAddress.py index 90f8d84210..8b900f8b3c 100644 --- a/core/src/trezor/messages/BinanceAddress.py +++ b/core/src/trezor/messages/BinanceAddress.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/BinanceCancelMsg.py b/core/src/trezor/messages/BinanceCancelMsg.py index 338103a5ae..d9eac7e7bd 100644 --- a/core/src/trezor/messages/BinanceCancelMsg.py +++ b/core/src/trezor/messages/BinanceCancelMsg.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/BinanceCoin.py b/core/src/trezor/messages/BinanceCoin.py index ffa6f019e6..e5c3f61481 100644 --- a/core/src/trezor/messages/BinanceCoin.py +++ b/core/src/trezor/messages/BinanceCoin.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/BinanceGetAddress.py b/core/src/trezor/messages/BinanceGetAddress.py index 15292de2ab..d011a8cd65 100644 --- a/core/src/trezor/messages/BinanceGetAddress.py +++ b/core/src/trezor/messages/BinanceGetAddress.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/BinanceGetPublicKey.py b/core/src/trezor/messages/BinanceGetPublicKey.py index 1b5a9e505c..1e561d1460 100644 --- a/core/src/trezor/messages/BinanceGetPublicKey.py +++ b/core/src/trezor/messages/BinanceGetPublicKey.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/BinanceInputOutput.py b/core/src/trezor/messages/BinanceInputOutput.py index 3e212eb1a3..bc36be1b89 100644 --- a/core/src/trezor/messages/BinanceInputOutput.py +++ b/core/src/trezor/messages/BinanceInputOutput.py @@ -7,6 +7,7 @@ from .BinanceCoin import BinanceCoin if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/BinanceOrderMsg.py b/core/src/trezor/messages/BinanceOrderMsg.py index 30e8c775d7..e55982d5e8 100644 --- a/core/src/trezor/messages/BinanceOrderMsg.py +++ b/core/src/trezor/messages/BinanceOrderMsg.py @@ -5,8 +5,15 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypeBinanceOrderType = Literal[0, 1, 2, 3] + EnumTypeBinanceOrderSide = Literal[0, 1, 2] + EnumTypeBinanceTimeInForce = Literal[0, 1, 2, 3] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeBinanceOrderType = None # type: ignore + EnumTypeBinanceOrderSide = None # type: ignore + EnumTypeBinanceTimeInForce = None # type: ignore class BinanceOrderMsg(p.MessageType): @@ -15,13 +22,13 @@ class BinanceOrderMsg(p.MessageType): def __init__( self, id: str = None, - ordertype: int = None, + ordertype: EnumTypeBinanceOrderType = None, price: int = None, quantity: int = None, sender: str = None, - side: int = None, + side: EnumTypeBinanceOrderSide = None, symbol: str = None, - timeinforce: int = None, + timeinforce: EnumTypeBinanceTimeInForce = None, ) -> None: self.id = id self.ordertype = ordertype @@ -36,11 +43,11 @@ class BinanceOrderMsg(p.MessageType): def get_fields(cls) -> Dict: return { 1: ('id', p.UnicodeType, 0), - 2: ('ordertype', p.UVarintType, 0), + 2: ('ordertype', p.EnumType("BinanceOrderType", (0, 1, 2, 3)), 0), 3: ('price', p.SVarintType, 0), 4: ('quantity', p.SVarintType, 0), 5: ('sender', p.UnicodeType, 0), - 6: ('side', p.UVarintType, 0), + 6: ('side', p.EnumType("BinanceOrderSide", (0, 1, 2)), 0), 7: ('symbol', p.UnicodeType, 0), - 8: ('timeinforce', p.UVarintType, 0), + 8: ('timeinforce', p.EnumType("BinanceTimeInForce", (0, 1, 2, 3)), 0), } diff --git a/core/src/trezor/messages/BinancePublicKey.py b/core/src/trezor/messages/BinancePublicKey.py index 468ae63443..7c85e586b0 100644 --- a/core/src/trezor/messages/BinancePublicKey.py +++ b/core/src/trezor/messages/BinancePublicKey.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/BinanceSignTx.py b/core/src/trezor/messages/BinanceSignTx.py index 0c117b95f3..2429985915 100644 --- a/core/src/trezor/messages/BinanceSignTx.py +++ b/core/src/trezor/messages/BinanceSignTx.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/BinanceSignedTx.py b/core/src/trezor/messages/BinanceSignedTx.py index a861e5b784..de1a5c5a37 100644 --- a/core/src/trezor/messages/BinanceSignedTx.py +++ b/core/src/trezor/messages/BinanceSignedTx.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/BinanceTransferMsg.py b/core/src/trezor/messages/BinanceTransferMsg.py index 37b76b21c5..f2ad7560f5 100644 --- a/core/src/trezor/messages/BinanceTransferMsg.py +++ b/core/src/trezor/messages/BinanceTransferMsg.py @@ -7,6 +7,7 @@ from .BinanceInputOutput import BinanceInputOutput if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/BinanceTxRequest.py b/core/src/trezor/messages/BinanceTxRequest.py index 394ae57211..121f9b404f 100644 --- a/core/src/trezor/messages/BinanceTxRequest.py +++ b/core/src/trezor/messages/BinanceTxRequest.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/ButtonAck.py b/core/src/trezor/messages/ButtonAck.py index c367455aa4..cd0166b6de 100644 --- a/core/src/trezor/messages/ButtonAck.py +++ b/core/src/trezor/messages/ButtonAck.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/ButtonRequest.py b/core/src/trezor/messages/ButtonRequest.py index 966b4a0f6c..c8985fbffb 100644 --- a/core/src/trezor/messages/ButtonRequest.py +++ b/core/src/trezor/messages/ButtonRequest.py @@ -5,8 +5,11 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypeButtonRequestType = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeButtonRequestType = None # type: ignore class ButtonRequest(p.MessageType): @@ -14,7 +17,7 @@ class ButtonRequest(p.MessageType): def __init__( self, - code: int = None, + code: EnumTypeButtonRequestType = None, data: str = None, ) -> None: self.code = code @@ -23,6 +26,6 @@ class ButtonRequest(p.MessageType): @classmethod def get_fields(cls) -> Dict: return { - 1: ('code', p.UVarintType, 0), + 1: ('code', p.EnumType("ButtonRequestType", (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18)), 0), 2: ('data', p.UnicodeType, 0), } diff --git a/core/src/trezor/messages/Cancel.py b/core/src/trezor/messages/Cancel.py index 8f677557dc..28f223e39d 100644 --- a/core/src/trezor/messages/Cancel.py +++ b/core/src/trezor/messages/Cancel.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/CardanoAddress.py b/core/src/trezor/messages/CardanoAddress.py index 69e6248547..7941868818 100644 --- a/core/src/trezor/messages/CardanoAddress.py +++ b/core/src/trezor/messages/CardanoAddress.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/CardanoGetAddress.py b/core/src/trezor/messages/CardanoGetAddress.py index 48805cee8d..0ddc7e29c3 100644 --- a/core/src/trezor/messages/CardanoGetAddress.py +++ b/core/src/trezor/messages/CardanoGetAddress.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/CardanoGetPublicKey.py b/core/src/trezor/messages/CardanoGetPublicKey.py index 3bd7a2dee4..377e9e2321 100644 --- a/core/src/trezor/messages/CardanoGetPublicKey.py +++ b/core/src/trezor/messages/CardanoGetPublicKey.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/CardanoPublicKey.py b/core/src/trezor/messages/CardanoPublicKey.py index f69055b3e8..a68cdae64c 100644 --- a/core/src/trezor/messages/CardanoPublicKey.py +++ b/core/src/trezor/messages/CardanoPublicKey.py @@ -7,6 +7,7 @@ from .HDNodeType import HDNodeType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/CardanoSignTx.py b/core/src/trezor/messages/CardanoSignTx.py index 3313c2c27b..410ad89076 100644 --- a/core/src/trezor/messages/CardanoSignTx.py +++ b/core/src/trezor/messages/CardanoSignTx.py @@ -8,6 +8,7 @@ from .CardanoTxOutputType import CardanoTxOutputType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/CardanoSignedTx.py b/core/src/trezor/messages/CardanoSignedTx.py index 7ca8aadf23..789a5bdf74 100644 --- a/core/src/trezor/messages/CardanoSignedTx.py +++ b/core/src/trezor/messages/CardanoSignedTx.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/CardanoTxAck.py b/core/src/trezor/messages/CardanoTxAck.py index d70f0954c1..d23533cdc9 100644 --- a/core/src/trezor/messages/CardanoTxAck.py +++ b/core/src/trezor/messages/CardanoTxAck.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/CardanoTxInputType.py b/core/src/trezor/messages/CardanoTxInputType.py index 9ed74bfb2d..ca48ef61d3 100644 --- a/core/src/trezor/messages/CardanoTxInputType.py +++ b/core/src/trezor/messages/CardanoTxInputType.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/CardanoTxOutputType.py b/core/src/trezor/messages/CardanoTxOutputType.py index 0ab22cbb6e..fe9e83a134 100644 --- a/core/src/trezor/messages/CardanoTxOutputType.py +++ b/core/src/trezor/messages/CardanoTxOutputType.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/CardanoTxRequest.py b/core/src/trezor/messages/CardanoTxRequest.py index fa7fbbc481..4c58ca0b97 100644 --- a/core/src/trezor/messages/CardanoTxRequest.py +++ b/core/src/trezor/messages/CardanoTxRequest.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/ChangePin.py b/core/src/trezor/messages/ChangePin.py index 69dac3511f..ddd1b07437 100644 --- a/core/src/trezor/messages/ChangePin.py +++ b/core/src/trezor/messages/ChangePin.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/CipherKeyValue.py b/core/src/trezor/messages/CipherKeyValue.py index 520e892831..b78004c3a0 100644 --- a/core/src/trezor/messages/CipherKeyValue.py +++ b/core/src/trezor/messages/CipherKeyValue.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/CipheredKeyValue.py b/core/src/trezor/messages/CipheredKeyValue.py index b0fa2d657b..d891123e47 100644 --- a/core/src/trezor/messages/CipheredKeyValue.py +++ b/core/src/trezor/messages/CipheredKeyValue.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/ClearSession.py b/core/src/trezor/messages/ClearSession.py index 17575c51f8..e7a956ba54 100644 --- a/core/src/trezor/messages/ClearSession.py +++ b/core/src/trezor/messages/ClearSession.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/DebugLinkDecision.py b/core/src/trezor/messages/DebugLinkDecision.py index bb900f46cf..3ee43101ff 100644 --- a/core/src/trezor/messages/DebugLinkDecision.py +++ b/core/src/trezor/messages/DebugLinkDecision.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/DebugLinkGetState.py b/core/src/trezor/messages/DebugLinkGetState.py index 63fa12476b..d979eaf582 100644 --- a/core/src/trezor/messages/DebugLinkGetState.py +++ b/core/src/trezor/messages/DebugLinkGetState.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/DebugLinkState.py b/core/src/trezor/messages/DebugLinkState.py index 5bf9a9015d..3bbf4f2e72 100644 --- a/core/src/trezor/messages/DebugLinkState.py +++ b/core/src/trezor/messages/DebugLinkState.py @@ -7,6 +7,7 @@ from .HDNodeType import HDNodeType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/DebugMoneroDiagAck.py b/core/src/trezor/messages/DebugMoneroDiagAck.py index fd02cc09da..1175db2bae 100644 --- a/core/src/trezor/messages/DebugMoneroDiagAck.py +++ b/core/src/trezor/messages/DebugMoneroDiagAck.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/DebugMoneroDiagRequest.py b/core/src/trezor/messages/DebugMoneroDiagRequest.py index ff03ad2170..7ba997d41d 100644 --- a/core/src/trezor/messages/DebugMoneroDiagRequest.py +++ b/core/src/trezor/messages/DebugMoneroDiagRequest.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/ECDHSessionKey.py b/core/src/trezor/messages/ECDHSessionKey.py index c628347fc5..88a08a1549 100644 --- a/core/src/trezor/messages/ECDHSessionKey.py +++ b/core/src/trezor/messages/ECDHSessionKey.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/Entropy.py b/core/src/trezor/messages/Entropy.py index 92974df658..984b484d45 100644 --- a/core/src/trezor/messages/Entropy.py +++ b/core/src/trezor/messages/Entropy.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EntropyAck.py b/core/src/trezor/messages/EntropyAck.py index 4c10818a59..3ccd6a80cb 100644 --- a/core/src/trezor/messages/EntropyAck.py +++ b/core/src/trezor/messages/EntropyAck.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EntropyRequest.py b/core/src/trezor/messages/EntropyRequest.py index 540d8003e0..8b13ba8664 100644 --- a/core/src/trezor/messages/EntropyRequest.py +++ b/core/src/trezor/messages/EntropyRequest.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EosActionBuyRam.py b/core/src/trezor/messages/EosActionBuyRam.py index f19950722b..8a7a03798c 100644 --- a/core/src/trezor/messages/EosActionBuyRam.py +++ b/core/src/trezor/messages/EosActionBuyRam.py @@ -7,6 +7,7 @@ from .EosAsset import EosAsset if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EosActionBuyRamBytes.py b/core/src/trezor/messages/EosActionBuyRamBytes.py index d277e902b0..2ad82455e4 100644 --- a/core/src/trezor/messages/EosActionBuyRamBytes.py +++ b/core/src/trezor/messages/EosActionBuyRamBytes.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EosActionCommon.py b/core/src/trezor/messages/EosActionCommon.py index bd08040f32..91051df825 100644 --- a/core/src/trezor/messages/EosActionCommon.py +++ b/core/src/trezor/messages/EosActionCommon.py @@ -7,6 +7,7 @@ from .EosPermissionLevel import EosPermissionLevel if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EosActionDelegate.py b/core/src/trezor/messages/EosActionDelegate.py index ea3e9a10a1..cd631e51f6 100644 --- a/core/src/trezor/messages/EosActionDelegate.py +++ b/core/src/trezor/messages/EosActionDelegate.py @@ -7,6 +7,7 @@ from .EosAsset import EosAsset if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EosActionDeleteAuth.py b/core/src/trezor/messages/EosActionDeleteAuth.py index b60e6ec45e..89b3896e0c 100644 --- a/core/src/trezor/messages/EosActionDeleteAuth.py +++ b/core/src/trezor/messages/EosActionDeleteAuth.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EosActionLinkAuth.py b/core/src/trezor/messages/EosActionLinkAuth.py index f67f39d74b..95c7b650c4 100644 --- a/core/src/trezor/messages/EosActionLinkAuth.py +++ b/core/src/trezor/messages/EosActionLinkAuth.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EosActionNewAccount.py b/core/src/trezor/messages/EosActionNewAccount.py index 3ea17ba7de..de62fbbdc5 100644 --- a/core/src/trezor/messages/EosActionNewAccount.py +++ b/core/src/trezor/messages/EosActionNewAccount.py @@ -7,6 +7,7 @@ from .EosAuthorization import EosAuthorization if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EosActionRefund.py b/core/src/trezor/messages/EosActionRefund.py index 27911e3bd5..c05a27cd4d 100644 --- a/core/src/trezor/messages/EosActionRefund.py +++ b/core/src/trezor/messages/EosActionRefund.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EosActionSellRam.py b/core/src/trezor/messages/EosActionSellRam.py index 63595bf5a6..476ad4b813 100644 --- a/core/src/trezor/messages/EosActionSellRam.py +++ b/core/src/trezor/messages/EosActionSellRam.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EosActionTransfer.py b/core/src/trezor/messages/EosActionTransfer.py index 4a54201881..afadc1c625 100644 --- a/core/src/trezor/messages/EosActionTransfer.py +++ b/core/src/trezor/messages/EosActionTransfer.py @@ -7,6 +7,7 @@ from .EosAsset import EosAsset if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EosActionUndelegate.py b/core/src/trezor/messages/EosActionUndelegate.py index 3e4db70c75..a42b8fdfab 100644 --- a/core/src/trezor/messages/EosActionUndelegate.py +++ b/core/src/trezor/messages/EosActionUndelegate.py @@ -7,6 +7,7 @@ from .EosAsset import EosAsset if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EosActionUnknown.py b/core/src/trezor/messages/EosActionUnknown.py index 34827939f7..1a2e3ef9ce 100644 --- a/core/src/trezor/messages/EosActionUnknown.py +++ b/core/src/trezor/messages/EosActionUnknown.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EosActionUnlinkAuth.py b/core/src/trezor/messages/EosActionUnlinkAuth.py index fa626b0a2e..cad2341604 100644 --- a/core/src/trezor/messages/EosActionUnlinkAuth.py +++ b/core/src/trezor/messages/EosActionUnlinkAuth.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EosActionUpdateAuth.py b/core/src/trezor/messages/EosActionUpdateAuth.py index 60b4487125..0bbb7531cf 100644 --- a/core/src/trezor/messages/EosActionUpdateAuth.py +++ b/core/src/trezor/messages/EosActionUpdateAuth.py @@ -7,6 +7,7 @@ from .EosAuthorization import EosAuthorization if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EosActionVoteProducer.py b/core/src/trezor/messages/EosActionVoteProducer.py index 8f5fd0c5e2..e7175e0dbd 100644 --- a/core/src/trezor/messages/EosActionVoteProducer.py +++ b/core/src/trezor/messages/EosActionVoteProducer.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EosAsset.py b/core/src/trezor/messages/EosAsset.py index 1a8b004949..bac7f995f6 100644 --- a/core/src/trezor/messages/EosAsset.py +++ b/core/src/trezor/messages/EosAsset.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EosAuthorization.py b/core/src/trezor/messages/EosAuthorization.py index cb5870042a..e6092101ec 100644 --- a/core/src/trezor/messages/EosAuthorization.py +++ b/core/src/trezor/messages/EosAuthorization.py @@ -9,6 +9,7 @@ from .EosAuthorizationWait import EosAuthorizationWait if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EosAuthorizationAccount.py b/core/src/trezor/messages/EosAuthorizationAccount.py index bcc815ac08..a7daffd4cf 100644 --- a/core/src/trezor/messages/EosAuthorizationAccount.py +++ b/core/src/trezor/messages/EosAuthorizationAccount.py @@ -7,6 +7,7 @@ from .EosPermissionLevel import EosPermissionLevel if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EosAuthorizationKey.py b/core/src/trezor/messages/EosAuthorizationKey.py index b49a1830e5..435625c555 100644 --- a/core/src/trezor/messages/EosAuthorizationKey.py +++ b/core/src/trezor/messages/EosAuthorizationKey.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EosAuthorizationWait.py b/core/src/trezor/messages/EosAuthorizationWait.py index 2d9f5262d5..137c1e3ae0 100644 --- a/core/src/trezor/messages/EosAuthorizationWait.py +++ b/core/src/trezor/messages/EosAuthorizationWait.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EosGetPublicKey.py b/core/src/trezor/messages/EosGetPublicKey.py index 89d055fcf0..fba03937a8 100644 --- a/core/src/trezor/messages/EosGetPublicKey.py +++ b/core/src/trezor/messages/EosGetPublicKey.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EosPermissionLevel.py b/core/src/trezor/messages/EosPermissionLevel.py index 8d00ae8c71..3a407879a2 100644 --- a/core/src/trezor/messages/EosPermissionLevel.py +++ b/core/src/trezor/messages/EosPermissionLevel.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EosPublicKey.py b/core/src/trezor/messages/EosPublicKey.py index b9d6f74203..e50aa79754 100644 --- a/core/src/trezor/messages/EosPublicKey.py +++ b/core/src/trezor/messages/EosPublicKey.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EosSignTx.py b/core/src/trezor/messages/EosSignTx.py index eddb119fe3..e2027fcaa7 100644 --- a/core/src/trezor/messages/EosSignTx.py +++ b/core/src/trezor/messages/EosSignTx.py @@ -7,6 +7,7 @@ from .EosTxHeader import EosTxHeader if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EosSignedTx.py b/core/src/trezor/messages/EosSignedTx.py index f0362ca889..755fc01e9b 100644 --- a/core/src/trezor/messages/EosSignedTx.py +++ b/core/src/trezor/messages/EosSignedTx.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EosTxActionAck.py b/core/src/trezor/messages/EosTxActionAck.py index 8285789ae5..7b7f37d1c9 100644 --- a/core/src/trezor/messages/EosTxActionAck.py +++ b/core/src/trezor/messages/EosTxActionAck.py @@ -21,6 +21,7 @@ from .EosActionVoteProducer import EosActionVoteProducer if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EosTxActionRequest.py b/core/src/trezor/messages/EosTxActionRequest.py index 7fc35b2900..b3a67e49a9 100644 --- a/core/src/trezor/messages/EosTxActionRequest.py +++ b/core/src/trezor/messages/EosTxActionRequest.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EosTxHeader.py b/core/src/trezor/messages/EosTxHeader.py index 829104ce32..8c253fd4a1 100644 --- a/core/src/trezor/messages/EosTxHeader.py +++ b/core/src/trezor/messages/EosTxHeader.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EthereumAddress.py b/core/src/trezor/messages/EthereumAddress.py index 44e98bf43a..3c2d1ad51f 100644 --- a/core/src/trezor/messages/EthereumAddress.py +++ b/core/src/trezor/messages/EthereumAddress.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EthereumGetAddress.py b/core/src/trezor/messages/EthereumGetAddress.py index 1dd567a234..d4f0ac4925 100644 --- a/core/src/trezor/messages/EthereumGetAddress.py +++ b/core/src/trezor/messages/EthereumGetAddress.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EthereumGetPublicKey.py b/core/src/trezor/messages/EthereumGetPublicKey.py index 70f6032f3f..cb0481de5d 100644 --- a/core/src/trezor/messages/EthereumGetPublicKey.py +++ b/core/src/trezor/messages/EthereumGetPublicKey.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EthereumMessageSignature.py b/core/src/trezor/messages/EthereumMessageSignature.py index dc71d48ddf..29dab290d0 100644 --- a/core/src/trezor/messages/EthereumMessageSignature.py +++ b/core/src/trezor/messages/EthereumMessageSignature.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EthereumPublicKey.py b/core/src/trezor/messages/EthereumPublicKey.py index 52a4b03e98..e700dc14d5 100644 --- a/core/src/trezor/messages/EthereumPublicKey.py +++ b/core/src/trezor/messages/EthereumPublicKey.py @@ -7,6 +7,7 @@ from .HDNodeType import HDNodeType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EthereumSignMessage.py b/core/src/trezor/messages/EthereumSignMessage.py index aaac15813e..e615995170 100644 --- a/core/src/trezor/messages/EthereumSignMessage.py +++ b/core/src/trezor/messages/EthereumSignMessage.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EthereumSignTx.py b/core/src/trezor/messages/EthereumSignTx.py index 5ba9021625..15140ef680 100644 --- a/core/src/trezor/messages/EthereumSignTx.py +++ b/core/src/trezor/messages/EthereumSignTx.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EthereumTxAck.py b/core/src/trezor/messages/EthereumTxAck.py index 22d9627e59..5cec103b24 100644 --- a/core/src/trezor/messages/EthereumTxAck.py +++ b/core/src/trezor/messages/EthereumTxAck.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EthereumTxRequest.py b/core/src/trezor/messages/EthereumTxRequest.py index e748684bf0..fa807c106e 100644 --- a/core/src/trezor/messages/EthereumTxRequest.py +++ b/core/src/trezor/messages/EthereumTxRequest.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/EthereumVerifyMessage.py b/core/src/trezor/messages/EthereumVerifyMessage.py index 9742b7fcca..c0dc9d5e38 100644 --- a/core/src/trezor/messages/EthereumVerifyMessage.py +++ b/core/src/trezor/messages/EthereumVerifyMessage.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/Failure.py b/core/src/trezor/messages/Failure.py index c8c692515d..51a0b7b3b7 100644 --- a/core/src/trezor/messages/Failure.py +++ b/core/src/trezor/messages/Failure.py @@ -5,8 +5,11 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypeFailureType = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 99] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeFailureType = None # type: ignore class Failure(p.MessageType): @@ -14,7 +17,7 @@ class Failure(p.MessageType): def __init__( self, - code: int = None, + code: EnumTypeFailureType = None, message: str = None, ) -> None: self.code = code @@ -23,6 +26,6 @@ class Failure(p.MessageType): @classmethod def get_fields(cls) -> Dict: return { - 1: ('code', p.UVarintType, 0), + 1: ('code', p.EnumType("FailureType", (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 99)), 0), 2: ('message', p.UnicodeType, 0), } diff --git a/core/src/trezor/messages/Features.py b/core/src/trezor/messages/Features.py index e5808b4284..f48d453e13 100644 --- a/core/src/trezor/messages/Features.py +++ b/core/src/trezor/messages/Features.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/GetAddress.py b/core/src/trezor/messages/GetAddress.py index 2e2378bbd9..191aa8756d 100644 --- a/core/src/trezor/messages/GetAddress.py +++ b/core/src/trezor/messages/GetAddress.py @@ -7,8 +7,11 @@ from .MultisigRedeemScriptType import MultisigRedeemScriptType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypeInputScriptType = Literal[0, 1, 2, 3, 4] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeInputScriptType = None # type: ignore class GetAddress(p.MessageType): @@ -20,7 +23,7 @@ class GetAddress(p.MessageType): coin_name: str = None, show_display: bool = None, multisig: MultisigRedeemScriptType = None, - script_type: int = None, + script_type: EnumTypeInputScriptType = None, ) -> None: self.address_n = address_n if address_n is not None else [] self.coin_name = coin_name @@ -35,5 +38,5 @@ class GetAddress(p.MessageType): 2: ('coin_name', p.UnicodeType, 0), # default=Bitcoin 3: ('show_display', p.BoolType, 0), 4: ('multisig', MultisigRedeemScriptType, 0), - 5: ('script_type', p.UVarintType, 0), # default=SPENDADDRESS + 5: ('script_type', p.EnumType("InputScriptType", (0, 1, 2, 3, 4)), 0), # default=SPENDADDRESS } diff --git a/core/src/trezor/messages/GetECDHSessionKey.py b/core/src/trezor/messages/GetECDHSessionKey.py index 76daabe981..3a2609bbae 100644 --- a/core/src/trezor/messages/GetECDHSessionKey.py +++ b/core/src/trezor/messages/GetECDHSessionKey.py @@ -7,6 +7,7 @@ from .IdentityType import IdentityType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/GetEntropy.py b/core/src/trezor/messages/GetEntropy.py index 510acbd981..74292be148 100644 --- a/core/src/trezor/messages/GetEntropy.py +++ b/core/src/trezor/messages/GetEntropy.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/GetFeatures.py b/core/src/trezor/messages/GetFeatures.py index bf9f47eacb..d66bf6efa5 100644 --- a/core/src/trezor/messages/GetFeatures.py +++ b/core/src/trezor/messages/GetFeatures.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/GetPublicKey.py b/core/src/trezor/messages/GetPublicKey.py index ebc8c67ebf..725bceb138 100644 --- a/core/src/trezor/messages/GetPublicKey.py +++ b/core/src/trezor/messages/GetPublicKey.py @@ -5,8 +5,11 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypeInputScriptType = Literal[0, 1, 2, 3, 4] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeInputScriptType = None # type: ignore class GetPublicKey(p.MessageType): @@ -18,7 +21,7 @@ class GetPublicKey(p.MessageType): ecdsa_curve_name: str = None, show_display: bool = None, coin_name: str = None, - script_type: int = None, + script_type: EnumTypeInputScriptType = None, ) -> None: self.address_n = address_n if address_n is not None else [] self.ecdsa_curve_name = ecdsa_curve_name @@ -33,5 +36,5 @@ class GetPublicKey(p.MessageType): 2: ('ecdsa_curve_name', p.UnicodeType, 0), 3: ('show_display', p.BoolType, 0), 4: ('coin_name', p.UnicodeType, 0), # default=Bitcoin - 5: ('script_type', p.UVarintType, 0), # default=SPENDADDRESS + 5: ('script_type', p.EnumType("InputScriptType", (0, 1, 2, 3, 4)), 0), # default=SPENDADDRESS } diff --git a/core/src/trezor/messages/HDNodePathType.py b/core/src/trezor/messages/HDNodePathType.py index 4f53fda6fc..b81b08886b 100644 --- a/core/src/trezor/messages/HDNodePathType.py +++ b/core/src/trezor/messages/HDNodePathType.py @@ -7,6 +7,7 @@ from .HDNodeType import HDNodeType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/HDNodeType.py b/core/src/trezor/messages/HDNodeType.py index 5dd7d6c173..434d54db84 100644 --- a/core/src/trezor/messages/HDNodeType.py +++ b/core/src/trezor/messages/HDNodeType.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/IdentityType.py b/core/src/trezor/messages/IdentityType.py index 7860ea8336..475e17ff60 100644 --- a/core/src/trezor/messages/IdentityType.py +++ b/core/src/trezor/messages/IdentityType.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/Initialize.py b/core/src/trezor/messages/Initialize.py index f170b27513..b5bb5dae23 100644 --- a/core/src/trezor/messages/Initialize.py +++ b/core/src/trezor/messages/Initialize.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/LiskAddress.py b/core/src/trezor/messages/LiskAddress.py index 6a93a6e96e..2ebb8a9dc4 100644 --- a/core/src/trezor/messages/LiskAddress.py +++ b/core/src/trezor/messages/LiskAddress.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/LiskDelegateType.py b/core/src/trezor/messages/LiskDelegateType.py index 897d321e9a..7804d7a2a0 100644 --- a/core/src/trezor/messages/LiskDelegateType.py +++ b/core/src/trezor/messages/LiskDelegateType.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/LiskGetAddress.py b/core/src/trezor/messages/LiskGetAddress.py index 94e4803501..55b69afe79 100644 --- a/core/src/trezor/messages/LiskGetAddress.py +++ b/core/src/trezor/messages/LiskGetAddress.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/LiskGetPublicKey.py b/core/src/trezor/messages/LiskGetPublicKey.py index 182faf20d5..a742a12c51 100644 --- a/core/src/trezor/messages/LiskGetPublicKey.py +++ b/core/src/trezor/messages/LiskGetPublicKey.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/LiskMessageSignature.py b/core/src/trezor/messages/LiskMessageSignature.py index 7efe9eb224..9178fb1da0 100644 --- a/core/src/trezor/messages/LiskMessageSignature.py +++ b/core/src/trezor/messages/LiskMessageSignature.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/LiskMultisignatureType.py b/core/src/trezor/messages/LiskMultisignatureType.py index 64340ed43a..55df7053c8 100644 --- a/core/src/trezor/messages/LiskMultisignatureType.py +++ b/core/src/trezor/messages/LiskMultisignatureType.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/LiskPublicKey.py b/core/src/trezor/messages/LiskPublicKey.py index e39b95d472..7192e92e0d 100644 --- a/core/src/trezor/messages/LiskPublicKey.py +++ b/core/src/trezor/messages/LiskPublicKey.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/LiskSignMessage.py b/core/src/trezor/messages/LiskSignMessage.py index ca5658742f..e0d0728d85 100644 --- a/core/src/trezor/messages/LiskSignMessage.py +++ b/core/src/trezor/messages/LiskSignMessage.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/LiskSignTx.py b/core/src/trezor/messages/LiskSignTx.py index b0d3f227d1..afd35e0a3f 100644 --- a/core/src/trezor/messages/LiskSignTx.py +++ b/core/src/trezor/messages/LiskSignTx.py @@ -7,6 +7,7 @@ from .LiskTransactionCommon import LiskTransactionCommon if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/LiskSignatureType.py b/core/src/trezor/messages/LiskSignatureType.py index bebb416f7b..3bb7bd4113 100644 --- a/core/src/trezor/messages/LiskSignatureType.py +++ b/core/src/trezor/messages/LiskSignatureType.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/LiskSignedTx.py b/core/src/trezor/messages/LiskSignedTx.py index 9ecee42050..2155b90004 100644 --- a/core/src/trezor/messages/LiskSignedTx.py +++ b/core/src/trezor/messages/LiskSignedTx.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/LiskTransactionAsset.py b/core/src/trezor/messages/LiskTransactionAsset.py index df680745cd..16bf74338e 100644 --- a/core/src/trezor/messages/LiskTransactionAsset.py +++ b/core/src/trezor/messages/LiskTransactionAsset.py @@ -9,6 +9,7 @@ from .LiskSignatureType import LiskSignatureType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/LiskTransactionCommon.py b/core/src/trezor/messages/LiskTransactionCommon.py index 3f576adf99..c5ce85f79e 100644 --- a/core/src/trezor/messages/LiskTransactionCommon.py +++ b/core/src/trezor/messages/LiskTransactionCommon.py @@ -7,15 +7,18 @@ from .LiskTransactionAsset import LiskTransactionAsset if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypeLiskTransactionType = Literal[0, 1, 2, 3, 4, 5, 6, 7] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeLiskTransactionType = None # type: ignore class LiskTransactionCommon(p.MessageType): def __init__( self, - type: int = None, + type: EnumTypeLiskTransactionType = None, amount: int = None, fee: int = None, recipient_id: str = None, @@ -38,7 +41,7 @@ class LiskTransactionCommon(p.MessageType): @classmethod def get_fields(cls) -> Dict: return { - 1: ('type', p.UVarintType, 0), + 1: ('type', p.EnumType("LiskTransactionType", (0, 1, 2, 3, 4, 5, 6, 7)), 0), 2: ('amount', p.UVarintType, 0), # default=0 3: ('fee', p.UVarintType, 0), 4: ('recipient_id', p.UnicodeType, 0), diff --git a/core/src/trezor/messages/LiskVerifyMessage.py b/core/src/trezor/messages/LiskVerifyMessage.py index 7b7b6fb172..f8eebbb86e 100644 --- a/core/src/trezor/messages/LiskVerifyMessage.py +++ b/core/src/trezor/messages/LiskVerifyMessage.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/LoadDevice.py b/core/src/trezor/messages/LoadDevice.py index 936ae0b99e..767e326bcd 100644 --- a/core/src/trezor/messages/LoadDevice.py +++ b/core/src/trezor/messages/LoadDevice.py @@ -7,6 +7,7 @@ from .HDNodeType import HDNodeType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MessageSignature.py b/core/src/trezor/messages/MessageSignature.py index fda04a02f1..e6682a4871 100644 --- a/core/src/trezor/messages/MessageSignature.py +++ b/core/src/trezor/messages/MessageSignature.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroAccountPublicAddress.py b/core/src/trezor/messages/MoneroAccountPublicAddress.py index 3fee8c261b..59b6d6345e 100644 --- a/core/src/trezor/messages/MoneroAccountPublicAddress.py +++ b/core/src/trezor/messages/MoneroAccountPublicAddress.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroAddress.py b/core/src/trezor/messages/MoneroAddress.py index c0906a3eb8..27c720bbc9 100644 --- a/core/src/trezor/messages/MoneroAddress.py +++ b/core/src/trezor/messages/MoneroAddress.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroExportedKeyImage.py b/core/src/trezor/messages/MoneroExportedKeyImage.py index 7dc2bcd7a3..81c29cbc84 100644 --- a/core/src/trezor/messages/MoneroExportedKeyImage.py +++ b/core/src/trezor/messages/MoneroExportedKeyImage.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroGetAddress.py b/core/src/trezor/messages/MoneroGetAddress.py index aa0ef3df30..1f310a2f1c 100644 --- a/core/src/trezor/messages/MoneroGetAddress.py +++ b/core/src/trezor/messages/MoneroGetAddress.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroGetTxKeyAck.py b/core/src/trezor/messages/MoneroGetTxKeyAck.py index 85d46d9823..9e646815ff 100644 --- a/core/src/trezor/messages/MoneroGetTxKeyAck.py +++ b/core/src/trezor/messages/MoneroGetTxKeyAck.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroGetTxKeyRequest.py b/core/src/trezor/messages/MoneroGetTxKeyRequest.py index 28cf1949e5..5e9777b19c 100644 --- a/core/src/trezor/messages/MoneroGetTxKeyRequest.py +++ b/core/src/trezor/messages/MoneroGetTxKeyRequest.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroGetWatchKey.py b/core/src/trezor/messages/MoneroGetWatchKey.py index 77000d2a3f..17bea95d75 100644 --- a/core/src/trezor/messages/MoneroGetWatchKey.py +++ b/core/src/trezor/messages/MoneroGetWatchKey.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroKeyImageExportInitAck.py b/core/src/trezor/messages/MoneroKeyImageExportInitAck.py index 39d4a52f81..b256412813 100644 --- a/core/src/trezor/messages/MoneroKeyImageExportInitAck.py +++ b/core/src/trezor/messages/MoneroKeyImageExportInitAck.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroKeyImageExportInitRequest.py b/core/src/trezor/messages/MoneroKeyImageExportInitRequest.py index 6e67099364..c39ee80c4a 100644 --- a/core/src/trezor/messages/MoneroKeyImageExportInitRequest.py +++ b/core/src/trezor/messages/MoneroKeyImageExportInitRequest.py @@ -7,6 +7,7 @@ from .MoneroSubAddressIndicesList import MoneroSubAddressIndicesList if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroKeyImageSyncFinalAck.py b/core/src/trezor/messages/MoneroKeyImageSyncFinalAck.py index 2dcb45a57d..df449f11c1 100644 --- a/core/src/trezor/messages/MoneroKeyImageSyncFinalAck.py +++ b/core/src/trezor/messages/MoneroKeyImageSyncFinalAck.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroKeyImageSyncFinalRequest.py b/core/src/trezor/messages/MoneroKeyImageSyncFinalRequest.py index 75ce7dee58..e9366756ad 100644 --- a/core/src/trezor/messages/MoneroKeyImageSyncFinalRequest.py +++ b/core/src/trezor/messages/MoneroKeyImageSyncFinalRequest.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroKeyImageSyncStepAck.py b/core/src/trezor/messages/MoneroKeyImageSyncStepAck.py index 1deb2a493c..da0d28dca5 100644 --- a/core/src/trezor/messages/MoneroKeyImageSyncStepAck.py +++ b/core/src/trezor/messages/MoneroKeyImageSyncStepAck.py @@ -7,6 +7,7 @@ from .MoneroExportedKeyImage import MoneroExportedKeyImage if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroKeyImageSyncStepRequest.py b/core/src/trezor/messages/MoneroKeyImageSyncStepRequest.py index 77bb548791..9fd3dfcbb9 100644 --- a/core/src/trezor/messages/MoneroKeyImageSyncStepRequest.py +++ b/core/src/trezor/messages/MoneroKeyImageSyncStepRequest.py @@ -7,6 +7,7 @@ from .MoneroTransferDetails import MoneroTransferDetails if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroLiveRefreshFinalAck.py b/core/src/trezor/messages/MoneroLiveRefreshFinalAck.py index 27efe92421..3d8167b70c 100644 --- a/core/src/trezor/messages/MoneroLiveRefreshFinalAck.py +++ b/core/src/trezor/messages/MoneroLiveRefreshFinalAck.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroLiveRefreshFinalRequest.py b/core/src/trezor/messages/MoneroLiveRefreshFinalRequest.py index 650794c871..48a4bca5b9 100644 --- a/core/src/trezor/messages/MoneroLiveRefreshFinalRequest.py +++ b/core/src/trezor/messages/MoneroLiveRefreshFinalRequest.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroLiveRefreshStartAck.py b/core/src/trezor/messages/MoneroLiveRefreshStartAck.py index 0758dab176..9283f76d87 100644 --- a/core/src/trezor/messages/MoneroLiveRefreshStartAck.py +++ b/core/src/trezor/messages/MoneroLiveRefreshStartAck.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroLiveRefreshStartRequest.py b/core/src/trezor/messages/MoneroLiveRefreshStartRequest.py index c9e4adf089..6cffc897d4 100644 --- a/core/src/trezor/messages/MoneroLiveRefreshStartRequest.py +++ b/core/src/trezor/messages/MoneroLiveRefreshStartRequest.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroLiveRefreshStepAck.py b/core/src/trezor/messages/MoneroLiveRefreshStepAck.py index eac1750fb1..9b5133f64a 100644 --- a/core/src/trezor/messages/MoneroLiveRefreshStepAck.py +++ b/core/src/trezor/messages/MoneroLiveRefreshStepAck.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroLiveRefreshStepRequest.py b/core/src/trezor/messages/MoneroLiveRefreshStepRequest.py index 75767b4dfc..ceaff811f0 100644 --- a/core/src/trezor/messages/MoneroLiveRefreshStepRequest.py +++ b/core/src/trezor/messages/MoneroLiveRefreshStepRequest.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroMultisigKLRki.py b/core/src/trezor/messages/MoneroMultisigKLRki.py index 2bdf40f783..5322d19791 100644 --- a/core/src/trezor/messages/MoneroMultisigKLRki.py +++ b/core/src/trezor/messages/MoneroMultisigKLRki.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroOutputEntry.py b/core/src/trezor/messages/MoneroOutputEntry.py index 95fb051865..0796380d3c 100644 --- a/core/src/trezor/messages/MoneroOutputEntry.py +++ b/core/src/trezor/messages/MoneroOutputEntry.py @@ -7,6 +7,7 @@ from .MoneroRctKeyPublic import MoneroRctKeyPublic if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroRctKeyPublic.py b/core/src/trezor/messages/MoneroRctKeyPublic.py index 709df1464d..4c3b7099c7 100644 --- a/core/src/trezor/messages/MoneroRctKeyPublic.py +++ b/core/src/trezor/messages/MoneroRctKeyPublic.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroRingCtSig.py b/core/src/trezor/messages/MoneroRingCtSig.py index 36bd8a3ff2..364637d665 100644 --- a/core/src/trezor/messages/MoneroRingCtSig.py +++ b/core/src/trezor/messages/MoneroRingCtSig.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroSubAddressIndicesList.py b/core/src/trezor/messages/MoneroSubAddressIndicesList.py index 1aeb916c8c..d1cf497063 100644 --- a/core/src/trezor/messages/MoneroSubAddressIndicesList.py +++ b/core/src/trezor/messages/MoneroSubAddressIndicesList.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroTransactionAllInputsSetAck.py b/core/src/trezor/messages/MoneroTransactionAllInputsSetAck.py index 587d24e3b6..69a7f9235b 100644 --- a/core/src/trezor/messages/MoneroTransactionAllInputsSetAck.py +++ b/core/src/trezor/messages/MoneroTransactionAllInputsSetAck.py @@ -7,6 +7,7 @@ from .MoneroTransactionRsigData import MoneroTransactionRsigData if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroTransactionAllInputsSetRequest.py b/core/src/trezor/messages/MoneroTransactionAllInputsSetRequest.py index 42157f766d..af99331a04 100644 --- a/core/src/trezor/messages/MoneroTransactionAllInputsSetRequest.py +++ b/core/src/trezor/messages/MoneroTransactionAllInputsSetRequest.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroTransactionAllOutSetAck.py b/core/src/trezor/messages/MoneroTransactionAllOutSetAck.py index 2e3eb946b9..81e9695f14 100644 --- a/core/src/trezor/messages/MoneroTransactionAllOutSetAck.py +++ b/core/src/trezor/messages/MoneroTransactionAllOutSetAck.py @@ -7,6 +7,7 @@ from .MoneroRingCtSig import MoneroRingCtSig if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroTransactionAllOutSetRequest.py b/core/src/trezor/messages/MoneroTransactionAllOutSetRequest.py index f029df4fd5..d7c9269624 100644 --- a/core/src/trezor/messages/MoneroTransactionAllOutSetRequest.py +++ b/core/src/trezor/messages/MoneroTransactionAllOutSetRequest.py @@ -7,6 +7,7 @@ from .MoneroTransactionRsigData import MoneroTransactionRsigData if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroTransactionData.py b/core/src/trezor/messages/MoneroTransactionData.py index cc982c0eb3..1c50d7504f 100644 --- a/core/src/trezor/messages/MoneroTransactionData.py +++ b/core/src/trezor/messages/MoneroTransactionData.py @@ -8,6 +8,7 @@ from .MoneroTransactionRsigData import MoneroTransactionRsigData if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroTransactionDestinationEntry.py b/core/src/trezor/messages/MoneroTransactionDestinationEntry.py index 827689615b..7d5fbbc5d0 100644 --- a/core/src/trezor/messages/MoneroTransactionDestinationEntry.py +++ b/core/src/trezor/messages/MoneroTransactionDestinationEntry.py @@ -7,6 +7,7 @@ from .MoneroAccountPublicAddress import MoneroAccountPublicAddress if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroTransactionFinalAck.py b/core/src/trezor/messages/MoneroTransactionFinalAck.py index 4032a3e1f6..42a72d9a1f 100644 --- a/core/src/trezor/messages/MoneroTransactionFinalAck.py +++ b/core/src/trezor/messages/MoneroTransactionFinalAck.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroTransactionFinalRequest.py b/core/src/trezor/messages/MoneroTransactionFinalRequest.py index 643fbe910d..1f4b7d870e 100644 --- a/core/src/trezor/messages/MoneroTransactionFinalRequest.py +++ b/core/src/trezor/messages/MoneroTransactionFinalRequest.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroTransactionInitAck.py b/core/src/trezor/messages/MoneroTransactionInitAck.py index 96d05d7762..ba3d5689a0 100644 --- a/core/src/trezor/messages/MoneroTransactionInitAck.py +++ b/core/src/trezor/messages/MoneroTransactionInitAck.py @@ -7,6 +7,7 @@ from .MoneroTransactionRsigData import MoneroTransactionRsigData if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroTransactionInitRequest.py b/core/src/trezor/messages/MoneroTransactionInitRequest.py index cf932a2c8b..46efce19b7 100644 --- a/core/src/trezor/messages/MoneroTransactionInitRequest.py +++ b/core/src/trezor/messages/MoneroTransactionInitRequest.py @@ -7,6 +7,7 @@ from .MoneroTransactionData import MoneroTransactionData if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroTransactionInputViniAck.py b/core/src/trezor/messages/MoneroTransactionInputViniAck.py index 0b7ef69bdc..bc2ade25ad 100644 --- a/core/src/trezor/messages/MoneroTransactionInputViniAck.py +++ b/core/src/trezor/messages/MoneroTransactionInputViniAck.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroTransactionInputViniRequest.py b/core/src/trezor/messages/MoneroTransactionInputViniRequest.py index 69eb00b999..8702221290 100644 --- a/core/src/trezor/messages/MoneroTransactionInputViniRequest.py +++ b/core/src/trezor/messages/MoneroTransactionInputViniRequest.py @@ -7,6 +7,7 @@ from .MoneroTransactionSourceEntry import MoneroTransactionSourceEntry if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroTransactionInputsPermutationAck.py b/core/src/trezor/messages/MoneroTransactionInputsPermutationAck.py index a40c58f950..5ee59585d3 100644 --- a/core/src/trezor/messages/MoneroTransactionInputsPermutationAck.py +++ b/core/src/trezor/messages/MoneroTransactionInputsPermutationAck.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroTransactionInputsPermutationRequest.py b/core/src/trezor/messages/MoneroTransactionInputsPermutationRequest.py index 669c653894..3041a76668 100644 --- a/core/src/trezor/messages/MoneroTransactionInputsPermutationRequest.py +++ b/core/src/trezor/messages/MoneroTransactionInputsPermutationRequest.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroTransactionRsigData.py b/core/src/trezor/messages/MoneroTransactionRsigData.py index 441b4d35de..6b203b8e39 100644 --- a/core/src/trezor/messages/MoneroTransactionRsigData.py +++ b/core/src/trezor/messages/MoneroTransactionRsigData.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroTransactionSetInputAck.py b/core/src/trezor/messages/MoneroTransactionSetInputAck.py index 5a01801ad8..52ce021dc9 100644 --- a/core/src/trezor/messages/MoneroTransactionSetInputAck.py +++ b/core/src/trezor/messages/MoneroTransactionSetInputAck.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroTransactionSetInputRequest.py b/core/src/trezor/messages/MoneroTransactionSetInputRequest.py index 6d276fd188..fa2e01a262 100644 --- a/core/src/trezor/messages/MoneroTransactionSetInputRequest.py +++ b/core/src/trezor/messages/MoneroTransactionSetInputRequest.py @@ -7,6 +7,7 @@ from .MoneroTransactionSourceEntry import MoneroTransactionSourceEntry if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroTransactionSetOutputAck.py b/core/src/trezor/messages/MoneroTransactionSetOutputAck.py index 6f65ce1a22..fe1592c31d 100644 --- a/core/src/trezor/messages/MoneroTransactionSetOutputAck.py +++ b/core/src/trezor/messages/MoneroTransactionSetOutputAck.py @@ -7,6 +7,7 @@ from .MoneroTransactionRsigData import MoneroTransactionRsigData if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroTransactionSetOutputRequest.py b/core/src/trezor/messages/MoneroTransactionSetOutputRequest.py index ddf02031e3..445fceb961 100644 --- a/core/src/trezor/messages/MoneroTransactionSetOutputRequest.py +++ b/core/src/trezor/messages/MoneroTransactionSetOutputRequest.py @@ -8,6 +8,7 @@ from .MoneroTransactionRsigData import MoneroTransactionRsigData if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroTransactionSignInputAck.py b/core/src/trezor/messages/MoneroTransactionSignInputAck.py index 99c38e5269..b74a517781 100644 --- a/core/src/trezor/messages/MoneroTransactionSignInputAck.py +++ b/core/src/trezor/messages/MoneroTransactionSignInputAck.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroTransactionSignInputRequest.py b/core/src/trezor/messages/MoneroTransactionSignInputRequest.py index 906d2eeb9d..3cfd189b86 100644 --- a/core/src/trezor/messages/MoneroTransactionSignInputRequest.py +++ b/core/src/trezor/messages/MoneroTransactionSignInputRequest.py @@ -7,6 +7,7 @@ from .MoneroTransactionSourceEntry import MoneroTransactionSourceEntry if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroTransactionSourceEntry.py b/core/src/trezor/messages/MoneroTransactionSourceEntry.py index 45cd4000da..574d14325b 100644 --- a/core/src/trezor/messages/MoneroTransactionSourceEntry.py +++ b/core/src/trezor/messages/MoneroTransactionSourceEntry.py @@ -8,6 +8,7 @@ from .MoneroOutputEntry import MoneroOutputEntry if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroTransferDetails.py b/core/src/trezor/messages/MoneroTransferDetails.py index b57932047e..d00d2106ab 100644 --- a/core/src/trezor/messages/MoneroTransferDetails.py +++ b/core/src/trezor/messages/MoneroTransferDetails.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MoneroWatchKey.py b/core/src/trezor/messages/MoneroWatchKey.py index 11beee8983..a2844f1581 100644 --- a/core/src/trezor/messages/MoneroWatchKey.py +++ b/core/src/trezor/messages/MoneroWatchKey.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/MultisigRedeemScriptType.py b/core/src/trezor/messages/MultisigRedeemScriptType.py index 9cfe4e4db1..95427f06f8 100644 --- a/core/src/trezor/messages/MultisigRedeemScriptType.py +++ b/core/src/trezor/messages/MultisigRedeemScriptType.py @@ -8,6 +8,7 @@ from .HDNodeType import HDNodeType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/NEMAddress.py b/core/src/trezor/messages/NEMAddress.py index 32eca1a483..ee61f6adb1 100644 --- a/core/src/trezor/messages/NEMAddress.py +++ b/core/src/trezor/messages/NEMAddress.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/NEMAggregateModification.py b/core/src/trezor/messages/NEMAggregateModification.py index bf28f7cb36..c61ffe72a2 100644 --- a/core/src/trezor/messages/NEMAggregateModification.py +++ b/core/src/trezor/messages/NEMAggregateModification.py @@ -7,6 +7,7 @@ from .NEMCosignatoryModification import NEMCosignatoryModification if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/NEMCosignatoryModification.py b/core/src/trezor/messages/NEMCosignatoryModification.py index 48071a5c25..173c45704c 100644 --- a/core/src/trezor/messages/NEMCosignatoryModification.py +++ b/core/src/trezor/messages/NEMCosignatoryModification.py @@ -5,15 +5,18 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypeNEMModificationType = Literal[1, 2] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeNEMModificationType = None # type: ignore class NEMCosignatoryModification(p.MessageType): def __init__( self, - type: int = None, + type: EnumTypeNEMModificationType = None, public_key: bytes = None, ) -> None: self.type = type @@ -22,6 +25,6 @@ class NEMCosignatoryModification(p.MessageType): @classmethod def get_fields(cls) -> Dict: return { - 1: ('type', p.UVarintType, 0), + 1: ('type', p.EnumType("NEMModificationType", (1, 2)), 0), 2: ('public_key', p.BytesType, 0), } diff --git a/core/src/trezor/messages/NEMGetAddress.py b/core/src/trezor/messages/NEMGetAddress.py index a79406d61e..f6bdc96cbb 100644 --- a/core/src/trezor/messages/NEMGetAddress.py +++ b/core/src/trezor/messages/NEMGetAddress.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/NEMImportanceTransfer.py b/core/src/trezor/messages/NEMImportanceTransfer.py index cea1490130..b9cd99617a 100644 --- a/core/src/trezor/messages/NEMImportanceTransfer.py +++ b/core/src/trezor/messages/NEMImportanceTransfer.py @@ -5,15 +5,18 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypeNEMImportanceTransferMode = Literal[1, 2] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeNEMImportanceTransferMode = None # type: ignore class NEMImportanceTransfer(p.MessageType): def __init__( self, - mode: int = None, + mode: EnumTypeNEMImportanceTransferMode = None, public_key: bytes = None, ) -> None: self.mode = mode @@ -22,6 +25,6 @@ class NEMImportanceTransfer(p.MessageType): @classmethod def get_fields(cls) -> Dict: return { - 1: ('mode', p.UVarintType, 0), + 1: ('mode', p.EnumType("NEMImportanceTransferMode", (1, 2)), 0), 2: ('public_key', p.BytesType, 0), } diff --git a/core/src/trezor/messages/NEMMosaic.py b/core/src/trezor/messages/NEMMosaic.py index 16365411d8..b67c930191 100644 --- a/core/src/trezor/messages/NEMMosaic.py +++ b/core/src/trezor/messages/NEMMosaic.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/NEMMosaicCreation.py b/core/src/trezor/messages/NEMMosaicCreation.py index 6c89b9a308..9e7dee307e 100644 --- a/core/src/trezor/messages/NEMMosaicCreation.py +++ b/core/src/trezor/messages/NEMMosaicCreation.py @@ -7,6 +7,7 @@ from .NEMMosaicDefinition import NEMMosaicDefinition if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/NEMMosaicDefinition.py b/core/src/trezor/messages/NEMMosaicDefinition.py index eb7621d8e2..626f50abda 100644 --- a/core/src/trezor/messages/NEMMosaicDefinition.py +++ b/core/src/trezor/messages/NEMMosaicDefinition.py @@ -5,8 +5,11 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypeNEMMosaicLevy = Literal[1, 2] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeNEMMosaicLevy = None # type: ignore class NEMMosaicDefinition(p.MessageType): @@ -18,7 +21,7 @@ class NEMMosaicDefinition(p.MessageType): namespace: str = None, mosaic: str = None, divisibility: int = None, - levy: int = None, + levy: EnumTypeNEMMosaicLevy = None, fee: int = None, levy_address: str = None, levy_namespace: str = None, @@ -53,7 +56,7 @@ class NEMMosaicDefinition(p.MessageType): 3: ('namespace', p.UnicodeType, 0), 4: ('mosaic', p.UnicodeType, 0), 5: ('divisibility', p.UVarintType, 0), - 6: ('levy', p.UVarintType, 0), + 6: ('levy', p.EnumType("NEMMosaicLevy", (1, 2)), 0), 7: ('fee', p.UVarintType, 0), 8: ('levy_address', p.UnicodeType, 0), 9: ('levy_namespace', p.UnicodeType, 0), diff --git a/core/src/trezor/messages/NEMMosaicSupplyChange.py b/core/src/trezor/messages/NEMMosaicSupplyChange.py index 6b470e56cd..abc88e677b 100644 --- a/core/src/trezor/messages/NEMMosaicSupplyChange.py +++ b/core/src/trezor/messages/NEMMosaicSupplyChange.py @@ -5,8 +5,11 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypeNEMSupplyChangeType = Literal[1, 2] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeNEMSupplyChangeType = None # type: ignore class NEMMosaicSupplyChange(p.MessageType): @@ -15,7 +18,7 @@ class NEMMosaicSupplyChange(p.MessageType): self, namespace: str = None, mosaic: str = None, - type: int = None, + type: EnumTypeNEMSupplyChangeType = None, delta: int = None, ) -> None: self.namespace = namespace @@ -28,6 +31,6 @@ class NEMMosaicSupplyChange(p.MessageType): return { 1: ('namespace', p.UnicodeType, 0), 2: ('mosaic', p.UnicodeType, 0), - 3: ('type', p.UVarintType, 0), + 3: ('type', p.EnumType("NEMSupplyChangeType", (1, 2)), 0), 4: ('delta', p.UVarintType, 0), } diff --git a/core/src/trezor/messages/NEMProvisionNamespace.py b/core/src/trezor/messages/NEMProvisionNamespace.py index e414e5ac4f..e62611983f 100644 --- a/core/src/trezor/messages/NEMProvisionNamespace.py +++ b/core/src/trezor/messages/NEMProvisionNamespace.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/NEMSignTx.py b/core/src/trezor/messages/NEMSignTx.py index 2cf517779f..6d9c16ee42 100644 --- a/core/src/trezor/messages/NEMSignTx.py +++ b/core/src/trezor/messages/NEMSignTx.py @@ -13,6 +13,7 @@ from .NEMTransfer import NEMTransfer if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/NEMSignedTx.py b/core/src/trezor/messages/NEMSignedTx.py index 420a37e7c7..141a2700ea 100644 --- a/core/src/trezor/messages/NEMSignedTx.py +++ b/core/src/trezor/messages/NEMSignedTx.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/NEMTransactionCommon.py b/core/src/trezor/messages/NEMTransactionCommon.py index 5c9dda5448..2fd9530868 100644 --- a/core/src/trezor/messages/NEMTransactionCommon.py +++ b/core/src/trezor/messages/NEMTransactionCommon.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/NEMTransfer.py b/core/src/trezor/messages/NEMTransfer.py index a878398225..581b71e76a 100644 --- a/core/src/trezor/messages/NEMTransfer.py +++ b/core/src/trezor/messages/NEMTransfer.py @@ -7,6 +7,7 @@ from .NEMMosaic import NEMMosaic if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/PassphraseAck.py b/core/src/trezor/messages/PassphraseAck.py index eb31e0c323..b9759316fa 100644 --- a/core/src/trezor/messages/PassphraseAck.py +++ b/core/src/trezor/messages/PassphraseAck.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/PassphraseRequest.py b/core/src/trezor/messages/PassphraseRequest.py index 4909858162..9cc415e9f0 100644 --- a/core/src/trezor/messages/PassphraseRequest.py +++ b/core/src/trezor/messages/PassphraseRequest.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/PassphraseStateAck.py b/core/src/trezor/messages/PassphraseStateAck.py index 19b0ecac3d..8b9005d913 100644 --- a/core/src/trezor/messages/PassphraseStateAck.py +++ b/core/src/trezor/messages/PassphraseStateAck.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/PassphraseStateRequest.py b/core/src/trezor/messages/PassphraseStateRequest.py index d269346164..6ac770a78d 100644 --- a/core/src/trezor/messages/PassphraseStateRequest.py +++ b/core/src/trezor/messages/PassphraseStateRequest.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/Ping.py b/core/src/trezor/messages/Ping.py index 16ef41c091..149244ee67 100644 --- a/core/src/trezor/messages/Ping.py +++ b/core/src/trezor/messages/Ping.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/PublicKey.py b/core/src/trezor/messages/PublicKey.py index 33d96ff105..b5f92b086c 100644 --- a/core/src/trezor/messages/PublicKey.py +++ b/core/src/trezor/messages/PublicKey.py @@ -7,6 +7,7 @@ from .HDNodeType import HDNodeType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/RecoveryDevice.py b/core/src/trezor/messages/RecoveryDevice.py index c4b4e3eece..e0eab7da21 100644 --- a/core/src/trezor/messages/RecoveryDevice.py +++ b/core/src/trezor/messages/RecoveryDevice.py @@ -5,8 +5,11 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypeRecoveryDeviceType = Literal[0, 1] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeRecoveryDeviceType = None # type: ignore class RecoveryDevice(p.MessageType): @@ -20,7 +23,7 @@ class RecoveryDevice(p.MessageType): language: str = None, label: str = None, enforce_wordlist: bool = None, - type: int = None, + type: EnumTypeRecoveryDeviceType = None, u2f_counter: int = None, dry_run: bool = None, ) -> None: @@ -43,7 +46,7 @@ class RecoveryDevice(p.MessageType): 4: ('language', p.UnicodeType, 0), # default=english 5: ('label', p.UnicodeType, 0), 6: ('enforce_wordlist', p.BoolType, 0), - 8: ('type', p.UVarintType, 0), + 8: ('type', p.EnumType("RecoveryDeviceType", (0, 1)), 0), 9: ('u2f_counter', p.UVarintType, 0), 10: ('dry_run', p.BoolType, 0), } diff --git a/core/src/trezor/messages/RecoveryDeviceType.py b/core/src/trezor/messages/RecoveryDeviceType.py new file mode 100644 index 0000000000..f6f643ac72 --- /dev/null +++ b/core/src/trezor/messages/RecoveryDeviceType.py @@ -0,0 +1,4 @@ +# Automatically generated by pb2py +# fmt: off +ScrambledWords = 0 +Matrix = 1 diff --git a/core/src/trezor/messages/ResetDevice.py b/core/src/trezor/messages/ResetDevice.py index f199dbc783..19a0047485 100644 --- a/core/src/trezor/messages/ResetDevice.py +++ b/core/src/trezor/messages/ResetDevice.py @@ -5,8 +5,11 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypeResetDeviceBackupType = Literal[0, 1, 2] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeResetDeviceBackupType = None # type: ignore class ResetDevice(p.MessageType): @@ -23,7 +26,7 @@ class ResetDevice(p.MessageType): u2f_counter: int = None, skip_backup: bool = None, no_backup: bool = None, - backup_type: int = None, + backup_type: EnumTypeResetDeviceBackupType = None, ) -> None: self.display_random = display_random self.strength = strength @@ -48,5 +51,5 @@ class ResetDevice(p.MessageType): 7: ('u2f_counter', p.UVarintType, 0), 8: ('skip_backup', p.BoolType, 0), 9: ('no_backup', p.BoolType, 0), - 10: ('backup_type', p.UVarintType, 0), # default=ResetDeviceBackupType_Bip39 + 10: ('backup_type', p.EnumType("ResetDeviceBackupType", (0, 1, 2)), 0), # default=ResetDeviceBackupType_Bip39 } diff --git a/core/src/trezor/messages/RippleAddress.py b/core/src/trezor/messages/RippleAddress.py index cee89e2d6a..f0f9a381b6 100644 --- a/core/src/trezor/messages/RippleAddress.py +++ b/core/src/trezor/messages/RippleAddress.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/RippleGetAddress.py b/core/src/trezor/messages/RippleGetAddress.py index f87550a566..728d81b9a1 100644 --- a/core/src/trezor/messages/RippleGetAddress.py +++ b/core/src/trezor/messages/RippleGetAddress.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/RipplePayment.py b/core/src/trezor/messages/RipplePayment.py index d7e8a9c4a2..3439a48569 100644 --- a/core/src/trezor/messages/RipplePayment.py +++ b/core/src/trezor/messages/RipplePayment.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/RippleSignTx.py b/core/src/trezor/messages/RippleSignTx.py index 025c7f2aed..0d34711448 100644 --- a/core/src/trezor/messages/RippleSignTx.py +++ b/core/src/trezor/messages/RippleSignTx.py @@ -7,6 +7,7 @@ from .RipplePayment import RipplePayment if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/RippleSignedTx.py b/core/src/trezor/messages/RippleSignedTx.py index 4f387e3208..933ef7286b 100644 --- a/core/src/trezor/messages/RippleSignedTx.py +++ b/core/src/trezor/messages/RippleSignedTx.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/SetU2FCounter.py b/core/src/trezor/messages/SetU2FCounter.py index 824e5538bb..6b80261a31 100644 --- a/core/src/trezor/messages/SetU2FCounter.py +++ b/core/src/trezor/messages/SetU2FCounter.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/SignIdentity.py b/core/src/trezor/messages/SignIdentity.py index 0e7c568d09..5674853cf0 100644 --- a/core/src/trezor/messages/SignIdentity.py +++ b/core/src/trezor/messages/SignIdentity.py @@ -7,6 +7,7 @@ from .IdentityType import IdentityType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/SignMessage.py b/core/src/trezor/messages/SignMessage.py index 89523c9da4..2e375f9524 100644 --- a/core/src/trezor/messages/SignMessage.py +++ b/core/src/trezor/messages/SignMessage.py @@ -5,8 +5,11 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypeInputScriptType = Literal[0, 1, 2, 3, 4] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeInputScriptType = None # type: ignore class SignMessage(p.MessageType): @@ -17,7 +20,7 @@ class SignMessage(p.MessageType): address_n: List[int] = None, message: bytes = None, coin_name: str = None, - script_type: int = None, + script_type: EnumTypeInputScriptType = None, ) -> None: self.address_n = address_n if address_n is not None else [] self.message = message @@ -30,5 +33,5 @@ class SignMessage(p.MessageType): 1: ('address_n', p.UVarintType, p.FLAG_REPEATED), 2: ('message', p.BytesType, 0), # required 3: ('coin_name', p.UnicodeType, 0), # default=Bitcoin - 4: ('script_type', p.UVarintType, 0), # default=SPENDADDRESS + 4: ('script_type', p.EnumType("InputScriptType", (0, 1, 2, 3, 4)), 0), # default=SPENDADDRESS } diff --git a/core/src/trezor/messages/SignTx.py b/core/src/trezor/messages/SignTx.py index 13afa4ada7..e1ae2148a2 100644 --- a/core/src/trezor/messages/SignTx.py +++ b/core/src/trezor/messages/SignTx.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/SignedIdentity.py b/core/src/trezor/messages/SignedIdentity.py index 7901a35677..009023df2c 100644 --- a/core/src/trezor/messages/SignedIdentity.py +++ b/core/src/trezor/messages/SignedIdentity.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/StellarAccountMergeOp.py b/core/src/trezor/messages/StellarAccountMergeOp.py index e050262124..8f8cd24d03 100644 --- a/core/src/trezor/messages/StellarAccountMergeOp.py +++ b/core/src/trezor/messages/StellarAccountMergeOp.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/StellarAddress.py b/core/src/trezor/messages/StellarAddress.py index 335e649e28..c2a6aba497 100644 --- a/core/src/trezor/messages/StellarAddress.py +++ b/core/src/trezor/messages/StellarAddress.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/StellarAllowTrustOp.py b/core/src/trezor/messages/StellarAllowTrustOp.py index c06850cecb..a49a7b0796 100644 --- a/core/src/trezor/messages/StellarAllowTrustOp.py +++ b/core/src/trezor/messages/StellarAllowTrustOp.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/StellarAssetType.py b/core/src/trezor/messages/StellarAssetType.py index f2f31d78c8..686c1c5361 100644 --- a/core/src/trezor/messages/StellarAssetType.py +++ b/core/src/trezor/messages/StellarAssetType.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/StellarBumpSequenceOp.py b/core/src/trezor/messages/StellarBumpSequenceOp.py index e1fee89a88..5d06c35a63 100644 --- a/core/src/trezor/messages/StellarBumpSequenceOp.py +++ b/core/src/trezor/messages/StellarBumpSequenceOp.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/StellarChangeTrustOp.py b/core/src/trezor/messages/StellarChangeTrustOp.py index 7add58d1da..c010123b58 100644 --- a/core/src/trezor/messages/StellarChangeTrustOp.py +++ b/core/src/trezor/messages/StellarChangeTrustOp.py @@ -7,6 +7,7 @@ from .StellarAssetType import StellarAssetType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/StellarCreateAccountOp.py b/core/src/trezor/messages/StellarCreateAccountOp.py index 35a0bfbda3..aa3020cc8f 100644 --- a/core/src/trezor/messages/StellarCreateAccountOp.py +++ b/core/src/trezor/messages/StellarCreateAccountOp.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/StellarCreatePassiveOfferOp.py b/core/src/trezor/messages/StellarCreatePassiveOfferOp.py index 50d8b00529..3a695d5e11 100644 --- a/core/src/trezor/messages/StellarCreatePassiveOfferOp.py +++ b/core/src/trezor/messages/StellarCreatePassiveOfferOp.py @@ -7,6 +7,7 @@ from .StellarAssetType import StellarAssetType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/StellarGetAddress.py b/core/src/trezor/messages/StellarGetAddress.py index 188cbf65ad..1771c73536 100644 --- a/core/src/trezor/messages/StellarGetAddress.py +++ b/core/src/trezor/messages/StellarGetAddress.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/StellarManageDataOp.py b/core/src/trezor/messages/StellarManageDataOp.py index 833e102511..b04e039469 100644 --- a/core/src/trezor/messages/StellarManageDataOp.py +++ b/core/src/trezor/messages/StellarManageDataOp.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/StellarManageOfferOp.py b/core/src/trezor/messages/StellarManageOfferOp.py index 1e8ce26b81..e72024861c 100644 --- a/core/src/trezor/messages/StellarManageOfferOp.py +++ b/core/src/trezor/messages/StellarManageOfferOp.py @@ -7,6 +7,7 @@ from .StellarAssetType import StellarAssetType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/StellarPathPaymentOp.py b/core/src/trezor/messages/StellarPathPaymentOp.py index 8e1aae97af..6614b0166b 100644 --- a/core/src/trezor/messages/StellarPathPaymentOp.py +++ b/core/src/trezor/messages/StellarPathPaymentOp.py @@ -7,6 +7,7 @@ from .StellarAssetType import StellarAssetType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/StellarPaymentOp.py b/core/src/trezor/messages/StellarPaymentOp.py index afbd51e41e..b176023541 100644 --- a/core/src/trezor/messages/StellarPaymentOp.py +++ b/core/src/trezor/messages/StellarPaymentOp.py @@ -7,6 +7,7 @@ from .StellarAssetType import StellarAssetType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/StellarSetOptionsOp.py b/core/src/trezor/messages/StellarSetOptionsOp.py index 643355b019..cfa6b7d24b 100644 --- a/core/src/trezor/messages/StellarSetOptionsOp.py +++ b/core/src/trezor/messages/StellarSetOptionsOp.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/StellarSignTx.py b/core/src/trezor/messages/StellarSignTx.py index 3debc1e6d2..148b2a5e1c 100644 --- a/core/src/trezor/messages/StellarSignTx.py +++ b/core/src/trezor/messages/StellarSignTx.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/StellarSignedTx.py b/core/src/trezor/messages/StellarSignedTx.py index 17d808de21..e5a62fcdfd 100644 --- a/core/src/trezor/messages/StellarSignedTx.py +++ b/core/src/trezor/messages/StellarSignedTx.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/StellarTxOpRequest.py b/core/src/trezor/messages/StellarTxOpRequest.py index 5054aaa697..e4d91f74c9 100644 --- a/core/src/trezor/messages/StellarTxOpRequest.py +++ b/core/src/trezor/messages/StellarTxOpRequest.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/Success.py b/core/src/trezor/messages/Success.py index c31f248883..46984b8785 100644 --- a/core/src/trezor/messages/Success.py +++ b/core/src/trezor/messages/Success.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/TezosAddress.py b/core/src/trezor/messages/TezosAddress.py index def8fac1d1..9e16b6d506 100644 --- a/core/src/trezor/messages/TezosAddress.py +++ b/core/src/trezor/messages/TezosAddress.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/TezosBallotOp.py b/core/src/trezor/messages/TezosBallotOp.py index 1de65b89fa..b71a7a1470 100644 --- a/core/src/trezor/messages/TezosBallotOp.py +++ b/core/src/trezor/messages/TezosBallotOp.py @@ -5,8 +5,11 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypeTezosBallotType = Literal[0, 1, 2] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeTezosBallotType = None # type: ignore class TezosBallotOp(p.MessageType): @@ -16,7 +19,7 @@ class TezosBallotOp(p.MessageType): source: bytes = None, period: int = None, proposal: bytes = None, - ballot: int = None, + ballot: EnumTypeTezosBallotType = None, ) -> None: self.source = source self.period = period @@ -29,5 +32,5 @@ class TezosBallotOp(p.MessageType): 1: ('source', p.BytesType, 0), 2: ('period', p.UVarintType, 0), 3: ('proposal', p.BytesType, 0), - 4: ('ballot', p.UVarintType, 0), + 4: ('ballot', p.EnumType("TezosBallotType", (0, 1, 2)), 0), } diff --git a/core/src/trezor/messages/TezosContractID.py b/core/src/trezor/messages/TezosContractID.py index 4f4693f0c6..57bccee411 100644 --- a/core/src/trezor/messages/TezosContractID.py +++ b/core/src/trezor/messages/TezosContractID.py @@ -5,15 +5,18 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypeTezosContractType = Literal[0, 1] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeTezosContractType = None # type: ignore class TezosContractID(p.MessageType): def __init__( self, - tag: int = None, + tag: EnumTypeTezosContractType = None, hash: bytes = None, ) -> None: self.tag = tag @@ -22,6 +25,6 @@ class TezosContractID(p.MessageType): @classmethod def get_fields(cls) -> Dict: return { - 1: ('tag', p.UVarintType, 0), + 1: ('tag', p.EnumType("TezosContractType", (0, 1)), 0), 2: ('hash', p.BytesType, 0), } diff --git a/core/src/trezor/messages/TezosDelegationOp.py b/core/src/trezor/messages/TezosDelegationOp.py index b316c20f36..238845ac6c 100644 --- a/core/src/trezor/messages/TezosDelegationOp.py +++ b/core/src/trezor/messages/TezosDelegationOp.py @@ -7,6 +7,7 @@ from .TezosContractID import TezosContractID if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/TezosGetAddress.py b/core/src/trezor/messages/TezosGetAddress.py index 893a2e7b62..78904b690f 100644 --- a/core/src/trezor/messages/TezosGetAddress.py +++ b/core/src/trezor/messages/TezosGetAddress.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/TezosGetPublicKey.py b/core/src/trezor/messages/TezosGetPublicKey.py index 8821c74a7c..96fff888c9 100644 --- a/core/src/trezor/messages/TezosGetPublicKey.py +++ b/core/src/trezor/messages/TezosGetPublicKey.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/TezosOriginationOp.py b/core/src/trezor/messages/TezosOriginationOp.py index a2384b6011..a4c332ef4a 100644 --- a/core/src/trezor/messages/TezosOriginationOp.py +++ b/core/src/trezor/messages/TezosOriginationOp.py @@ -7,6 +7,7 @@ from .TezosContractID import TezosContractID if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/TezosProposalOp.py b/core/src/trezor/messages/TezosProposalOp.py index 625c76cb36..1c651b8ac4 100644 --- a/core/src/trezor/messages/TezosProposalOp.py +++ b/core/src/trezor/messages/TezosProposalOp.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/TezosPublicKey.py b/core/src/trezor/messages/TezosPublicKey.py index 6301f44ef6..a697f82e0e 100644 --- a/core/src/trezor/messages/TezosPublicKey.py +++ b/core/src/trezor/messages/TezosPublicKey.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/TezosRevealOp.py b/core/src/trezor/messages/TezosRevealOp.py index 6297ef3bda..3691322b95 100644 --- a/core/src/trezor/messages/TezosRevealOp.py +++ b/core/src/trezor/messages/TezosRevealOp.py @@ -7,6 +7,7 @@ from .TezosContractID import TezosContractID if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/TezosSignTx.py b/core/src/trezor/messages/TezosSignTx.py index 4805bfae1f..308ed70c32 100644 --- a/core/src/trezor/messages/TezosSignTx.py +++ b/core/src/trezor/messages/TezosSignTx.py @@ -12,6 +12,7 @@ from .TezosTransactionOp import TezosTransactionOp if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/TezosSignedTx.py b/core/src/trezor/messages/TezosSignedTx.py index cc594338bd..011e6855a7 100644 --- a/core/src/trezor/messages/TezosSignedTx.py +++ b/core/src/trezor/messages/TezosSignedTx.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/TezosTransactionOp.py b/core/src/trezor/messages/TezosTransactionOp.py index a7e20cb92e..370bd3a127 100644 --- a/core/src/trezor/messages/TezosTransactionOp.py +++ b/core/src/trezor/messages/TezosTransactionOp.py @@ -7,6 +7,7 @@ from .TezosContractID import TezosContractID if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/TransactionType.py b/core/src/trezor/messages/TransactionType.py index ee57d464cd..cdcdb5b464 100644 --- a/core/src/trezor/messages/TransactionType.py +++ b/core/src/trezor/messages/TransactionType.py @@ -9,6 +9,7 @@ from .TxOutputType import TxOutputType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/TxAck.py b/core/src/trezor/messages/TxAck.py index 7940504841..5015e9b08b 100644 --- a/core/src/trezor/messages/TxAck.py +++ b/core/src/trezor/messages/TxAck.py @@ -7,6 +7,7 @@ from .TransactionType import TransactionType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/TxInputType.py b/core/src/trezor/messages/TxInputType.py index 552c93bad0..c089d4a6e4 100644 --- a/core/src/trezor/messages/TxInputType.py +++ b/core/src/trezor/messages/TxInputType.py @@ -7,8 +7,11 @@ from .MultisigRedeemScriptType import MultisigRedeemScriptType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypeInputScriptType = Literal[0, 1, 2, 3, 4] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeInputScriptType = None # type: ignore class TxInputType(p.MessageType): @@ -20,7 +23,7 @@ class TxInputType(p.MessageType): prev_index: int = None, script_sig: bytes = None, sequence: int = None, - script_type: int = None, + script_type: EnumTypeInputScriptType = None, multisig: MultisigRedeemScriptType = None, amount: int = None, decred_tree: int = None, @@ -49,7 +52,7 @@ class TxInputType(p.MessageType): 3: ('prev_index', p.UVarintType, 0), # required 4: ('script_sig', p.BytesType, 0), 5: ('sequence', p.UVarintType, 0), # default=4294967295 - 6: ('script_type', p.UVarintType, 0), # default=SPENDADDRESS + 6: ('script_type', p.EnumType("InputScriptType", (0, 1, 2, 3, 4)), 0), # default=SPENDADDRESS 7: ('multisig', MultisigRedeemScriptType, 0), 8: ('amount', p.UVarintType, 0), 9: ('decred_tree', p.UVarintType, 0), diff --git a/core/src/trezor/messages/TxOutputBinType.py b/core/src/trezor/messages/TxOutputBinType.py index 31e8ee4254..8a8744217b 100644 --- a/core/src/trezor/messages/TxOutputBinType.py +++ b/core/src/trezor/messages/TxOutputBinType.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/TxOutputType.py b/core/src/trezor/messages/TxOutputType.py index d4047e9ec2..e1f271f62e 100644 --- a/core/src/trezor/messages/TxOutputType.py +++ b/core/src/trezor/messages/TxOutputType.py @@ -7,8 +7,11 @@ from .MultisigRedeemScriptType import MultisigRedeemScriptType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypeOutputScriptType = Literal[0, 1, 2, 3, 4, 5] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeOutputScriptType = None # type: ignore class TxOutputType(p.MessageType): @@ -18,7 +21,7 @@ class TxOutputType(p.MessageType): address: str = None, address_n: List[int] = None, amount: int = None, - script_type: int = None, + script_type: EnumTypeOutputScriptType = None, multisig: MultisigRedeemScriptType = None, op_return_data: bytes = None, decred_script_version: int = None, @@ -41,7 +44,7 @@ class TxOutputType(p.MessageType): 1: ('address', p.UnicodeType, 0), 2: ('address_n', p.UVarintType, p.FLAG_REPEATED), 3: ('amount', p.UVarintType, 0), # required - 4: ('script_type', p.UVarintType, 0), # required + 4: ('script_type', p.EnumType("OutputScriptType", (0, 1, 2, 3, 4, 5)), 0), # required 5: ('multisig', MultisigRedeemScriptType, 0), 6: ('op_return_data', p.BytesType, 0), 7: ('decred_script_version', p.UVarintType, 0), diff --git a/core/src/trezor/messages/TxRequest.py b/core/src/trezor/messages/TxRequest.py index 3501a13e46..0c8a4d4396 100644 --- a/core/src/trezor/messages/TxRequest.py +++ b/core/src/trezor/messages/TxRequest.py @@ -8,8 +8,11 @@ from .TxRequestSerializedType import TxRequestSerializedType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypeRequestType = Literal[0, 1, 2, 3, 4] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeRequestType = None # type: ignore class TxRequest(p.MessageType): @@ -17,7 +20,7 @@ class TxRequest(p.MessageType): def __init__( self, - request_type: int = None, + request_type: EnumTypeRequestType = None, details: TxRequestDetailsType = None, serialized: TxRequestSerializedType = None, ) -> None: @@ -28,7 +31,7 @@ class TxRequest(p.MessageType): @classmethod def get_fields(cls) -> Dict: return { - 1: ('request_type', p.UVarintType, 0), + 1: ('request_type', p.EnumType("RequestType", (0, 1, 2, 3, 4)), 0), 2: ('details', TxRequestDetailsType, 0), 3: ('serialized', TxRequestSerializedType, 0), } diff --git a/core/src/trezor/messages/TxRequestDetailsType.py b/core/src/trezor/messages/TxRequestDetailsType.py index db18767d8b..31df83363b 100644 --- a/core/src/trezor/messages/TxRequestDetailsType.py +++ b/core/src/trezor/messages/TxRequestDetailsType.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/TxRequestSerializedType.py b/core/src/trezor/messages/TxRequestSerializedType.py index 4543aa7669..aa92bd3dc1 100644 --- a/core/src/trezor/messages/TxRequestSerializedType.py +++ b/core/src/trezor/messages/TxRequestSerializedType.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/VerifyMessage.py b/core/src/trezor/messages/VerifyMessage.py index 8905047044..6527f2bad4 100644 --- a/core/src/trezor/messages/VerifyMessage.py +++ b/core/src/trezor/messages/VerifyMessage.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/src/trezor/messages/WipeDevice.py b/core/src/trezor/messages/WipeDevice.py index 29a4db15ac..4557d2f302 100644 --- a/core/src/trezor/messages/WipeDevice.py +++ b/core/src/trezor/messages/WipeDevice.py @@ -5,6 +5,7 @@ import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/core/tests/test_protobuf.py b/core/tests/test_protobuf.py new file mode 100644 index 0000000000..d362401e52 --- /dev/null +++ b/core/tests/test_protobuf.py @@ -0,0 +1,126 @@ +from common import * + +import protobuf + +if False: + from typing import Awaitable, Dict + + +class Message(protobuf.MessageType): + def __init__(self, uint_field: int = 0, enum_field: int = 0) -> None: + self.sint_field = uint_field + self.enum_field = enum_field + + @classmethod + def get_fields(cls) -> Dict: + return { + 1: ("sint_field", protobuf.SVarintType, 0), + 2: ("enum_field", protobuf.EnumType("t", (0, 5, 25)), 0), + } + + +class ByteReader: + def __init__(self, data: bytes) -> None: + self.data = data + self.pos = 0 + + async def areadinto(self, buf: bytearray) -> int: + remaining = len(self.data) - self.pos + limit = len(buf) + if remaining < limit: + raise EOFError + + buf[:] = self.data[self.pos : self.pos + limit] + self.pos += limit + return limit + + +class ByteArrayWriter: + def __init__(self) -> None: + self.buf = bytearray(0) + + async def awrite(self, buf: bytes) -> int: + self.buf.extend(buf) + return len(buf) + + +def run_until_complete(task: Awaitable) -> Any: + value = None + while True: + try: + result = task.send(value) + except StopIteration as e: + return e.value + + if result: + value = run_until_complete(result) + else: + value = None + + +def load_uvarint(data: bytes) -> int: + reader = ByteReader(data) + return run_until_complete(protobuf.load_uvarint(reader)) + + +def dump_uvarint(value: int) -> bytearray: + writer = ByteArrayWriter() + run_until_complete(protobuf.dump_uvarint(writer, value)) + return writer.buf + + +class TestProtobuf(unittest.TestCase): + def test_dump_uvarint(self): + self.assertEqual(dump_uvarint(0), b"\x00") + self.assertEqual(dump_uvarint(1), b"\x01") + self.assertEqual(dump_uvarint(0xFF), b"\xff\x01") + self.assertEqual(dump_uvarint(123456), b"\xc0\xc4\x07") + with self.assertRaises(ValueError): + dump_uvarint(-1) + + def test_load_uvarint(self): + self.assertEqual(load_uvarint(b"\x00"), 0) + self.assertEqual(load_uvarint(b"\x01"), 1) + self.assertEqual(load_uvarint(b"\xff\x01"), 0xFF) + self.assertEqual(load_uvarint(b"\xc0\xc4\x07"), 123456) + + def test_sint_uint(self): + self.assertEqual(protobuf.uint_to_sint(0), 0) + self.assertEqual(protobuf.sint_to_uint(0), 0) + + self.assertEqual(protobuf.sint_to_uint(-1), 1) + self.assertEqual(protobuf.sint_to_uint(1), 2) + + self.assertEqual(protobuf.uint_to_sint(1), -1) + self.assertEqual(protobuf.uint_to_sint(2), 1) + + # roundtrip: + self.assertEqual( + protobuf.uint_to_sint(protobuf.sint_to_uint(1234567891011)), 1234567891011 + ) + self.assertEqual( + protobuf.uint_to_sint(protobuf.sint_to_uint(-2 ** 32)), -2 ** 32 + ) + + def test_validate_enum(self): + # ok message: + msg = Message(-42, 5) + writer = ByteArrayWriter() + run_until_complete(protobuf.dump_message(writer, msg)) + reader = ByteReader(bytes(writer.buf)) + nmsg = run_until_complete(protobuf.load_message(reader, Message)) + + self.assertEqual(msg.sint_field, nmsg.sint_field) + self.assertEqual(msg.enum_field, nmsg.enum_field) + + # bad enum value: + msg = Message(-42, 42) + writer = ByteArrayWriter() + run_until_complete(protobuf.dump_message(writer, msg)) + reader = ByteReader(bytes(writer.buf)) + with self.assertRaises(TypeError): + run_until_complete(protobuf.load_message(reader, Message)) + + +if __name__ == "__main__": + unittest.main() diff --git a/python/setup.cfg b/python/setup.cfg index ac9615bb9b..aa83c9ca88 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -32,5 +32,5 @@ combine_as_imports = True line_length = 88 not_skip=__init__.py known_first_party=trezorlib -known_third_party=hidapi, rlp, ethjsonrpc, ecdsa, mnemonic, shamir-mnemonic, requests, click, pyblake2, \ +known_third_party=hidapi, rlp, ethjsonrpc, ecdsa, mnemonic, shamir_mnemonic, requests, click, pyblake2, \ usb, construct, pytest diff --git a/python/trezorlib/messages/Address.py b/python/trezorlib/messages/Address.py index e0e044682f..4e8abf7943 100644 --- a/python/trezorlib/messages/Address.py +++ b/python/trezorlib/messages/Address.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/ApplyFlags.py b/python/trezorlib/messages/ApplyFlags.py index bcab4af8e0..b6f5bc614a 100644 --- a/python/trezorlib/messages/ApplyFlags.py +++ b/python/trezorlib/messages/ApplyFlags.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/ApplySettings.py b/python/trezorlib/messages/ApplySettings.py index decf13abfe..4e51d6b283 100644 --- a/python/trezorlib/messages/ApplySettings.py +++ b/python/trezorlib/messages/ApplySettings.py @@ -5,8 +5,11 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypePassphraseSourceType = Literal[0, 1, 2] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypePassphraseSourceType = None # type: ignore class ApplySettings(p.MessageType): @@ -18,7 +21,7 @@ class ApplySettings(p.MessageType): label: str = None, use_passphrase: bool = None, homescreen: bytes = None, - passphrase_source: int = None, + passphrase_source: EnumTypePassphraseSourceType = None, auto_lock_delay_ms: int = None, display_rotation: int = None, ) -> None: @@ -37,7 +40,7 @@ class ApplySettings(p.MessageType): 2: ('label', p.UnicodeType, 0), 3: ('use_passphrase', p.BoolType, 0), 4: ('homescreen', p.BytesType, 0), - 5: ('passphrase_source', p.UVarintType, 0), + 5: ('passphrase_source', p.EnumType("PassphraseSourceType", (0, 1, 2)), 0), 6: ('auto_lock_delay_ms', p.UVarintType, 0), 7: ('display_rotation', p.UVarintType, 0), } diff --git a/python/trezorlib/messages/BackupDevice.py b/python/trezorlib/messages/BackupDevice.py index f213229938..f7a13b4f97 100644 --- a/python/trezorlib/messages/BackupDevice.py +++ b/python/trezorlib/messages/BackupDevice.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/BinanceAddress.py b/python/trezorlib/messages/BinanceAddress.py index 39080a2c2e..727d2bfd05 100644 --- a/python/trezorlib/messages/BinanceAddress.py +++ b/python/trezorlib/messages/BinanceAddress.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/BinanceCancelMsg.py b/python/trezorlib/messages/BinanceCancelMsg.py index ebee76997d..72b9a570f7 100644 --- a/python/trezorlib/messages/BinanceCancelMsg.py +++ b/python/trezorlib/messages/BinanceCancelMsg.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/BinanceCoin.py b/python/trezorlib/messages/BinanceCoin.py index 73d520b4e9..c40fc848a4 100644 --- a/python/trezorlib/messages/BinanceCoin.py +++ b/python/trezorlib/messages/BinanceCoin.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/BinanceGetAddress.py b/python/trezorlib/messages/BinanceGetAddress.py index 6cdb1cf795..be51033c32 100644 --- a/python/trezorlib/messages/BinanceGetAddress.py +++ b/python/trezorlib/messages/BinanceGetAddress.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/BinanceGetPublicKey.py b/python/trezorlib/messages/BinanceGetPublicKey.py index e2c884e22f..574879f89d 100644 --- a/python/trezorlib/messages/BinanceGetPublicKey.py +++ b/python/trezorlib/messages/BinanceGetPublicKey.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/BinanceInputOutput.py b/python/trezorlib/messages/BinanceInputOutput.py index a5e7ef5649..c9148b6b14 100644 --- a/python/trezorlib/messages/BinanceInputOutput.py +++ b/python/trezorlib/messages/BinanceInputOutput.py @@ -7,6 +7,7 @@ from .BinanceCoin import BinanceCoin if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/BinanceOrderMsg.py b/python/trezorlib/messages/BinanceOrderMsg.py index b1ed10b95d..81950477fe 100644 --- a/python/trezorlib/messages/BinanceOrderMsg.py +++ b/python/trezorlib/messages/BinanceOrderMsg.py @@ -5,8 +5,15 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypeBinanceOrderType = Literal[0, 1, 2, 3] + EnumTypeBinanceOrderSide = Literal[0, 1, 2] + EnumTypeBinanceTimeInForce = Literal[0, 1, 2, 3] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeBinanceOrderType = None # type: ignore + EnumTypeBinanceOrderSide = None # type: ignore + EnumTypeBinanceTimeInForce = None # type: ignore class BinanceOrderMsg(p.MessageType): @@ -15,13 +22,13 @@ class BinanceOrderMsg(p.MessageType): def __init__( self, id: str = None, - ordertype: int = None, + ordertype: EnumTypeBinanceOrderType = None, price: int = None, quantity: int = None, sender: str = None, - side: int = None, + side: EnumTypeBinanceOrderSide = None, symbol: str = None, - timeinforce: int = None, + timeinforce: EnumTypeBinanceTimeInForce = None, ) -> None: self.id = id self.ordertype = ordertype @@ -36,11 +43,11 @@ class BinanceOrderMsg(p.MessageType): def get_fields(cls) -> Dict: return { 1: ('id', p.UnicodeType, 0), - 2: ('ordertype', p.UVarintType, 0), + 2: ('ordertype', p.EnumType("BinanceOrderType", (0, 1, 2, 3)), 0), 3: ('price', p.SVarintType, 0), 4: ('quantity', p.SVarintType, 0), 5: ('sender', p.UnicodeType, 0), - 6: ('side', p.UVarintType, 0), + 6: ('side', p.EnumType("BinanceOrderSide", (0, 1, 2)), 0), 7: ('symbol', p.UnicodeType, 0), - 8: ('timeinforce', p.UVarintType, 0), + 8: ('timeinforce', p.EnumType("BinanceTimeInForce", (0, 1, 2, 3)), 0), } diff --git a/python/trezorlib/messages/BinancePublicKey.py b/python/trezorlib/messages/BinancePublicKey.py index aec6a131e9..ad6ee462b0 100644 --- a/python/trezorlib/messages/BinancePublicKey.py +++ b/python/trezorlib/messages/BinancePublicKey.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/BinanceSignTx.py b/python/trezorlib/messages/BinanceSignTx.py index 1c70407fb4..1738e85002 100644 --- a/python/trezorlib/messages/BinanceSignTx.py +++ b/python/trezorlib/messages/BinanceSignTx.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/BinanceSignedTx.py b/python/trezorlib/messages/BinanceSignedTx.py index ef7cc918b7..00eeaea11c 100644 --- a/python/trezorlib/messages/BinanceSignedTx.py +++ b/python/trezorlib/messages/BinanceSignedTx.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/BinanceTransferMsg.py b/python/trezorlib/messages/BinanceTransferMsg.py index ed71097033..c932b56d19 100644 --- a/python/trezorlib/messages/BinanceTransferMsg.py +++ b/python/trezorlib/messages/BinanceTransferMsg.py @@ -7,6 +7,7 @@ from .BinanceInputOutput import BinanceInputOutput if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/BinanceTxRequest.py b/python/trezorlib/messages/BinanceTxRequest.py index 1ff248a5a5..b9b7b69748 100644 --- a/python/trezorlib/messages/BinanceTxRequest.py +++ b/python/trezorlib/messages/BinanceTxRequest.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/ButtonAck.py b/python/trezorlib/messages/ButtonAck.py index c3be23de80..db823052e5 100644 --- a/python/trezorlib/messages/ButtonAck.py +++ b/python/trezorlib/messages/ButtonAck.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/ButtonRequest.py b/python/trezorlib/messages/ButtonRequest.py index 594b91000a..496ecc494c 100644 --- a/python/trezorlib/messages/ButtonRequest.py +++ b/python/trezorlib/messages/ButtonRequest.py @@ -5,8 +5,11 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypeButtonRequestType = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeButtonRequestType = None # type: ignore class ButtonRequest(p.MessageType): @@ -14,7 +17,7 @@ class ButtonRequest(p.MessageType): def __init__( self, - code: int = None, + code: EnumTypeButtonRequestType = None, data: str = None, ) -> None: self.code = code @@ -23,6 +26,6 @@ class ButtonRequest(p.MessageType): @classmethod def get_fields(cls) -> Dict: return { - 1: ('code', p.UVarintType, 0), + 1: ('code', p.EnumType("ButtonRequestType", (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18)), 0), 2: ('data', p.UnicodeType, 0), } diff --git a/python/trezorlib/messages/Cancel.py b/python/trezorlib/messages/Cancel.py index 7dc5faef69..d8c2d99194 100644 --- a/python/trezorlib/messages/Cancel.py +++ b/python/trezorlib/messages/Cancel.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/CardanoAddress.py b/python/trezorlib/messages/CardanoAddress.py index fff3da0e0a..c0e46006a0 100644 --- a/python/trezorlib/messages/CardanoAddress.py +++ b/python/trezorlib/messages/CardanoAddress.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/CardanoGetAddress.py b/python/trezorlib/messages/CardanoGetAddress.py index 966bc8dc0f..0c383f4c8a 100644 --- a/python/trezorlib/messages/CardanoGetAddress.py +++ b/python/trezorlib/messages/CardanoGetAddress.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/CardanoGetPublicKey.py b/python/trezorlib/messages/CardanoGetPublicKey.py index c5af666f01..b8bcc43268 100644 --- a/python/trezorlib/messages/CardanoGetPublicKey.py +++ b/python/trezorlib/messages/CardanoGetPublicKey.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/CardanoPublicKey.py b/python/trezorlib/messages/CardanoPublicKey.py index 7347270bdb..9e66438315 100644 --- a/python/trezorlib/messages/CardanoPublicKey.py +++ b/python/trezorlib/messages/CardanoPublicKey.py @@ -7,6 +7,7 @@ from .HDNodeType import HDNodeType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/CardanoSignTx.py b/python/trezorlib/messages/CardanoSignTx.py index fa54a42924..a6e99ec4b8 100644 --- a/python/trezorlib/messages/CardanoSignTx.py +++ b/python/trezorlib/messages/CardanoSignTx.py @@ -8,6 +8,7 @@ from .CardanoTxOutputType import CardanoTxOutputType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/CardanoSignedTx.py b/python/trezorlib/messages/CardanoSignedTx.py index b9404bbaf8..17734a546e 100644 --- a/python/trezorlib/messages/CardanoSignedTx.py +++ b/python/trezorlib/messages/CardanoSignedTx.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/CardanoTxAck.py b/python/trezorlib/messages/CardanoTxAck.py index 98af0d64e4..f96f80c5fa 100644 --- a/python/trezorlib/messages/CardanoTxAck.py +++ b/python/trezorlib/messages/CardanoTxAck.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/CardanoTxInputType.py b/python/trezorlib/messages/CardanoTxInputType.py index 5c4988b856..20f14d26ae 100644 --- a/python/trezorlib/messages/CardanoTxInputType.py +++ b/python/trezorlib/messages/CardanoTxInputType.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/CardanoTxOutputType.py b/python/trezorlib/messages/CardanoTxOutputType.py index 521e083b72..def6586378 100644 --- a/python/trezorlib/messages/CardanoTxOutputType.py +++ b/python/trezorlib/messages/CardanoTxOutputType.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/CardanoTxRequest.py b/python/trezorlib/messages/CardanoTxRequest.py index 0c5e18505f..09adf95bca 100644 --- a/python/trezorlib/messages/CardanoTxRequest.py +++ b/python/trezorlib/messages/CardanoTxRequest.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/ChangePin.py b/python/trezorlib/messages/ChangePin.py index f2bc637759..87f3cd0464 100644 --- a/python/trezorlib/messages/ChangePin.py +++ b/python/trezorlib/messages/ChangePin.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/CipherKeyValue.py b/python/trezorlib/messages/CipherKeyValue.py index 039601d53a..fb33434cd8 100644 --- a/python/trezorlib/messages/CipherKeyValue.py +++ b/python/trezorlib/messages/CipherKeyValue.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/CipheredKeyValue.py b/python/trezorlib/messages/CipheredKeyValue.py index c6dac0908b..ca7a3bc828 100644 --- a/python/trezorlib/messages/CipheredKeyValue.py +++ b/python/trezorlib/messages/CipheredKeyValue.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/ClearSession.py b/python/trezorlib/messages/ClearSession.py index 39d6013101..defc7e6371 100644 --- a/python/trezorlib/messages/ClearSession.py +++ b/python/trezorlib/messages/ClearSession.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/CosiCommit.py b/python/trezorlib/messages/CosiCommit.py index e7e93ea2d9..b122b21da2 100644 --- a/python/trezorlib/messages/CosiCommit.py +++ b/python/trezorlib/messages/CosiCommit.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/CosiCommitment.py b/python/trezorlib/messages/CosiCommitment.py index e674f08af7..d1bf4d17a3 100644 --- a/python/trezorlib/messages/CosiCommitment.py +++ b/python/trezorlib/messages/CosiCommitment.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/CosiSign.py b/python/trezorlib/messages/CosiSign.py index 8681ae4a65..ef0c956a00 100644 --- a/python/trezorlib/messages/CosiSign.py +++ b/python/trezorlib/messages/CosiSign.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/CosiSignature.py b/python/trezorlib/messages/CosiSignature.py index 40601bf6f9..71e9cf7b18 100644 --- a/python/trezorlib/messages/CosiSignature.py +++ b/python/trezorlib/messages/CosiSignature.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/DebugLinkDecision.py b/python/trezorlib/messages/DebugLinkDecision.py index fc4b62e873..cf68770a1e 100644 --- a/python/trezorlib/messages/DebugLinkDecision.py +++ b/python/trezorlib/messages/DebugLinkDecision.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/DebugLinkFlashErase.py b/python/trezorlib/messages/DebugLinkFlashErase.py index a38d5920b0..f65f0a7ffa 100644 --- a/python/trezorlib/messages/DebugLinkFlashErase.py +++ b/python/trezorlib/messages/DebugLinkFlashErase.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/DebugLinkGetState.py b/python/trezorlib/messages/DebugLinkGetState.py index cd07b8fa82..f4c24df7c0 100644 --- a/python/trezorlib/messages/DebugLinkGetState.py +++ b/python/trezorlib/messages/DebugLinkGetState.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/DebugLinkLog.py b/python/trezorlib/messages/DebugLinkLog.py index 11fa63b8ed..279d4630a1 100644 --- a/python/trezorlib/messages/DebugLinkLog.py +++ b/python/trezorlib/messages/DebugLinkLog.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/DebugLinkMemory.py b/python/trezorlib/messages/DebugLinkMemory.py index b2af6be708..f7167de9de 100644 --- a/python/trezorlib/messages/DebugLinkMemory.py +++ b/python/trezorlib/messages/DebugLinkMemory.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/DebugLinkMemoryRead.py b/python/trezorlib/messages/DebugLinkMemoryRead.py index a402c69444..da02de1a56 100644 --- a/python/trezorlib/messages/DebugLinkMemoryRead.py +++ b/python/trezorlib/messages/DebugLinkMemoryRead.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/DebugLinkMemoryWrite.py b/python/trezorlib/messages/DebugLinkMemoryWrite.py index 680ed22ae2..e6f212e0dd 100644 --- a/python/trezorlib/messages/DebugLinkMemoryWrite.py +++ b/python/trezorlib/messages/DebugLinkMemoryWrite.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/DebugLinkState.py b/python/trezorlib/messages/DebugLinkState.py index ce3e9f6a80..f1135b3d83 100644 --- a/python/trezorlib/messages/DebugLinkState.py +++ b/python/trezorlib/messages/DebugLinkState.py @@ -7,6 +7,7 @@ from .HDNodeType import HDNodeType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/DebugLinkStop.py b/python/trezorlib/messages/DebugLinkStop.py index 41ffc2c1b5..e4c478b78d 100644 --- a/python/trezorlib/messages/DebugLinkStop.py +++ b/python/trezorlib/messages/DebugLinkStop.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/DebugMoneroDiagAck.py b/python/trezorlib/messages/DebugMoneroDiagAck.py index 346735e1a6..7b9065f0da 100644 --- a/python/trezorlib/messages/DebugMoneroDiagAck.py +++ b/python/trezorlib/messages/DebugMoneroDiagAck.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/DebugMoneroDiagRequest.py b/python/trezorlib/messages/DebugMoneroDiagRequest.py index 8868862568..8651671fad 100644 --- a/python/trezorlib/messages/DebugMoneroDiagRequest.py +++ b/python/trezorlib/messages/DebugMoneroDiagRequest.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/ECDHSessionKey.py b/python/trezorlib/messages/ECDHSessionKey.py index ee2d955502..dd0a60c943 100644 --- a/python/trezorlib/messages/ECDHSessionKey.py +++ b/python/trezorlib/messages/ECDHSessionKey.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/Entropy.py b/python/trezorlib/messages/Entropy.py index 812085c980..777080fad1 100644 --- a/python/trezorlib/messages/Entropy.py +++ b/python/trezorlib/messages/Entropy.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EntropyAck.py b/python/trezorlib/messages/EntropyAck.py index a6749a184b..6824ee7da3 100644 --- a/python/trezorlib/messages/EntropyAck.py +++ b/python/trezorlib/messages/EntropyAck.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EntropyRequest.py b/python/trezorlib/messages/EntropyRequest.py index ff25f719db..d0c7e1260d 100644 --- a/python/trezorlib/messages/EntropyRequest.py +++ b/python/trezorlib/messages/EntropyRequest.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EosActionBuyRam.py b/python/trezorlib/messages/EosActionBuyRam.py index 85997a797a..cc9ae62fd0 100644 --- a/python/trezorlib/messages/EosActionBuyRam.py +++ b/python/trezorlib/messages/EosActionBuyRam.py @@ -7,6 +7,7 @@ from .EosAsset import EosAsset if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EosActionBuyRamBytes.py b/python/trezorlib/messages/EosActionBuyRamBytes.py index 650eebac81..374ed3bd5a 100644 --- a/python/trezorlib/messages/EosActionBuyRamBytes.py +++ b/python/trezorlib/messages/EosActionBuyRamBytes.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EosActionCommon.py b/python/trezorlib/messages/EosActionCommon.py index 9a3489183c..76c0e6ff38 100644 --- a/python/trezorlib/messages/EosActionCommon.py +++ b/python/trezorlib/messages/EosActionCommon.py @@ -7,6 +7,7 @@ from .EosPermissionLevel import EosPermissionLevel if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EosActionDelegate.py b/python/trezorlib/messages/EosActionDelegate.py index f3f4de565e..5afe71e782 100644 --- a/python/trezorlib/messages/EosActionDelegate.py +++ b/python/trezorlib/messages/EosActionDelegate.py @@ -7,6 +7,7 @@ from .EosAsset import EosAsset if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EosActionDeleteAuth.py b/python/trezorlib/messages/EosActionDeleteAuth.py index 80642b734a..17a2677de7 100644 --- a/python/trezorlib/messages/EosActionDeleteAuth.py +++ b/python/trezorlib/messages/EosActionDeleteAuth.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EosActionLinkAuth.py b/python/trezorlib/messages/EosActionLinkAuth.py index cffdfb32c7..57f81b2e19 100644 --- a/python/trezorlib/messages/EosActionLinkAuth.py +++ b/python/trezorlib/messages/EosActionLinkAuth.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EosActionNewAccount.py b/python/trezorlib/messages/EosActionNewAccount.py index 7da7d1374a..55677a900e 100644 --- a/python/trezorlib/messages/EosActionNewAccount.py +++ b/python/trezorlib/messages/EosActionNewAccount.py @@ -7,6 +7,7 @@ from .EosAuthorization import EosAuthorization if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EosActionRefund.py b/python/trezorlib/messages/EosActionRefund.py index 38716e8632..a98eb7f6cb 100644 --- a/python/trezorlib/messages/EosActionRefund.py +++ b/python/trezorlib/messages/EosActionRefund.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EosActionSellRam.py b/python/trezorlib/messages/EosActionSellRam.py index 314e564626..51fe851c13 100644 --- a/python/trezorlib/messages/EosActionSellRam.py +++ b/python/trezorlib/messages/EosActionSellRam.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EosActionTransfer.py b/python/trezorlib/messages/EosActionTransfer.py index 73d99854dd..a30d7b994c 100644 --- a/python/trezorlib/messages/EosActionTransfer.py +++ b/python/trezorlib/messages/EosActionTransfer.py @@ -7,6 +7,7 @@ from .EosAsset import EosAsset if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EosActionUndelegate.py b/python/trezorlib/messages/EosActionUndelegate.py index e2b4cf3f9f..d1f814916e 100644 --- a/python/trezorlib/messages/EosActionUndelegate.py +++ b/python/trezorlib/messages/EosActionUndelegate.py @@ -7,6 +7,7 @@ from .EosAsset import EosAsset if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EosActionUnknown.py b/python/trezorlib/messages/EosActionUnknown.py index 3355aec13c..0d42d2f51f 100644 --- a/python/trezorlib/messages/EosActionUnknown.py +++ b/python/trezorlib/messages/EosActionUnknown.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EosActionUnlinkAuth.py b/python/trezorlib/messages/EosActionUnlinkAuth.py index 08ae4d528d..3137ccd3b8 100644 --- a/python/trezorlib/messages/EosActionUnlinkAuth.py +++ b/python/trezorlib/messages/EosActionUnlinkAuth.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EosActionUpdateAuth.py b/python/trezorlib/messages/EosActionUpdateAuth.py index 5aac2046ff..67c33a6b56 100644 --- a/python/trezorlib/messages/EosActionUpdateAuth.py +++ b/python/trezorlib/messages/EosActionUpdateAuth.py @@ -7,6 +7,7 @@ from .EosAuthorization import EosAuthorization if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EosActionVoteProducer.py b/python/trezorlib/messages/EosActionVoteProducer.py index 0150a3ce30..7b27395913 100644 --- a/python/trezorlib/messages/EosActionVoteProducer.py +++ b/python/trezorlib/messages/EosActionVoteProducer.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EosAsset.py b/python/trezorlib/messages/EosAsset.py index cbe882d35e..dcd540a091 100644 --- a/python/trezorlib/messages/EosAsset.py +++ b/python/trezorlib/messages/EosAsset.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EosAuthorization.py b/python/trezorlib/messages/EosAuthorization.py index 0c41d85902..3890103908 100644 --- a/python/trezorlib/messages/EosAuthorization.py +++ b/python/trezorlib/messages/EosAuthorization.py @@ -9,6 +9,7 @@ from .EosAuthorizationWait import EosAuthorizationWait if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EosAuthorizationAccount.py b/python/trezorlib/messages/EosAuthorizationAccount.py index e68659441f..3984856e05 100644 --- a/python/trezorlib/messages/EosAuthorizationAccount.py +++ b/python/trezorlib/messages/EosAuthorizationAccount.py @@ -7,6 +7,7 @@ from .EosPermissionLevel import EosPermissionLevel if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EosAuthorizationKey.py b/python/trezorlib/messages/EosAuthorizationKey.py index f892530c8b..c5ba1f5d4c 100644 --- a/python/trezorlib/messages/EosAuthorizationKey.py +++ b/python/trezorlib/messages/EosAuthorizationKey.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EosAuthorizationWait.py b/python/trezorlib/messages/EosAuthorizationWait.py index 6abe05eec5..cf48e2bd18 100644 --- a/python/trezorlib/messages/EosAuthorizationWait.py +++ b/python/trezorlib/messages/EosAuthorizationWait.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EosGetPublicKey.py b/python/trezorlib/messages/EosGetPublicKey.py index 0f68d11c1a..674e5c5e51 100644 --- a/python/trezorlib/messages/EosGetPublicKey.py +++ b/python/trezorlib/messages/EosGetPublicKey.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EosPermissionLevel.py b/python/trezorlib/messages/EosPermissionLevel.py index abbc414bca..7a566cc3c5 100644 --- a/python/trezorlib/messages/EosPermissionLevel.py +++ b/python/trezorlib/messages/EosPermissionLevel.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EosPublicKey.py b/python/trezorlib/messages/EosPublicKey.py index fc02172fc3..0b0eed18c0 100644 --- a/python/trezorlib/messages/EosPublicKey.py +++ b/python/trezorlib/messages/EosPublicKey.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EosSignTx.py b/python/trezorlib/messages/EosSignTx.py index fdcad959fe..cec4745131 100644 --- a/python/trezorlib/messages/EosSignTx.py +++ b/python/trezorlib/messages/EosSignTx.py @@ -7,6 +7,7 @@ from .EosTxHeader import EosTxHeader if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EosSignedTx.py b/python/trezorlib/messages/EosSignedTx.py index 79a5769868..63bb0081c0 100644 --- a/python/trezorlib/messages/EosSignedTx.py +++ b/python/trezorlib/messages/EosSignedTx.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EosTxActionAck.py b/python/trezorlib/messages/EosTxActionAck.py index 50561b9976..e4a6be9364 100644 --- a/python/trezorlib/messages/EosTxActionAck.py +++ b/python/trezorlib/messages/EosTxActionAck.py @@ -21,6 +21,7 @@ from .EosActionVoteProducer import EosActionVoteProducer if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EosTxActionRequest.py b/python/trezorlib/messages/EosTxActionRequest.py index dcd75cdb3c..57872110e4 100644 --- a/python/trezorlib/messages/EosTxActionRequest.py +++ b/python/trezorlib/messages/EosTxActionRequest.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EosTxHeader.py b/python/trezorlib/messages/EosTxHeader.py index 28604189cd..e5e5c22ed3 100644 --- a/python/trezorlib/messages/EosTxHeader.py +++ b/python/trezorlib/messages/EosTxHeader.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EthereumAddress.py b/python/trezorlib/messages/EthereumAddress.py index e266f6f12c..280a2369df 100644 --- a/python/trezorlib/messages/EthereumAddress.py +++ b/python/trezorlib/messages/EthereumAddress.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EthereumGetAddress.py b/python/trezorlib/messages/EthereumGetAddress.py index a8ee91e15a..686c4b89f3 100644 --- a/python/trezorlib/messages/EthereumGetAddress.py +++ b/python/trezorlib/messages/EthereumGetAddress.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EthereumGetPublicKey.py b/python/trezorlib/messages/EthereumGetPublicKey.py index d458637a6b..ca18dbef16 100644 --- a/python/trezorlib/messages/EthereumGetPublicKey.py +++ b/python/trezorlib/messages/EthereumGetPublicKey.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EthereumMessageSignature.py b/python/trezorlib/messages/EthereumMessageSignature.py index 1b89400ad1..1078621789 100644 --- a/python/trezorlib/messages/EthereumMessageSignature.py +++ b/python/trezorlib/messages/EthereumMessageSignature.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EthereumPublicKey.py b/python/trezorlib/messages/EthereumPublicKey.py index da2dbe2c08..af531678d7 100644 --- a/python/trezorlib/messages/EthereumPublicKey.py +++ b/python/trezorlib/messages/EthereumPublicKey.py @@ -7,6 +7,7 @@ from .HDNodeType import HDNodeType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EthereumSignMessage.py b/python/trezorlib/messages/EthereumSignMessage.py index 233990a0b6..000166b9bd 100644 --- a/python/trezorlib/messages/EthereumSignMessage.py +++ b/python/trezorlib/messages/EthereumSignMessage.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EthereumSignTx.py b/python/trezorlib/messages/EthereumSignTx.py index ee86e7ec48..710406ca10 100644 --- a/python/trezorlib/messages/EthereumSignTx.py +++ b/python/trezorlib/messages/EthereumSignTx.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EthereumTxAck.py b/python/trezorlib/messages/EthereumTxAck.py index 19f6c361dc..aacb878e6e 100644 --- a/python/trezorlib/messages/EthereumTxAck.py +++ b/python/trezorlib/messages/EthereumTxAck.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EthereumTxRequest.py b/python/trezorlib/messages/EthereumTxRequest.py index f256cfeec0..6f9d266bf1 100644 --- a/python/trezorlib/messages/EthereumTxRequest.py +++ b/python/trezorlib/messages/EthereumTxRequest.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/EthereumVerifyMessage.py b/python/trezorlib/messages/EthereumVerifyMessage.py index 3689482d25..41b8c7d9f9 100644 --- a/python/trezorlib/messages/EthereumVerifyMessage.py +++ b/python/trezorlib/messages/EthereumVerifyMessage.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/Failure.py b/python/trezorlib/messages/Failure.py index 05ef8e2d20..5c7bb8bd67 100644 --- a/python/trezorlib/messages/Failure.py +++ b/python/trezorlib/messages/Failure.py @@ -5,8 +5,11 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypeFailureType = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 99] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeFailureType = None # type: ignore class Failure(p.MessageType): @@ -14,7 +17,7 @@ class Failure(p.MessageType): def __init__( self, - code: int = None, + code: EnumTypeFailureType = None, message: str = None, ) -> None: self.code = code @@ -23,6 +26,6 @@ class Failure(p.MessageType): @classmethod def get_fields(cls) -> Dict: return { - 1: ('code', p.UVarintType, 0), + 1: ('code', p.EnumType("FailureType", (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 99)), 0), 2: ('message', p.UnicodeType, 0), } diff --git a/python/trezorlib/messages/Features.py b/python/trezorlib/messages/Features.py index ea95a5cfd4..88a418813c 100644 --- a/python/trezorlib/messages/Features.py +++ b/python/trezorlib/messages/Features.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/FirmwareErase.py b/python/trezorlib/messages/FirmwareErase.py index de3c49be18..1f0fef92e1 100644 --- a/python/trezorlib/messages/FirmwareErase.py +++ b/python/trezorlib/messages/FirmwareErase.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/FirmwareRequest.py b/python/trezorlib/messages/FirmwareRequest.py index e3b46e05e9..a1809ba357 100644 --- a/python/trezorlib/messages/FirmwareRequest.py +++ b/python/trezorlib/messages/FirmwareRequest.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/FirmwareUpload.py b/python/trezorlib/messages/FirmwareUpload.py index 77abec9588..1a1af861fd 100644 --- a/python/trezorlib/messages/FirmwareUpload.py +++ b/python/trezorlib/messages/FirmwareUpload.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/GetAddress.py b/python/trezorlib/messages/GetAddress.py index 3fec94d90a..1f677a6134 100644 --- a/python/trezorlib/messages/GetAddress.py +++ b/python/trezorlib/messages/GetAddress.py @@ -7,8 +7,11 @@ from .MultisigRedeemScriptType import MultisigRedeemScriptType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypeInputScriptType = Literal[0, 1, 2, 3, 4] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeInputScriptType = None # type: ignore class GetAddress(p.MessageType): @@ -20,7 +23,7 @@ class GetAddress(p.MessageType): coin_name: str = None, show_display: bool = None, multisig: MultisigRedeemScriptType = None, - script_type: int = None, + script_type: EnumTypeInputScriptType = None, ) -> None: self.address_n = address_n if address_n is not None else [] self.coin_name = coin_name @@ -35,5 +38,5 @@ class GetAddress(p.MessageType): 2: ('coin_name', p.UnicodeType, 0), # default=Bitcoin 3: ('show_display', p.BoolType, 0), 4: ('multisig', MultisigRedeemScriptType, 0), - 5: ('script_type', p.UVarintType, 0), # default=SPENDADDRESS + 5: ('script_type', p.EnumType("InputScriptType", (0, 1, 2, 3, 4)), 0), # default=SPENDADDRESS } diff --git a/python/trezorlib/messages/GetECDHSessionKey.py b/python/trezorlib/messages/GetECDHSessionKey.py index 7fe3db4180..592dc37877 100644 --- a/python/trezorlib/messages/GetECDHSessionKey.py +++ b/python/trezorlib/messages/GetECDHSessionKey.py @@ -7,6 +7,7 @@ from .IdentityType import IdentityType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/GetEntropy.py b/python/trezorlib/messages/GetEntropy.py index a755f574e5..25bd1f1263 100644 --- a/python/trezorlib/messages/GetEntropy.py +++ b/python/trezorlib/messages/GetEntropy.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/GetFeatures.py b/python/trezorlib/messages/GetFeatures.py index bc21c61d83..d7eca5c3d6 100644 --- a/python/trezorlib/messages/GetFeatures.py +++ b/python/trezorlib/messages/GetFeatures.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/GetPublicKey.py b/python/trezorlib/messages/GetPublicKey.py index fb50331f13..08db2d0995 100644 --- a/python/trezorlib/messages/GetPublicKey.py +++ b/python/trezorlib/messages/GetPublicKey.py @@ -5,8 +5,11 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypeInputScriptType = Literal[0, 1, 2, 3, 4] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeInputScriptType = None # type: ignore class GetPublicKey(p.MessageType): @@ -18,7 +21,7 @@ class GetPublicKey(p.MessageType): ecdsa_curve_name: str = None, show_display: bool = None, coin_name: str = None, - script_type: int = None, + script_type: EnumTypeInputScriptType = None, ) -> None: self.address_n = address_n if address_n is not None else [] self.ecdsa_curve_name = ecdsa_curve_name @@ -33,5 +36,5 @@ class GetPublicKey(p.MessageType): 2: ('ecdsa_curve_name', p.UnicodeType, 0), 3: ('show_display', p.BoolType, 0), 4: ('coin_name', p.UnicodeType, 0), # default=Bitcoin - 5: ('script_type', p.UVarintType, 0), # default=SPENDADDRESS + 5: ('script_type', p.EnumType("InputScriptType", (0, 1, 2, 3, 4)), 0), # default=SPENDADDRESS } diff --git a/python/trezorlib/messages/HDNodePathType.py b/python/trezorlib/messages/HDNodePathType.py index 667b3be1e5..d776fbb0a6 100644 --- a/python/trezorlib/messages/HDNodePathType.py +++ b/python/trezorlib/messages/HDNodePathType.py @@ -7,6 +7,7 @@ from .HDNodeType import HDNodeType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/HDNodeType.py b/python/trezorlib/messages/HDNodeType.py index ab79bb202d..87c73d6e58 100644 --- a/python/trezorlib/messages/HDNodeType.py +++ b/python/trezorlib/messages/HDNodeType.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/IdentityType.py b/python/trezorlib/messages/IdentityType.py index 36fb398e2f..ad65df0cd7 100644 --- a/python/trezorlib/messages/IdentityType.py +++ b/python/trezorlib/messages/IdentityType.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/Initialize.py b/python/trezorlib/messages/Initialize.py index 629ea6a87b..b594136cf6 100644 --- a/python/trezorlib/messages/Initialize.py +++ b/python/trezorlib/messages/Initialize.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/LiskAddress.py b/python/trezorlib/messages/LiskAddress.py index 7d173c181d..3e732bf343 100644 --- a/python/trezorlib/messages/LiskAddress.py +++ b/python/trezorlib/messages/LiskAddress.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/LiskDelegateType.py b/python/trezorlib/messages/LiskDelegateType.py index 12f4bfaf21..b268d40184 100644 --- a/python/trezorlib/messages/LiskDelegateType.py +++ b/python/trezorlib/messages/LiskDelegateType.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/LiskGetAddress.py b/python/trezorlib/messages/LiskGetAddress.py index dccfd3e2ea..f5d1422fbc 100644 --- a/python/trezorlib/messages/LiskGetAddress.py +++ b/python/trezorlib/messages/LiskGetAddress.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/LiskGetPublicKey.py b/python/trezorlib/messages/LiskGetPublicKey.py index 6b55b061c4..a32dbd0592 100644 --- a/python/trezorlib/messages/LiskGetPublicKey.py +++ b/python/trezorlib/messages/LiskGetPublicKey.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/LiskMessageSignature.py b/python/trezorlib/messages/LiskMessageSignature.py index e6a7123938..010fb5d4dc 100644 --- a/python/trezorlib/messages/LiskMessageSignature.py +++ b/python/trezorlib/messages/LiskMessageSignature.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/LiskMultisignatureType.py b/python/trezorlib/messages/LiskMultisignatureType.py index 90f4277c77..9063ecc2e1 100644 --- a/python/trezorlib/messages/LiskMultisignatureType.py +++ b/python/trezorlib/messages/LiskMultisignatureType.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/LiskPublicKey.py b/python/trezorlib/messages/LiskPublicKey.py index 3bb33c17e2..4db38d42a9 100644 --- a/python/trezorlib/messages/LiskPublicKey.py +++ b/python/trezorlib/messages/LiskPublicKey.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/LiskSignMessage.py b/python/trezorlib/messages/LiskSignMessage.py index d98262d0ba..1adfc3b5a6 100644 --- a/python/trezorlib/messages/LiskSignMessage.py +++ b/python/trezorlib/messages/LiskSignMessage.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/LiskSignTx.py b/python/trezorlib/messages/LiskSignTx.py index 683d3ef198..9c121059c1 100644 --- a/python/trezorlib/messages/LiskSignTx.py +++ b/python/trezorlib/messages/LiskSignTx.py @@ -7,6 +7,7 @@ from .LiskTransactionCommon import LiskTransactionCommon if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/LiskSignatureType.py b/python/trezorlib/messages/LiskSignatureType.py index 534c8c13db..22142302cf 100644 --- a/python/trezorlib/messages/LiskSignatureType.py +++ b/python/trezorlib/messages/LiskSignatureType.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/LiskSignedTx.py b/python/trezorlib/messages/LiskSignedTx.py index 2ccd7d2658..ec3e5eb747 100644 --- a/python/trezorlib/messages/LiskSignedTx.py +++ b/python/trezorlib/messages/LiskSignedTx.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/LiskTransactionAsset.py b/python/trezorlib/messages/LiskTransactionAsset.py index 9fbdeb1132..138b8e6994 100644 --- a/python/trezorlib/messages/LiskTransactionAsset.py +++ b/python/trezorlib/messages/LiskTransactionAsset.py @@ -9,6 +9,7 @@ from .LiskSignatureType import LiskSignatureType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/LiskTransactionCommon.py b/python/trezorlib/messages/LiskTransactionCommon.py index eefaaa9fc8..04ff4aae45 100644 --- a/python/trezorlib/messages/LiskTransactionCommon.py +++ b/python/trezorlib/messages/LiskTransactionCommon.py @@ -7,15 +7,18 @@ from .LiskTransactionAsset import LiskTransactionAsset if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypeLiskTransactionType = Literal[0, 1, 2, 3, 4, 5, 6, 7] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeLiskTransactionType = None # type: ignore class LiskTransactionCommon(p.MessageType): def __init__( self, - type: int = None, + type: EnumTypeLiskTransactionType = None, amount: int = None, fee: int = None, recipient_id: str = None, @@ -38,7 +41,7 @@ class LiskTransactionCommon(p.MessageType): @classmethod def get_fields(cls) -> Dict: return { - 1: ('type', p.UVarintType, 0), + 1: ('type', p.EnumType("LiskTransactionType", (0, 1, 2, 3, 4, 5, 6, 7)), 0), 2: ('amount', p.UVarintType, 0), # default=0 3: ('fee', p.UVarintType, 0), 4: ('recipient_id', p.UnicodeType, 0), diff --git a/python/trezorlib/messages/LiskVerifyMessage.py b/python/trezorlib/messages/LiskVerifyMessage.py index 4bec26e6a3..1eb62c865e 100644 --- a/python/trezorlib/messages/LiskVerifyMessage.py +++ b/python/trezorlib/messages/LiskVerifyMessage.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/LoadDevice.py b/python/trezorlib/messages/LoadDevice.py index db283519b1..263ab2b9bb 100644 --- a/python/trezorlib/messages/LoadDevice.py +++ b/python/trezorlib/messages/LoadDevice.py @@ -7,6 +7,7 @@ from .HDNodeType import HDNodeType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MessageSignature.py b/python/trezorlib/messages/MessageSignature.py index 9551e13b24..1ba7e6f1a1 100644 --- a/python/trezorlib/messages/MessageSignature.py +++ b/python/trezorlib/messages/MessageSignature.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroAccountPublicAddress.py b/python/trezorlib/messages/MoneroAccountPublicAddress.py index c1e91bf1af..9eefba4b7b 100644 --- a/python/trezorlib/messages/MoneroAccountPublicAddress.py +++ b/python/trezorlib/messages/MoneroAccountPublicAddress.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroAddress.py b/python/trezorlib/messages/MoneroAddress.py index 77502894b0..385b5150b0 100644 --- a/python/trezorlib/messages/MoneroAddress.py +++ b/python/trezorlib/messages/MoneroAddress.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroExportedKeyImage.py b/python/trezorlib/messages/MoneroExportedKeyImage.py index bc71967c90..69d2871aef 100644 --- a/python/trezorlib/messages/MoneroExportedKeyImage.py +++ b/python/trezorlib/messages/MoneroExportedKeyImage.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroGetAddress.py b/python/trezorlib/messages/MoneroGetAddress.py index f454d8ca30..5433217347 100644 --- a/python/trezorlib/messages/MoneroGetAddress.py +++ b/python/trezorlib/messages/MoneroGetAddress.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroGetTxKeyAck.py b/python/trezorlib/messages/MoneroGetTxKeyAck.py index 1c5de77294..4e58a881ff 100644 --- a/python/trezorlib/messages/MoneroGetTxKeyAck.py +++ b/python/trezorlib/messages/MoneroGetTxKeyAck.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroGetTxKeyRequest.py b/python/trezorlib/messages/MoneroGetTxKeyRequest.py index ff967170e2..728fa4e081 100644 --- a/python/trezorlib/messages/MoneroGetTxKeyRequest.py +++ b/python/trezorlib/messages/MoneroGetTxKeyRequest.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroGetWatchKey.py b/python/trezorlib/messages/MoneroGetWatchKey.py index c31dbd8c1d..df97e5e292 100644 --- a/python/trezorlib/messages/MoneroGetWatchKey.py +++ b/python/trezorlib/messages/MoneroGetWatchKey.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroKeyImageExportInitAck.py b/python/trezorlib/messages/MoneroKeyImageExportInitAck.py index c515845531..97d99769cd 100644 --- a/python/trezorlib/messages/MoneroKeyImageExportInitAck.py +++ b/python/trezorlib/messages/MoneroKeyImageExportInitAck.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroKeyImageExportInitRequest.py b/python/trezorlib/messages/MoneroKeyImageExportInitRequest.py index ec3d82fe08..fd374a27f3 100644 --- a/python/trezorlib/messages/MoneroKeyImageExportInitRequest.py +++ b/python/trezorlib/messages/MoneroKeyImageExportInitRequest.py @@ -7,6 +7,7 @@ from .MoneroSubAddressIndicesList import MoneroSubAddressIndicesList if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroKeyImageSyncFinalAck.py b/python/trezorlib/messages/MoneroKeyImageSyncFinalAck.py index dccbf34b48..32497cf1eb 100644 --- a/python/trezorlib/messages/MoneroKeyImageSyncFinalAck.py +++ b/python/trezorlib/messages/MoneroKeyImageSyncFinalAck.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroKeyImageSyncFinalRequest.py b/python/trezorlib/messages/MoneroKeyImageSyncFinalRequest.py index eed4017101..063a385495 100644 --- a/python/trezorlib/messages/MoneroKeyImageSyncFinalRequest.py +++ b/python/trezorlib/messages/MoneroKeyImageSyncFinalRequest.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroKeyImageSyncStepAck.py b/python/trezorlib/messages/MoneroKeyImageSyncStepAck.py index 0debb8dd74..0bd2f5fd65 100644 --- a/python/trezorlib/messages/MoneroKeyImageSyncStepAck.py +++ b/python/trezorlib/messages/MoneroKeyImageSyncStepAck.py @@ -7,6 +7,7 @@ from .MoneroExportedKeyImage import MoneroExportedKeyImage if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroKeyImageSyncStepRequest.py b/python/trezorlib/messages/MoneroKeyImageSyncStepRequest.py index 7163a05c20..5674bae3af 100644 --- a/python/trezorlib/messages/MoneroKeyImageSyncStepRequest.py +++ b/python/trezorlib/messages/MoneroKeyImageSyncStepRequest.py @@ -7,6 +7,7 @@ from .MoneroTransferDetails import MoneroTransferDetails if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroLiveRefreshFinalAck.py b/python/trezorlib/messages/MoneroLiveRefreshFinalAck.py index 9e644f37b7..33c0c19eab 100644 --- a/python/trezorlib/messages/MoneroLiveRefreshFinalAck.py +++ b/python/trezorlib/messages/MoneroLiveRefreshFinalAck.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroLiveRefreshFinalRequest.py b/python/trezorlib/messages/MoneroLiveRefreshFinalRequest.py index 19e820c570..0e496f370d 100644 --- a/python/trezorlib/messages/MoneroLiveRefreshFinalRequest.py +++ b/python/trezorlib/messages/MoneroLiveRefreshFinalRequest.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroLiveRefreshStartAck.py b/python/trezorlib/messages/MoneroLiveRefreshStartAck.py index a265016ab2..c85acbdfde 100644 --- a/python/trezorlib/messages/MoneroLiveRefreshStartAck.py +++ b/python/trezorlib/messages/MoneroLiveRefreshStartAck.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroLiveRefreshStartRequest.py b/python/trezorlib/messages/MoneroLiveRefreshStartRequest.py index 207280ce99..40f09d1fb9 100644 --- a/python/trezorlib/messages/MoneroLiveRefreshStartRequest.py +++ b/python/trezorlib/messages/MoneroLiveRefreshStartRequest.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroLiveRefreshStepAck.py b/python/trezorlib/messages/MoneroLiveRefreshStepAck.py index 27ee16cb93..90e756e93c 100644 --- a/python/trezorlib/messages/MoneroLiveRefreshStepAck.py +++ b/python/trezorlib/messages/MoneroLiveRefreshStepAck.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroLiveRefreshStepRequest.py b/python/trezorlib/messages/MoneroLiveRefreshStepRequest.py index a5bb5d1fe9..56615376c6 100644 --- a/python/trezorlib/messages/MoneroLiveRefreshStepRequest.py +++ b/python/trezorlib/messages/MoneroLiveRefreshStepRequest.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroMultisigKLRki.py b/python/trezorlib/messages/MoneroMultisigKLRki.py index dfc0b6a86b..2b338c4425 100644 --- a/python/trezorlib/messages/MoneroMultisigKLRki.py +++ b/python/trezorlib/messages/MoneroMultisigKLRki.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroOutputEntry.py b/python/trezorlib/messages/MoneroOutputEntry.py index 41ddadefd0..005070e1dd 100644 --- a/python/trezorlib/messages/MoneroOutputEntry.py +++ b/python/trezorlib/messages/MoneroOutputEntry.py @@ -7,6 +7,7 @@ from .MoneroRctKeyPublic import MoneroRctKeyPublic if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroRctKeyPublic.py b/python/trezorlib/messages/MoneroRctKeyPublic.py index 118dd71cc2..5c313fb6f1 100644 --- a/python/trezorlib/messages/MoneroRctKeyPublic.py +++ b/python/trezorlib/messages/MoneroRctKeyPublic.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroRingCtSig.py b/python/trezorlib/messages/MoneroRingCtSig.py index c0c6079bda..7a08a5d40c 100644 --- a/python/trezorlib/messages/MoneroRingCtSig.py +++ b/python/trezorlib/messages/MoneroRingCtSig.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroSubAddressIndicesList.py b/python/trezorlib/messages/MoneroSubAddressIndicesList.py index e2ba0b2efe..8ea8f4a690 100644 --- a/python/trezorlib/messages/MoneroSubAddressIndicesList.py +++ b/python/trezorlib/messages/MoneroSubAddressIndicesList.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroTransactionAllInputsSetAck.py b/python/trezorlib/messages/MoneroTransactionAllInputsSetAck.py index 2eab8cea3f..b7e2b2e8c0 100644 --- a/python/trezorlib/messages/MoneroTransactionAllInputsSetAck.py +++ b/python/trezorlib/messages/MoneroTransactionAllInputsSetAck.py @@ -7,6 +7,7 @@ from .MoneroTransactionRsigData import MoneroTransactionRsigData if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroTransactionAllInputsSetRequest.py b/python/trezorlib/messages/MoneroTransactionAllInputsSetRequest.py index 8576c06adb..4e80f35d3b 100644 --- a/python/trezorlib/messages/MoneroTransactionAllInputsSetRequest.py +++ b/python/trezorlib/messages/MoneroTransactionAllInputsSetRequest.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroTransactionAllOutSetAck.py b/python/trezorlib/messages/MoneroTransactionAllOutSetAck.py index 0e23cf84b9..acf372fed3 100644 --- a/python/trezorlib/messages/MoneroTransactionAllOutSetAck.py +++ b/python/trezorlib/messages/MoneroTransactionAllOutSetAck.py @@ -7,6 +7,7 @@ from .MoneroRingCtSig import MoneroRingCtSig if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroTransactionAllOutSetRequest.py b/python/trezorlib/messages/MoneroTransactionAllOutSetRequest.py index 5a80313d07..6f89636283 100644 --- a/python/trezorlib/messages/MoneroTransactionAllOutSetRequest.py +++ b/python/trezorlib/messages/MoneroTransactionAllOutSetRequest.py @@ -7,6 +7,7 @@ from .MoneroTransactionRsigData import MoneroTransactionRsigData if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroTransactionData.py b/python/trezorlib/messages/MoneroTransactionData.py index afa81d54be..f9d95bbf63 100644 --- a/python/trezorlib/messages/MoneroTransactionData.py +++ b/python/trezorlib/messages/MoneroTransactionData.py @@ -8,6 +8,7 @@ from .MoneroTransactionRsigData import MoneroTransactionRsigData if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroTransactionDestinationEntry.py b/python/trezorlib/messages/MoneroTransactionDestinationEntry.py index 15155217fd..c9d520e291 100644 --- a/python/trezorlib/messages/MoneroTransactionDestinationEntry.py +++ b/python/trezorlib/messages/MoneroTransactionDestinationEntry.py @@ -7,6 +7,7 @@ from .MoneroAccountPublicAddress import MoneroAccountPublicAddress if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroTransactionFinalAck.py b/python/trezorlib/messages/MoneroTransactionFinalAck.py index b932419ec7..9d5068d01e 100644 --- a/python/trezorlib/messages/MoneroTransactionFinalAck.py +++ b/python/trezorlib/messages/MoneroTransactionFinalAck.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroTransactionFinalRequest.py b/python/trezorlib/messages/MoneroTransactionFinalRequest.py index 233e4fc54f..79ba3834a5 100644 --- a/python/trezorlib/messages/MoneroTransactionFinalRequest.py +++ b/python/trezorlib/messages/MoneroTransactionFinalRequest.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroTransactionInitAck.py b/python/trezorlib/messages/MoneroTransactionInitAck.py index f6853ccd4c..f6c2930552 100644 --- a/python/trezorlib/messages/MoneroTransactionInitAck.py +++ b/python/trezorlib/messages/MoneroTransactionInitAck.py @@ -7,6 +7,7 @@ from .MoneroTransactionRsigData import MoneroTransactionRsigData if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroTransactionInitRequest.py b/python/trezorlib/messages/MoneroTransactionInitRequest.py index 9449192e56..922790fc09 100644 --- a/python/trezorlib/messages/MoneroTransactionInitRequest.py +++ b/python/trezorlib/messages/MoneroTransactionInitRequest.py @@ -7,6 +7,7 @@ from .MoneroTransactionData import MoneroTransactionData if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroTransactionInputViniAck.py b/python/trezorlib/messages/MoneroTransactionInputViniAck.py index 833a295421..af549e94c1 100644 --- a/python/trezorlib/messages/MoneroTransactionInputViniAck.py +++ b/python/trezorlib/messages/MoneroTransactionInputViniAck.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroTransactionInputViniRequest.py b/python/trezorlib/messages/MoneroTransactionInputViniRequest.py index bd1ad0947f..86e5233a7f 100644 --- a/python/trezorlib/messages/MoneroTransactionInputViniRequest.py +++ b/python/trezorlib/messages/MoneroTransactionInputViniRequest.py @@ -7,6 +7,7 @@ from .MoneroTransactionSourceEntry import MoneroTransactionSourceEntry if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroTransactionInputsPermutationAck.py b/python/trezorlib/messages/MoneroTransactionInputsPermutationAck.py index 45bcb83415..729aa09a00 100644 --- a/python/trezorlib/messages/MoneroTransactionInputsPermutationAck.py +++ b/python/trezorlib/messages/MoneroTransactionInputsPermutationAck.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroTransactionInputsPermutationRequest.py b/python/trezorlib/messages/MoneroTransactionInputsPermutationRequest.py index 9b585fd7d3..323d61fe4b 100644 --- a/python/trezorlib/messages/MoneroTransactionInputsPermutationRequest.py +++ b/python/trezorlib/messages/MoneroTransactionInputsPermutationRequest.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroTransactionRsigData.py b/python/trezorlib/messages/MoneroTransactionRsigData.py index 3767562aa6..27dc5e03fa 100644 --- a/python/trezorlib/messages/MoneroTransactionRsigData.py +++ b/python/trezorlib/messages/MoneroTransactionRsigData.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroTransactionSetInputAck.py b/python/trezorlib/messages/MoneroTransactionSetInputAck.py index 4df3806507..4216e69503 100644 --- a/python/trezorlib/messages/MoneroTransactionSetInputAck.py +++ b/python/trezorlib/messages/MoneroTransactionSetInputAck.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroTransactionSetInputRequest.py b/python/trezorlib/messages/MoneroTransactionSetInputRequest.py index f36db9fa87..963586ee8c 100644 --- a/python/trezorlib/messages/MoneroTransactionSetInputRequest.py +++ b/python/trezorlib/messages/MoneroTransactionSetInputRequest.py @@ -7,6 +7,7 @@ from .MoneroTransactionSourceEntry import MoneroTransactionSourceEntry if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroTransactionSetOutputAck.py b/python/trezorlib/messages/MoneroTransactionSetOutputAck.py index ebdb047917..7616759a6e 100644 --- a/python/trezorlib/messages/MoneroTransactionSetOutputAck.py +++ b/python/trezorlib/messages/MoneroTransactionSetOutputAck.py @@ -7,6 +7,7 @@ from .MoneroTransactionRsigData import MoneroTransactionRsigData if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroTransactionSetOutputRequest.py b/python/trezorlib/messages/MoneroTransactionSetOutputRequest.py index fa9f7e7691..3113cda412 100644 --- a/python/trezorlib/messages/MoneroTransactionSetOutputRequest.py +++ b/python/trezorlib/messages/MoneroTransactionSetOutputRequest.py @@ -8,6 +8,7 @@ from .MoneroTransactionRsigData import MoneroTransactionRsigData if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroTransactionSignInputAck.py b/python/trezorlib/messages/MoneroTransactionSignInputAck.py index f970e22152..0727f557db 100644 --- a/python/trezorlib/messages/MoneroTransactionSignInputAck.py +++ b/python/trezorlib/messages/MoneroTransactionSignInputAck.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroTransactionSignInputRequest.py b/python/trezorlib/messages/MoneroTransactionSignInputRequest.py index 66cc9d7e4a..19304f3451 100644 --- a/python/trezorlib/messages/MoneroTransactionSignInputRequest.py +++ b/python/trezorlib/messages/MoneroTransactionSignInputRequest.py @@ -7,6 +7,7 @@ from .MoneroTransactionSourceEntry import MoneroTransactionSourceEntry if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroTransactionSourceEntry.py b/python/trezorlib/messages/MoneroTransactionSourceEntry.py index ab8f538a52..a315b399a6 100644 --- a/python/trezorlib/messages/MoneroTransactionSourceEntry.py +++ b/python/trezorlib/messages/MoneroTransactionSourceEntry.py @@ -8,6 +8,7 @@ from .MoneroOutputEntry import MoneroOutputEntry if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroTransferDetails.py b/python/trezorlib/messages/MoneroTransferDetails.py index 6a30babb62..7000757766 100644 --- a/python/trezorlib/messages/MoneroTransferDetails.py +++ b/python/trezorlib/messages/MoneroTransferDetails.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MoneroWatchKey.py b/python/trezorlib/messages/MoneroWatchKey.py index fbdb393380..7defbc3fa9 100644 --- a/python/trezorlib/messages/MoneroWatchKey.py +++ b/python/trezorlib/messages/MoneroWatchKey.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/MultisigRedeemScriptType.py b/python/trezorlib/messages/MultisigRedeemScriptType.py index 9ac41c1eeb..08f1594dfd 100644 --- a/python/trezorlib/messages/MultisigRedeemScriptType.py +++ b/python/trezorlib/messages/MultisigRedeemScriptType.py @@ -8,6 +8,7 @@ from .HDNodeType import HDNodeType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/NEMAddress.py b/python/trezorlib/messages/NEMAddress.py index 1d64df8b4d..65dd69b60f 100644 --- a/python/trezorlib/messages/NEMAddress.py +++ b/python/trezorlib/messages/NEMAddress.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/NEMAggregateModification.py b/python/trezorlib/messages/NEMAggregateModification.py index e702abae26..cb6a6730b6 100644 --- a/python/trezorlib/messages/NEMAggregateModification.py +++ b/python/trezorlib/messages/NEMAggregateModification.py @@ -7,6 +7,7 @@ from .NEMCosignatoryModification import NEMCosignatoryModification if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/NEMCosignatoryModification.py b/python/trezorlib/messages/NEMCosignatoryModification.py index 0e3a5ff285..b733c48224 100644 --- a/python/trezorlib/messages/NEMCosignatoryModification.py +++ b/python/trezorlib/messages/NEMCosignatoryModification.py @@ -5,15 +5,18 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypeNEMModificationType = Literal[1, 2] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeNEMModificationType = None # type: ignore class NEMCosignatoryModification(p.MessageType): def __init__( self, - type: int = None, + type: EnumTypeNEMModificationType = None, public_key: bytes = None, ) -> None: self.type = type @@ -22,6 +25,6 @@ class NEMCosignatoryModification(p.MessageType): @classmethod def get_fields(cls) -> Dict: return { - 1: ('type', p.UVarintType, 0), + 1: ('type', p.EnumType("NEMModificationType", (1, 2)), 0), 2: ('public_key', p.BytesType, 0), } diff --git a/python/trezorlib/messages/NEMDecryptMessage.py b/python/trezorlib/messages/NEMDecryptMessage.py index 9beaf2948c..11c301a556 100644 --- a/python/trezorlib/messages/NEMDecryptMessage.py +++ b/python/trezorlib/messages/NEMDecryptMessage.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/NEMDecryptedMessage.py b/python/trezorlib/messages/NEMDecryptedMessage.py index 2000f3683a..ff59dba4a1 100644 --- a/python/trezorlib/messages/NEMDecryptedMessage.py +++ b/python/trezorlib/messages/NEMDecryptedMessage.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/NEMGetAddress.py b/python/trezorlib/messages/NEMGetAddress.py index 74a19e6d53..252e2b136a 100644 --- a/python/trezorlib/messages/NEMGetAddress.py +++ b/python/trezorlib/messages/NEMGetAddress.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/NEMImportanceTransfer.py b/python/trezorlib/messages/NEMImportanceTransfer.py index 7614f70236..341c281778 100644 --- a/python/trezorlib/messages/NEMImportanceTransfer.py +++ b/python/trezorlib/messages/NEMImportanceTransfer.py @@ -5,15 +5,18 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypeNEMImportanceTransferMode = Literal[1, 2] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeNEMImportanceTransferMode = None # type: ignore class NEMImportanceTransfer(p.MessageType): def __init__( self, - mode: int = None, + mode: EnumTypeNEMImportanceTransferMode = None, public_key: bytes = None, ) -> None: self.mode = mode @@ -22,6 +25,6 @@ class NEMImportanceTransfer(p.MessageType): @classmethod def get_fields(cls) -> Dict: return { - 1: ('mode', p.UVarintType, 0), + 1: ('mode', p.EnumType("NEMImportanceTransferMode", (1, 2)), 0), 2: ('public_key', p.BytesType, 0), } diff --git a/python/trezorlib/messages/NEMMosaic.py b/python/trezorlib/messages/NEMMosaic.py index eab234b014..998d8d0268 100644 --- a/python/trezorlib/messages/NEMMosaic.py +++ b/python/trezorlib/messages/NEMMosaic.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/NEMMosaicCreation.py b/python/trezorlib/messages/NEMMosaicCreation.py index fb5b7e972f..fd0498ce7f 100644 --- a/python/trezorlib/messages/NEMMosaicCreation.py +++ b/python/trezorlib/messages/NEMMosaicCreation.py @@ -7,6 +7,7 @@ from .NEMMosaicDefinition import NEMMosaicDefinition if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/NEMMosaicDefinition.py b/python/trezorlib/messages/NEMMosaicDefinition.py index 8d746595fb..f55f9a35e4 100644 --- a/python/trezorlib/messages/NEMMosaicDefinition.py +++ b/python/trezorlib/messages/NEMMosaicDefinition.py @@ -5,8 +5,11 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypeNEMMosaicLevy = Literal[1, 2] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeNEMMosaicLevy = None # type: ignore class NEMMosaicDefinition(p.MessageType): @@ -18,7 +21,7 @@ class NEMMosaicDefinition(p.MessageType): namespace: str = None, mosaic: str = None, divisibility: int = None, - levy: int = None, + levy: EnumTypeNEMMosaicLevy = None, fee: int = None, levy_address: str = None, levy_namespace: str = None, @@ -53,7 +56,7 @@ class NEMMosaicDefinition(p.MessageType): 3: ('namespace', p.UnicodeType, 0), 4: ('mosaic', p.UnicodeType, 0), 5: ('divisibility', p.UVarintType, 0), - 6: ('levy', p.UVarintType, 0), + 6: ('levy', p.EnumType("NEMMosaicLevy", (1, 2)), 0), 7: ('fee', p.UVarintType, 0), 8: ('levy_address', p.UnicodeType, 0), 9: ('levy_namespace', p.UnicodeType, 0), diff --git a/python/trezorlib/messages/NEMMosaicSupplyChange.py b/python/trezorlib/messages/NEMMosaicSupplyChange.py index afb5412e7a..08ad85290f 100644 --- a/python/trezorlib/messages/NEMMosaicSupplyChange.py +++ b/python/trezorlib/messages/NEMMosaicSupplyChange.py @@ -5,8 +5,11 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypeNEMSupplyChangeType = Literal[1, 2] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeNEMSupplyChangeType = None # type: ignore class NEMMosaicSupplyChange(p.MessageType): @@ -15,7 +18,7 @@ class NEMMosaicSupplyChange(p.MessageType): self, namespace: str = None, mosaic: str = None, - type: int = None, + type: EnumTypeNEMSupplyChangeType = None, delta: int = None, ) -> None: self.namespace = namespace @@ -28,6 +31,6 @@ class NEMMosaicSupplyChange(p.MessageType): return { 1: ('namespace', p.UnicodeType, 0), 2: ('mosaic', p.UnicodeType, 0), - 3: ('type', p.UVarintType, 0), + 3: ('type', p.EnumType("NEMSupplyChangeType", (1, 2)), 0), 4: ('delta', p.UVarintType, 0), } diff --git a/python/trezorlib/messages/NEMProvisionNamespace.py b/python/trezorlib/messages/NEMProvisionNamespace.py index 04fc552097..f62bd4e394 100644 --- a/python/trezorlib/messages/NEMProvisionNamespace.py +++ b/python/trezorlib/messages/NEMProvisionNamespace.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/NEMSignTx.py b/python/trezorlib/messages/NEMSignTx.py index 286b0245af..f807a4d951 100644 --- a/python/trezorlib/messages/NEMSignTx.py +++ b/python/trezorlib/messages/NEMSignTx.py @@ -13,6 +13,7 @@ from .NEMTransfer import NEMTransfer if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/NEMSignedTx.py b/python/trezorlib/messages/NEMSignedTx.py index 4516287de6..4497efcc10 100644 --- a/python/trezorlib/messages/NEMSignedTx.py +++ b/python/trezorlib/messages/NEMSignedTx.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/NEMTransactionCommon.py b/python/trezorlib/messages/NEMTransactionCommon.py index db65aabbcf..49d3b50b4a 100644 --- a/python/trezorlib/messages/NEMTransactionCommon.py +++ b/python/trezorlib/messages/NEMTransactionCommon.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/NEMTransfer.py b/python/trezorlib/messages/NEMTransfer.py index 0fb5ade79a..eded5b46ee 100644 --- a/python/trezorlib/messages/NEMTransfer.py +++ b/python/trezorlib/messages/NEMTransfer.py @@ -7,6 +7,7 @@ from .NEMMosaic import NEMMosaic if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/PassphraseAck.py b/python/trezorlib/messages/PassphraseAck.py index 0e9b93bb80..6cafc49af2 100644 --- a/python/trezorlib/messages/PassphraseAck.py +++ b/python/trezorlib/messages/PassphraseAck.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/PassphraseRequest.py b/python/trezorlib/messages/PassphraseRequest.py index 186b703e8a..bdd6aa1ea3 100644 --- a/python/trezorlib/messages/PassphraseRequest.py +++ b/python/trezorlib/messages/PassphraseRequest.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/PassphraseStateAck.py b/python/trezorlib/messages/PassphraseStateAck.py index 2a4a0f1125..1717fa911a 100644 --- a/python/trezorlib/messages/PassphraseStateAck.py +++ b/python/trezorlib/messages/PassphraseStateAck.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/PassphraseStateRequest.py b/python/trezorlib/messages/PassphraseStateRequest.py index cbab1df6d9..c39a51d6ec 100644 --- a/python/trezorlib/messages/PassphraseStateRequest.py +++ b/python/trezorlib/messages/PassphraseStateRequest.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/PinMatrixAck.py b/python/trezorlib/messages/PinMatrixAck.py index e7cf9dd9b2..dcf0cba8af 100644 --- a/python/trezorlib/messages/PinMatrixAck.py +++ b/python/trezorlib/messages/PinMatrixAck.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/PinMatrixRequest.py b/python/trezorlib/messages/PinMatrixRequest.py index c0c6d8b73b..9047e6d584 100644 --- a/python/trezorlib/messages/PinMatrixRequest.py +++ b/python/trezorlib/messages/PinMatrixRequest.py @@ -5,8 +5,11 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypePinMatrixRequestType = Literal[1, 2, 3] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypePinMatrixRequestType = None # type: ignore class PinMatrixRequest(p.MessageType): @@ -14,12 +17,12 @@ class PinMatrixRequest(p.MessageType): def __init__( self, - type: int = None, + type: EnumTypePinMatrixRequestType = None, ) -> None: self.type = type @classmethod def get_fields(cls) -> Dict: return { - 1: ('type', p.UVarintType, 0), + 1: ('type', p.EnumType("PinMatrixRequestType", (1, 2, 3)), 0), } diff --git a/python/trezorlib/messages/Ping.py b/python/trezorlib/messages/Ping.py index 54a8dfdfec..b2d7f6dc19 100644 --- a/python/trezorlib/messages/Ping.py +++ b/python/trezorlib/messages/Ping.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/PublicKey.py b/python/trezorlib/messages/PublicKey.py index 16c039a663..ff6c41870a 100644 --- a/python/trezorlib/messages/PublicKey.py +++ b/python/trezorlib/messages/PublicKey.py @@ -7,6 +7,7 @@ from .HDNodeType import HDNodeType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/RecoveryDevice.py b/python/trezorlib/messages/RecoveryDevice.py index 9a93bb23e9..feea78541c 100644 --- a/python/trezorlib/messages/RecoveryDevice.py +++ b/python/trezorlib/messages/RecoveryDevice.py @@ -5,8 +5,11 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypeRecoveryDeviceType = Literal[0, 1] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeRecoveryDeviceType = None # type: ignore class RecoveryDevice(p.MessageType): @@ -20,7 +23,7 @@ class RecoveryDevice(p.MessageType): language: str = None, label: str = None, enforce_wordlist: bool = None, - type: int = None, + type: EnumTypeRecoveryDeviceType = None, u2f_counter: int = None, dry_run: bool = None, ) -> None: @@ -43,7 +46,7 @@ class RecoveryDevice(p.MessageType): 4: ('language', p.UnicodeType, 0), # default=english 5: ('label', p.UnicodeType, 0), 6: ('enforce_wordlist', p.BoolType, 0), - 8: ('type', p.UVarintType, 0), + 8: ('type', p.EnumType("RecoveryDeviceType", (0, 1)), 0), 9: ('u2f_counter', p.UVarintType, 0), 10: ('dry_run', p.BoolType, 0), } diff --git a/python/trezorlib/messages/ResetDevice.py b/python/trezorlib/messages/ResetDevice.py index 32bf903652..94c1d3c0fd 100644 --- a/python/trezorlib/messages/ResetDevice.py +++ b/python/trezorlib/messages/ResetDevice.py @@ -5,8 +5,11 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypeResetDeviceBackupType = Literal[0, 1, 2] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeResetDeviceBackupType = None # type: ignore class ResetDevice(p.MessageType): @@ -23,7 +26,7 @@ class ResetDevice(p.MessageType): u2f_counter: int = None, skip_backup: bool = None, no_backup: bool = None, - backup_type: int = None, + backup_type: EnumTypeResetDeviceBackupType = None, ) -> None: self.display_random = display_random self.strength = strength @@ -48,5 +51,5 @@ class ResetDevice(p.MessageType): 7: ('u2f_counter', p.UVarintType, 0), 8: ('skip_backup', p.BoolType, 0), 9: ('no_backup', p.BoolType, 0), - 10: ('backup_type', p.UVarintType, 0), # default=ResetDeviceBackupType_Bip39 + 10: ('backup_type', p.EnumType("ResetDeviceBackupType", (0, 1, 2)), 0), # default=ResetDeviceBackupType_Bip39 } diff --git a/python/trezorlib/messages/RippleAddress.py b/python/trezorlib/messages/RippleAddress.py index 45762c3482..7ddf1bf938 100644 --- a/python/trezorlib/messages/RippleAddress.py +++ b/python/trezorlib/messages/RippleAddress.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/RippleGetAddress.py b/python/trezorlib/messages/RippleGetAddress.py index 00be6b5c90..feed574367 100644 --- a/python/trezorlib/messages/RippleGetAddress.py +++ b/python/trezorlib/messages/RippleGetAddress.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/RipplePayment.py b/python/trezorlib/messages/RipplePayment.py index 30bea49027..eb51de89b1 100644 --- a/python/trezorlib/messages/RipplePayment.py +++ b/python/trezorlib/messages/RipplePayment.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/RippleSignTx.py b/python/trezorlib/messages/RippleSignTx.py index 453c960c17..add6be8e6a 100644 --- a/python/trezorlib/messages/RippleSignTx.py +++ b/python/trezorlib/messages/RippleSignTx.py @@ -7,6 +7,7 @@ from .RipplePayment import RipplePayment if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/RippleSignedTx.py b/python/trezorlib/messages/RippleSignedTx.py index 2dca8f5cb6..4397fcd29a 100644 --- a/python/trezorlib/messages/RippleSignedTx.py +++ b/python/trezorlib/messages/RippleSignedTx.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/SelfTest.py b/python/trezorlib/messages/SelfTest.py index 74b259c4b8..fdac7a38a2 100644 --- a/python/trezorlib/messages/SelfTest.py +++ b/python/trezorlib/messages/SelfTest.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/SetU2FCounter.py b/python/trezorlib/messages/SetU2FCounter.py index 3733c7fcda..2e399ee7d1 100644 --- a/python/trezorlib/messages/SetU2FCounter.py +++ b/python/trezorlib/messages/SetU2FCounter.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/SignIdentity.py b/python/trezorlib/messages/SignIdentity.py index 0d195f045c..923b163274 100644 --- a/python/trezorlib/messages/SignIdentity.py +++ b/python/trezorlib/messages/SignIdentity.py @@ -7,6 +7,7 @@ from .IdentityType import IdentityType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/SignMessage.py b/python/trezorlib/messages/SignMessage.py index c238d91814..15fe907732 100644 --- a/python/trezorlib/messages/SignMessage.py +++ b/python/trezorlib/messages/SignMessage.py @@ -5,8 +5,11 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypeInputScriptType = Literal[0, 1, 2, 3, 4] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeInputScriptType = None # type: ignore class SignMessage(p.MessageType): @@ -17,7 +20,7 @@ class SignMessage(p.MessageType): address_n: List[int] = None, message: bytes = None, coin_name: str = None, - script_type: int = None, + script_type: EnumTypeInputScriptType = None, ) -> None: self.address_n = address_n if address_n is not None else [] self.message = message @@ -30,5 +33,5 @@ class SignMessage(p.MessageType): 1: ('address_n', p.UVarintType, p.FLAG_REPEATED), 2: ('message', p.BytesType, 0), # required 3: ('coin_name', p.UnicodeType, 0), # default=Bitcoin - 4: ('script_type', p.UVarintType, 0), # default=SPENDADDRESS + 4: ('script_type', p.EnumType("InputScriptType", (0, 1, 2, 3, 4)), 0), # default=SPENDADDRESS } diff --git a/python/trezorlib/messages/SignTx.py b/python/trezorlib/messages/SignTx.py index c3f0e21735..bfd05c198e 100644 --- a/python/trezorlib/messages/SignTx.py +++ b/python/trezorlib/messages/SignTx.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/SignedIdentity.py b/python/trezorlib/messages/SignedIdentity.py index e161559eeb..c2555d46c1 100644 --- a/python/trezorlib/messages/SignedIdentity.py +++ b/python/trezorlib/messages/SignedIdentity.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/StellarAccountMergeOp.py b/python/trezorlib/messages/StellarAccountMergeOp.py index 784271e31b..acf3a5241d 100644 --- a/python/trezorlib/messages/StellarAccountMergeOp.py +++ b/python/trezorlib/messages/StellarAccountMergeOp.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/StellarAddress.py b/python/trezorlib/messages/StellarAddress.py index 3fc08233c6..1176e3c0d8 100644 --- a/python/trezorlib/messages/StellarAddress.py +++ b/python/trezorlib/messages/StellarAddress.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/StellarAllowTrustOp.py b/python/trezorlib/messages/StellarAllowTrustOp.py index 08c359fd7b..8cb252dfad 100644 --- a/python/trezorlib/messages/StellarAllowTrustOp.py +++ b/python/trezorlib/messages/StellarAllowTrustOp.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/StellarAssetType.py b/python/trezorlib/messages/StellarAssetType.py index c541e19f2f..f6585de435 100644 --- a/python/trezorlib/messages/StellarAssetType.py +++ b/python/trezorlib/messages/StellarAssetType.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/StellarBumpSequenceOp.py b/python/trezorlib/messages/StellarBumpSequenceOp.py index 4d85f84b33..321d80f455 100644 --- a/python/trezorlib/messages/StellarBumpSequenceOp.py +++ b/python/trezorlib/messages/StellarBumpSequenceOp.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/StellarChangeTrustOp.py b/python/trezorlib/messages/StellarChangeTrustOp.py index 8b431fd07c..af56938a18 100644 --- a/python/trezorlib/messages/StellarChangeTrustOp.py +++ b/python/trezorlib/messages/StellarChangeTrustOp.py @@ -7,6 +7,7 @@ from .StellarAssetType import StellarAssetType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/StellarCreateAccountOp.py b/python/trezorlib/messages/StellarCreateAccountOp.py index ea91dbb29e..f91f71d165 100644 --- a/python/trezorlib/messages/StellarCreateAccountOp.py +++ b/python/trezorlib/messages/StellarCreateAccountOp.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/StellarCreatePassiveOfferOp.py b/python/trezorlib/messages/StellarCreatePassiveOfferOp.py index ae0666b0c1..ad1b732bfa 100644 --- a/python/trezorlib/messages/StellarCreatePassiveOfferOp.py +++ b/python/trezorlib/messages/StellarCreatePassiveOfferOp.py @@ -7,6 +7,7 @@ from .StellarAssetType import StellarAssetType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/StellarGetAddress.py b/python/trezorlib/messages/StellarGetAddress.py index 59ee797be1..4bfb586edf 100644 --- a/python/trezorlib/messages/StellarGetAddress.py +++ b/python/trezorlib/messages/StellarGetAddress.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/StellarManageDataOp.py b/python/trezorlib/messages/StellarManageDataOp.py index a057274de0..f8b64ca7ed 100644 --- a/python/trezorlib/messages/StellarManageDataOp.py +++ b/python/trezorlib/messages/StellarManageDataOp.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/StellarManageOfferOp.py b/python/trezorlib/messages/StellarManageOfferOp.py index 271b864a6f..f385812732 100644 --- a/python/trezorlib/messages/StellarManageOfferOp.py +++ b/python/trezorlib/messages/StellarManageOfferOp.py @@ -7,6 +7,7 @@ from .StellarAssetType import StellarAssetType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/StellarPathPaymentOp.py b/python/trezorlib/messages/StellarPathPaymentOp.py index 5bd662385f..a50ff0b6ae 100644 --- a/python/trezorlib/messages/StellarPathPaymentOp.py +++ b/python/trezorlib/messages/StellarPathPaymentOp.py @@ -7,6 +7,7 @@ from .StellarAssetType import StellarAssetType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/StellarPaymentOp.py b/python/trezorlib/messages/StellarPaymentOp.py index 2e79ca1022..3800cdba68 100644 --- a/python/trezorlib/messages/StellarPaymentOp.py +++ b/python/trezorlib/messages/StellarPaymentOp.py @@ -7,6 +7,7 @@ from .StellarAssetType import StellarAssetType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/StellarSetOptionsOp.py b/python/trezorlib/messages/StellarSetOptionsOp.py index ae38a446ab..83630879e5 100644 --- a/python/trezorlib/messages/StellarSetOptionsOp.py +++ b/python/trezorlib/messages/StellarSetOptionsOp.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/StellarSignTx.py b/python/trezorlib/messages/StellarSignTx.py index 1fb6a1f0ca..d782b437e6 100644 --- a/python/trezorlib/messages/StellarSignTx.py +++ b/python/trezorlib/messages/StellarSignTx.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/StellarSignedTx.py b/python/trezorlib/messages/StellarSignedTx.py index e572bfcf55..586ef2164d 100644 --- a/python/trezorlib/messages/StellarSignedTx.py +++ b/python/trezorlib/messages/StellarSignedTx.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/StellarTxOpRequest.py b/python/trezorlib/messages/StellarTxOpRequest.py index e149367b0a..40c3895720 100644 --- a/python/trezorlib/messages/StellarTxOpRequest.py +++ b/python/trezorlib/messages/StellarTxOpRequest.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/Success.py b/python/trezorlib/messages/Success.py index f7e6381ba1..643ae0b078 100644 --- a/python/trezorlib/messages/Success.py +++ b/python/trezorlib/messages/Success.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/TezosAddress.py b/python/trezorlib/messages/TezosAddress.py index 7ac3654982..09e3fee4c3 100644 --- a/python/trezorlib/messages/TezosAddress.py +++ b/python/trezorlib/messages/TezosAddress.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/TezosBallotOp.py b/python/trezorlib/messages/TezosBallotOp.py index 938d355bc1..4ab4f6ea1c 100644 --- a/python/trezorlib/messages/TezosBallotOp.py +++ b/python/trezorlib/messages/TezosBallotOp.py @@ -5,8 +5,11 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypeTezosBallotType = Literal[0, 1, 2] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeTezosBallotType = None # type: ignore class TezosBallotOp(p.MessageType): @@ -16,7 +19,7 @@ class TezosBallotOp(p.MessageType): source: bytes = None, period: int = None, proposal: bytes = None, - ballot: int = None, + ballot: EnumTypeTezosBallotType = None, ) -> None: self.source = source self.period = period @@ -29,5 +32,5 @@ class TezosBallotOp(p.MessageType): 1: ('source', p.BytesType, 0), 2: ('period', p.UVarintType, 0), 3: ('proposal', p.BytesType, 0), - 4: ('ballot', p.UVarintType, 0), + 4: ('ballot', p.EnumType("TezosBallotType", (0, 1, 2)), 0), } diff --git a/python/trezorlib/messages/TezosContractID.py b/python/trezorlib/messages/TezosContractID.py index 5663692382..9a3c840445 100644 --- a/python/trezorlib/messages/TezosContractID.py +++ b/python/trezorlib/messages/TezosContractID.py @@ -5,15 +5,18 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypeTezosContractType = Literal[0, 1] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeTezosContractType = None # type: ignore class TezosContractID(p.MessageType): def __init__( self, - tag: int = None, + tag: EnumTypeTezosContractType = None, hash: bytes = None, ) -> None: self.tag = tag @@ -22,6 +25,6 @@ class TezosContractID(p.MessageType): @classmethod def get_fields(cls) -> Dict: return { - 1: ('tag', p.UVarintType, 0), + 1: ('tag', p.EnumType("TezosContractType", (0, 1)), 0), 2: ('hash', p.BytesType, 0), } diff --git a/python/trezorlib/messages/TezosDelegationOp.py b/python/trezorlib/messages/TezosDelegationOp.py index f1e4df9f0c..2b16836084 100644 --- a/python/trezorlib/messages/TezosDelegationOp.py +++ b/python/trezorlib/messages/TezosDelegationOp.py @@ -7,6 +7,7 @@ from .TezosContractID import TezosContractID if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/TezosGetAddress.py b/python/trezorlib/messages/TezosGetAddress.py index 673be8df91..d62e8efa59 100644 --- a/python/trezorlib/messages/TezosGetAddress.py +++ b/python/trezorlib/messages/TezosGetAddress.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/TezosGetPublicKey.py b/python/trezorlib/messages/TezosGetPublicKey.py index f2aa5cad83..fb4e733c21 100644 --- a/python/trezorlib/messages/TezosGetPublicKey.py +++ b/python/trezorlib/messages/TezosGetPublicKey.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/TezosOriginationOp.py b/python/trezorlib/messages/TezosOriginationOp.py index e0aaba871e..509612553a 100644 --- a/python/trezorlib/messages/TezosOriginationOp.py +++ b/python/trezorlib/messages/TezosOriginationOp.py @@ -7,6 +7,7 @@ from .TezosContractID import TezosContractID if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/TezosProposalOp.py b/python/trezorlib/messages/TezosProposalOp.py index 12a4338919..1ce7089f9f 100644 --- a/python/trezorlib/messages/TezosProposalOp.py +++ b/python/trezorlib/messages/TezosProposalOp.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/TezosPublicKey.py b/python/trezorlib/messages/TezosPublicKey.py index 008e034db7..ddcb11f458 100644 --- a/python/trezorlib/messages/TezosPublicKey.py +++ b/python/trezorlib/messages/TezosPublicKey.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/TezosRevealOp.py b/python/trezorlib/messages/TezosRevealOp.py index 00d73911f2..2471b97893 100644 --- a/python/trezorlib/messages/TezosRevealOp.py +++ b/python/trezorlib/messages/TezosRevealOp.py @@ -7,6 +7,7 @@ from .TezosContractID import TezosContractID if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/TezosSignTx.py b/python/trezorlib/messages/TezosSignTx.py index e59a3d275f..3e29e19e02 100644 --- a/python/trezorlib/messages/TezosSignTx.py +++ b/python/trezorlib/messages/TezosSignTx.py @@ -12,6 +12,7 @@ from .TezosTransactionOp import TezosTransactionOp if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/TezosSignedTx.py b/python/trezorlib/messages/TezosSignedTx.py index 31632ecedd..f232a87780 100644 --- a/python/trezorlib/messages/TezosSignedTx.py +++ b/python/trezorlib/messages/TezosSignedTx.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/TezosTransactionOp.py b/python/trezorlib/messages/TezosTransactionOp.py index f7acb4a235..33e9b4e26b 100644 --- a/python/trezorlib/messages/TezosTransactionOp.py +++ b/python/trezorlib/messages/TezosTransactionOp.py @@ -7,6 +7,7 @@ from .TezosContractID import TezosContractID if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/TransactionType.py b/python/trezorlib/messages/TransactionType.py index dbf49b5ee2..e289d4555c 100644 --- a/python/trezorlib/messages/TransactionType.py +++ b/python/trezorlib/messages/TransactionType.py @@ -9,6 +9,7 @@ from .TxOutputType import TxOutputType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/TxAck.py b/python/trezorlib/messages/TxAck.py index eed13b8227..2734adb208 100644 --- a/python/trezorlib/messages/TxAck.py +++ b/python/trezorlib/messages/TxAck.py @@ -7,6 +7,7 @@ from .TransactionType import TransactionType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/TxInputType.py b/python/trezorlib/messages/TxInputType.py index 4cef19622e..bc4240e714 100644 --- a/python/trezorlib/messages/TxInputType.py +++ b/python/trezorlib/messages/TxInputType.py @@ -7,8 +7,11 @@ from .MultisigRedeemScriptType import MultisigRedeemScriptType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypeInputScriptType = Literal[0, 1, 2, 3, 4] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeInputScriptType = None # type: ignore class TxInputType(p.MessageType): @@ -20,7 +23,7 @@ class TxInputType(p.MessageType): prev_index: int = None, script_sig: bytes = None, sequence: int = None, - script_type: int = None, + script_type: EnumTypeInputScriptType = None, multisig: MultisigRedeemScriptType = None, amount: int = None, decred_tree: int = None, @@ -49,7 +52,7 @@ class TxInputType(p.MessageType): 3: ('prev_index', p.UVarintType, 0), # required 4: ('script_sig', p.BytesType, 0), 5: ('sequence', p.UVarintType, 0), # default=4294967295 - 6: ('script_type', p.UVarintType, 0), # default=SPENDADDRESS + 6: ('script_type', p.EnumType("InputScriptType", (0, 1, 2, 3, 4)), 0), # default=SPENDADDRESS 7: ('multisig', MultisigRedeemScriptType, 0), 8: ('amount', p.UVarintType, 0), 9: ('decred_tree', p.UVarintType, 0), diff --git a/python/trezorlib/messages/TxOutputBinType.py b/python/trezorlib/messages/TxOutputBinType.py index ce9af99d6f..965b3d8ecb 100644 --- a/python/trezorlib/messages/TxOutputBinType.py +++ b/python/trezorlib/messages/TxOutputBinType.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/TxOutputType.py b/python/trezorlib/messages/TxOutputType.py index 9f1c9ae6dd..de32eb404d 100644 --- a/python/trezorlib/messages/TxOutputType.py +++ b/python/trezorlib/messages/TxOutputType.py @@ -7,8 +7,11 @@ from .MultisigRedeemScriptType import MultisigRedeemScriptType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypeOutputScriptType = Literal[0, 1, 2, 3, 4, 5] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeOutputScriptType = None # type: ignore class TxOutputType(p.MessageType): @@ -18,7 +21,7 @@ class TxOutputType(p.MessageType): address: str = None, address_n: List[int] = None, amount: int = None, - script_type: int = None, + script_type: EnumTypeOutputScriptType = None, multisig: MultisigRedeemScriptType = None, op_return_data: bytes = None, decred_script_version: int = None, @@ -41,7 +44,7 @@ class TxOutputType(p.MessageType): 1: ('address', p.UnicodeType, 0), 2: ('address_n', p.UVarintType, p.FLAG_REPEATED), 3: ('amount', p.UVarintType, 0), # required - 4: ('script_type', p.UVarintType, 0), # required + 4: ('script_type', p.EnumType("OutputScriptType", (0, 1, 2, 3, 4, 5)), 0), # required 5: ('multisig', MultisigRedeemScriptType, 0), 6: ('op_return_data', p.BytesType, 0), 7: ('decred_script_version', p.UVarintType, 0), diff --git a/python/trezorlib/messages/TxRequest.py b/python/trezorlib/messages/TxRequest.py index 05cfac1313..e7ad696102 100644 --- a/python/trezorlib/messages/TxRequest.py +++ b/python/trezorlib/messages/TxRequest.py @@ -8,8 +8,11 @@ from .TxRequestSerializedType import TxRequestSerializedType if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypeRequestType = Literal[0, 1, 2, 3, 4] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeRequestType = None # type: ignore class TxRequest(p.MessageType): @@ -17,7 +20,7 @@ class TxRequest(p.MessageType): def __init__( self, - request_type: int = None, + request_type: EnumTypeRequestType = None, details: TxRequestDetailsType = None, serialized: TxRequestSerializedType = None, ) -> None: @@ -28,7 +31,7 @@ class TxRequest(p.MessageType): @classmethod def get_fields(cls) -> Dict: return { - 1: ('request_type', p.UVarintType, 0), + 1: ('request_type', p.EnumType("RequestType", (0, 1, 2, 3, 4)), 0), 2: ('details', TxRequestDetailsType, 0), 3: ('serialized', TxRequestSerializedType, 0), } diff --git a/python/trezorlib/messages/TxRequestDetailsType.py b/python/trezorlib/messages/TxRequestDetailsType.py index aacb316378..bde924fb65 100644 --- a/python/trezorlib/messages/TxRequestDetailsType.py +++ b/python/trezorlib/messages/TxRequestDetailsType.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/TxRequestSerializedType.py b/python/trezorlib/messages/TxRequestSerializedType.py index 28afa7bb4a..20b4b44a4b 100644 --- a/python/trezorlib/messages/TxRequestSerializedType.py +++ b/python/trezorlib/messages/TxRequestSerializedType.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/VerifyMessage.py b/python/trezorlib/messages/VerifyMessage.py index a0ca2e043a..96c1fee6b6 100644 --- a/python/trezorlib/messages/VerifyMessage.py +++ b/python/trezorlib/messages/VerifyMessage.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/WipeDevice.py b/python/trezorlib/messages/WipeDevice.py index c55969feab..ad020af20b 100644 --- a/python/trezorlib/messages/WipeDevice.py +++ b/python/trezorlib/messages/WipeDevice.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/WordAck.py b/python/trezorlib/messages/WordAck.py index ef354926a4..f851e21e9d 100644 --- a/python/trezorlib/messages/WordAck.py +++ b/python/trezorlib/messages/WordAck.py @@ -5,6 +5,7 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 except ImportError: Dict, List, Optional = None, None, None # type: ignore diff --git a/python/trezorlib/messages/WordRequest.py b/python/trezorlib/messages/WordRequest.py index 582a6dda56..c3c68a588f 100644 --- a/python/trezorlib/messages/WordRequest.py +++ b/python/trezorlib/messages/WordRequest.py @@ -5,8 +5,11 @@ from .. import protobuf as p if __debug__: try: from typing import Dict, List, Optional + from typing_extensions import Literal # noqa: F401 + EnumTypeWordRequestType = Literal[0, 1, 2] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeWordRequestType = None # type: ignore class WordRequest(p.MessageType): @@ -14,12 +17,12 @@ class WordRequest(p.MessageType): def __init__( self, - type: int = None, + type: EnumTypeWordRequestType = None, ) -> None: self.type = type @classmethod def get_fields(cls) -> Dict: return { - 1: ('type', p.UVarintType, 0), + 1: ('type', p.EnumType("WordRequestType", (0, 1, 2)), 0), } diff --git a/python/trezorlib/protobuf.py b/python/trezorlib/protobuf.py index 77d817501a..1fd6699f30 100644 --- a/python/trezorlib/protobuf.py +++ b/python/trezorlib/protobuf.py @@ -37,11 +37,14 @@ required: >>> """ ''' +import logging from io import BytesIO from typing import Any, Optional _UVARINT_BUFFER = bytearray(1) +LOG = logging.getLogger(__name__) + def load_uvarint(reader): buffer = _UVARINT_BUFFER @@ -116,6 +119,45 @@ class BoolType: WIRE_TYPE = 0 +class EnumType: + WIRE_TYPE = 0 + + def __init__(self, enum_name, enum_values): + self.enum_name = enum_name + self.enum_values = enum_values + + def validate(self, fvalue: int) -> int: + if fvalue not in self.enum_values: + # raise TypeError("Invalid enum value") + LOG.warning("Value {} unknown for type {}".format(fvalue, self.enum_name)) + return fvalue + + def to_str(self, fvalue: int) -> str: + from . import messages + + module = getattr(messages, self.enum_name) + for name in dir(module): + if name.startswith("__"): + continue + if getattr(module, name) == fvalue: + return name + else: + raise TypeError("Invalid enum value") + + def from_str(self, fstr: str) -> int: + try: + from . import messages + + module = getattr(messages, self.enum_name) + ivalue = getattr(module, fstr) + if isinstance(ivalue, int): + return ivalue + else: + raise TypeError("Invalid enum value") + except AttributeError: + raise TypeError("Invalid enum value") from None + + class BytesType: WIRE_TYPE = 2 @@ -235,6 +277,8 @@ def load_message(reader, msg_type): fvalue = uint_to_sint(ivalue) elif ftype is BoolType: fvalue = bool(ivalue) + elif isinstance(ftype, EnumType): + fvalue = ftype.validate(ivalue) elif ftype is BytesType: buf = bytearray(ivalue) reader.readinto(buf) @@ -287,6 +331,9 @@ def dump_message(writer, msg): elif ftype is BoolType: dump_uvarint(writer, int(svalue)) + elif isinstance(ftype, EnumType): + dump_uvarint(writer, ftype.validate(svalue)) + elif ftype is BytesType: dump_uvarint(writer, len(svalue)) writer.write(svalue) @@ -321,11 +368,19 @@ def format_message( printable = sum(1 for byte in bytes if 0x20 <= byte <= 0x7E) return printable / len(bytes) > 0.8 - def pformat_value(value: Any, indent: int) -> str: + def get_type(name: str) -> Any: + try: + return next(ft for fn, ft, _ in pb.get_fields().values() if fn == name) + except StopIteration: + return None + + def pformat(name: str, value: Any, indent: int) -> str: level = sep * indent leadin = sep * (indent + 1) + if isinstance(value, MessageType): return format_message(value, indent, sep) + if isinstance(value, list): # short list of simple values if not value or not isinstance(value[0], MessageType): @@ -333,16 +388,18 @@ def format_message( # long list, one line per entry lines = ["[", level + "]"] - lines[1:1] = [leadin + pformat_value(x, indent + 1) + "," for x in value] + lines[1:1] = [leadin + pformat(name, x, indent + 1) + "," for x in value] return "\n".join(lines) + if isinstance(value, dict): lines = ["{"] for key, val in sorted(value.items()): if val is None or val == []: continue - lines.append(leadin + key + ": " + pformat_value(val, indent + 1) + ",") + lines.append(leadin + key + ": " + pformat(key, val, indent + 1) + ",") lines.append(level + "}") return "\n".join(lines) + if isinstance(value, (bytes, bytearray)): length = len(value) suffix = "" @@ -355,42 +412,33 @@ def format_message( output = "0x" + value.hex() return "{} bytes {}{}".format(length, output, suffix) + if isinstance(value, int): + ftype = get_type(name) + if isinstance(ftype, EnumType): + return ftype.to_str(value) + return repr(value) return "{name} ({size} bytes) {content}".format( name=pb.__class__.__name__, size=pb.ByteSize(), - content=pformat_value(pb.__dict__, indent), + content=pformat("", pb.__dict__, indent), ) -_ALL_ENUMS = {} - - -def _make_all_enums(): - if not _ALL_ENUMS: - import inspect - from . import messages - - for attr in messages.__dict__.values(): - if not inspect.ismodule(attr): - continue - for name in dir(attr): - value = getattr(attr, name) - if isinstance(value, int): - _ALL_ENUMS[name] = value - - def value_to_proto(ftype, value): - if issubclass(ftype, MessageType): + if isinstance(ftype, type) and issubclass(ftype, MessageType): raise TypeError("value_to_proto only converts simple values") - if ftype in (UVarintType, SVarintType): - if isinstance(value, str) and value in _ALL_ENUMS: - return _ALL_ENUMS[value] + if isinstance(ftype, EnumType): + if isinstance(value, str): + return ftype.from_str(value) else: return int(value) + if ftype in (UVarintType, SVarintType): + return int(value) + if ftype is BoolType: return bool(value) @@ -407,8 +455,6 @@ def value_to_proto(ftype, value): def dict_to_proto(message_type, d): - _make_all_enums() - params = {} for fname, ftype, fflags in message_type.get_fields().values(): repeated = fflags & FLAG_REPEATED @@ -419,7 +465,7 @@ def dict_to_proto(message_type, d): if not repeated: value = [value] - if issubclass(ftype, MessageType): + if isinstance(ftype, type) and issubclass(ftype, MessageType): function = dict_to_proto else: function = value_to_proto diff --git a/python/trezorlib/tests/unit_tests/test_protobuf.py b/python/trezorlib/tests/unit_tests/test_protobuf.py index ef2017a560..b8e51b8553 100644 --- a/python/trezorlib/tests/unit_tests/test_protobuf.py +++ b/python/trezorlib/tests/unit_tests/test_protobuf.py @@ -19,6 +19,7 @@ from io import BytesIO import pytest from trezorlib import protobuf +from trezorlib.messages import InputScriptType class PrimitiveMessage(protobuf.MessageType): @@ -30,9 +31,22 @@ class PrimitiveMessage(protobuf.MessageType): 2: ("bool", protobuf.BoolType, 0), 3: ("bytes", protobuf.BytesType, 0), 4: ("unicode", protobuf.UnicodeType, 0), + 5: ("enum", protobuf.EnumType("t", (0, 5, 25)), 0), } +class EnumMessageMoreValues(protobuf.MessageType): + @classmethod + def get_fields(cls): + return {0: ("enum", protobuf.EnumType("t", (0, 1, 2, 3, 4, 5)), 0)} + + +class EnumMessageLessValues(protobuf.MessageType): + @classmethod + def get_fields(cls): + return {0: ("enum", protobuf.EnumType("t", (0, 5)), 0)} + + def load_uvarint(buffer): reader = BytesIO(buffer) return protobuf.load_uvarint(reader) @@ -89,6 +103,7 @@ def test_simple_message(): bool=True, bytes=b"\xDE\xAD\xCA\xFE", unicode="Příliš žluťoučký kůň úpěl ďábelské ódy 😊", + enum=5, ) buf = BytesIO() @@ -103,3 +118,55 @@ def test_simple_message(): assert retr.bool is True assert retr.bytes == b"\xDE\xAD\xCA\xFE" assert retr.unicode == "Příliš žluťoučký kůň úpěl ďábelské ódy 😊" + assert retr.enum == 5 + + +def test_validate_enum(caplog): + # round-trip of a valid value + msg = EnumMessageMoreValues(enum=0) + buf = BytesIO() + protobuf.dump_message(buf, msg) + buf.seek(0) + retr = protobuf.load_message(buf, EnumMessageLessValues) + assert retr.enum == msg.enum + + assert not caplog.records + + # dumping an invalid enum value fails + msg.enum = 19 + buf.seek(0) + protobuf.dump_message(buf, msg) + + assert len(caplog.records) == 1 + record = caplog.records.pop(0) + assert record.levelname == "WARNING" + assert record.getMessage() == "Value 19 unknown for type t" + + msg.enum = 3 + buf.seek(0) + protobuf.dump_message(buf, msg) + buf.seek(0) + protobuf.load_message(buf, EnumMessageLessValues) + + assert len(caplog.records) == 1 + record = caplog.records.pop(0) + assert record.levelname == "WARNING" + assert record.getMessage() == "Value 3 unknown for type t" + + +def test_enum_to_str(): + enum_values = [ + (key, getattr(InputScriptType, key)) + for key in dir(InputScriptType) + if not key.startswith("__") + ] + enum_type = protobuf.EnumType("InputScriptType", [v for _, v in enum_values]) + for name, value in enum_values: + assert enum_type.to_str(value) == name + assert enum_type.from_str(name) == value + + with pytest.raises(TypeError): + enum_type.from_str("NotAValidValue") + + with pytest.raises(TypeError): + enum_type.to_str(999) diff --git a/tools/build_protobuf b/tools/build_protobuf index af78ce9c64..7935e9aca1 100755 --- a/tools/build_protobuf +++ b/tools/build_protobuf @@ -40,7 +40,6 @@ CORE_MESSAGES_IGNORE="\ PinMatrixAck \ PinMatrixRequest \ PinMatrixRequestType \ - RecoveryDeviceType \ WordAck \ WordRequest \ WordRequestType \