From cc184a0a302218cc4a6a65bf40ad02e83e40b4ea Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Mon, 19 Aug 2019 12:22:06 +0200 Subject: [PATCH] common: introduce Features.features enum --- common/protob/messages-management.proto | 17 +++++++++++++++++ core/src/trezor/messages/Feature.py | 16 ++++++++++++++++ core/src/trezor/messages/Features.py | 5 +++++ .../firmware/protob/messages-management.options | 1 + python/src/trezorlib/messages/Feature.py | 16 ++++++++++++++++ python/src/trezorlib/messages/Features.py | 5 +++++ python/src/trezorlib/messages/__init__.py | 1 + 7 files changed, 61 insertions(+) create mode 100644 core/src/trezor/messages/Feature.py create mode 100644 python/src/trezorlib/messages/Feature.py diff --git a/common/protob/messages-management.proto b/common/protob/messages-management.proto index dddd91b327..24eabb071f 100644 --- a/common/protob/messages-management.proto +++ b/common/protob/messages-management.proto @@ -58,6 +58,23 @@ message Features { optional bool unfinished_backup = 27; // report unfinished backup (equals to Storage.unfinished_backup) optional bool no_backup = 28; // report no backup (equals to Storage.no_backup) optional bool recovery_mode = 29; // is recovery mode in progress + repeated Feature features = 30; // list of supported features + enum Feature { + Feature_Bitcoin = 1; + Feature_Bitcoin_like = 2; // Altcoins based on the Bitcoin source code + Feature_Binance = 3; + Feature_Cardano = 4; + Feature_Crypto = 5; // generic crypto operations for GPG, SSH, etc. + Feature_EOS = 6; + Feature_Ethereum = 7; + Feature_Lisk = 8; + Feature_Monero = 9; + Feature_NEM = 10; + Feature_Ripple = 11; + Feature_Stellar = 12; + Feature_Tezos = 13; + Feature_U2F = 14; + } } /** diff --git a/core/src/trezor/messages/Feature.py b/core/src/trezor/messages/Feature.py new file mode 100644 index 0000000000..3f4a31b140 --- /dev/null +++ b/core/src/trezor/messages/Feature.py @@ -0,0 +1,16 @@ +# Automatically generated by pb2py +# fmt: off +Bitcoin = 1 +Bitcoin_like = 2 +Binance = 3 +Cardano = 4 +Crypto = 5 +EOS = 6 +Ethereum = 7 +Lisk = 8 +Monero = 9 +NEM = 10 +Ripple = 11 +Stellar = 12 +Tezos = 13 +U2F = 14 diff --git a/core/src/trezor/messages/Features.py b/core/src/trezor/messages/Features.py index f48d453e13..b9e517f9ce 100644 --- a/core/src/trezor/messages/Features.py +++ b/core/src/trezor/messages/Features.py @@ -6,8 +6,10 @@ if __debug__: try: from typing import Dict, List, Optional from typing_extensions import Literal # noqa: F401 + EnumTypeFeature = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeFeature = None # type: ignore class Features(p.MessageType): @@ -43,6 +45,7 @@ class Features(p.MessageType): unfinished_backup: bool = None, no_backup: bool = None, recovery_mode: bool = None, + features: List[EnumTypeFeature] = None, ) -> None: self.vendor = vendor self.major_version = major_version @@ -72,6 +75,7 @@ class Features(p.MessageType): self.unfinished_backup = unfinished_backup self.no_backup = no_backup self.recovery_mode = recovery_mode + self.features = features if features is not None else [] @classmethod def get_fields(cls) -> Dict: @@ -104,4 +108,5 @@ class Features(p.MessageType): 27: ('unfinished_backup', p.BoolType, 0), 28: ('no_backup', p.BoolType, 0), 29: ('recovery_mode', p.BoolType, 0), + 30: ('features', p.EnumType("Feature", (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)), p.FLAG_REPEATED), } diff --git a/legacy/firmware/protob/messages-management.options b/legacy/firmware/protob/messages-management.options index 934cb4328d..3df823797d 100644 --- a/legacy/firmware/protob/messages-management.options +++ b/legacy/firmware/protob/messages-management.options @@ -9,6 +9,7 @@ Features.bootloader_hash max_size:32 Features.model max_size:17 Features.fw_vendor max_size:256 Features.fw_vendor_keys max_size:32 +Features.features max_count:32 ApplySettings.language max_size:17 ApplySettings.label max_size:33 diff --git a/python/src/trezorlib/messages/Feature.py b/python/src/trezorlib/messages/Feature.py new file mode 100644 index 0000000000..3f4a31b140 --- /dev/null +++ b/python/src/trezorlib/messages/Feature.py @@ -0,0 +1,16 @@ +# Automatically generated by pb2py +# fmt: off +Bitcoin = 1 +Bitcoin_like = 2 +Binance = 3 +Cardano = 4 +Crypto = 5 +EOS = 6 +Ethereum = 7 +Lisk = 8 +Monero = 9 +NEM = 10 +Ripple = 11 +Stellar = 12 +Tezos = 13 +U2F = 14 diff --git a/python/src/trezorlib/messages/Features.py b/python/src/trezorlib/messages/Features.py index 88a418813c..b487cc476c 100644 --- a/python/src/trezorlib/messages/Features.py +++ b/python/src/trezorlib/messages/Features.py @@ -6,8 +6,10 @@ if __debug__: try: from typing import Dict, List, Optional from typing_extensions import Literal # noqa: F401 + EnumTypeFeature = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] except ImportError: Dict, List, Optional = None, None, None # type: ignore + EnumTypeFeature = None # type: ignore class Features(p.MessageType): @@ -43,6 +45,7 @@ class Features(p.MessageType): unfinished_backup: bool = None, no_backup: bool = None, recovery_mode: bool = None, + features: List[EnumTypeFeature] = None, ) -> None: self.vendor = vendor self.major_version = major_version @@ -72,6 +75,7 @@ class Features(p.MessageType): self.unfinished_backup = unfinished_backup self.no_backup = no_backup self.recovery_mode = recovery_mode + self.features = features if features is not None else [] @classmethod def get_fields(cls) -> Dict: @@ -104,4 +108,5 @@ class Features(p.MessageType): 27: ('unfinished_backup', p.BoolType, 0), 28: ('no_backup', p.BoolType, 0), 29: ('recovery_mode', p.BoolType, 0), + 30: ('features', p.EnumType("Feature", (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)), p.FLAG_REPEATED), } diff --git a/python/src/trezorlib/messages/__init__.py b/python/src/trezorlib/messages/__init__.py index 89f4c5fc99..f28813cb1f 100644 --- a/python/src/trezorlib/messages/__init__.py +++ b/python/src/trezorlib/messages/__init__.py @@ -255,6 +255,7 @@ from . import BinanceOrderType from . import BinanceTimeInForce from . import ButtonRequestType from . import FailureType +from . import Feature from . import InputScriptType from . import LiskTransactionType from . import MessageType