From 1a71c7a3e89afae6fbc2e4323e26914b0d327e8c Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Wed, 28 Aug 2019 12:42:33 +0200 Subject: [PATCH] common: rename Features.features to Features.capabilities --- common/protob/messages-management.proto | 36 +++++++-------- core/src/apps/homescreen/__init__.py | 46 +++++++++---------- .../messages/{Feature.py => Capability.py} | 0 core/src/trezor/messages/Features.py | 10 ++-- legacy/firmware/fsm_msg_common.h | 24 +++++----- .../protob/messages-management.options | 2 +- .../messages/{Feature.py => Capability.py} | 0 python/src/trezorlib/messages/Features.py | 10 ++-- python/src/trezorlib/messages/__init__.py | 2 +- tools/build_protobuf | 10 ++-- 10 files changed, 70 insertions(+), 70 deletions(-) rename core/src/trezor/messages/{Feature.py => Capability.py} (100%) rename python/src/trezorlib/messages/{Feature.py => Capability.py} (100%) diff --git a/common/protob/messages-management.proto b/common/protob/messages-management.proto index 71f535f94..58c5dbd3d 100644 --- a/common/protob/messages-management.proto +++ b/common/protob/messages-management.proto @@ -58,24 +58,24 @@ 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; - Feature_Shamir = 15; - Feature_ShamirGroups = 16; + repeated Capability capabilities = 30; // list of supported capabilities + enum Capability { + Capability_Bitcoin = 1; + Capability_Bitcoin_like = 2; // Altcoins based on the Bitcoin source code + Capability_Binance = 3; + Capability_Cardano = 4; + Capability_Crypto = 5; // generic crypto operations for GPG, SSH, etc. + Capability_EOS = 6; + Capability_Ethereum = 7; + Capability_Lisk = 8; + Capability_Monero = 9; + Capability_NEM = 10; + Capability_Ripple = 11; + Capability_Stellar = 12; + Capability_Tezos = 13; + Capability_U2F = 14; + Capability_Shamir = 15; + Capability_ShamirGroups = 16; } } diff --git a/core/src/apps/homescreen/__init__.py b/core/src/apps/homescreen/__init__.py index 2b2c2d24a..85ba10a08 100644 --- a/core/src/apps/homescreen/__init__.py +++ b/core/src/apps/homescreen/__init__.py @@ -1,5 +1,5 @@ from trezor import config, utils, wire -from trezor.messages import Feature, MessageType +from trezor.messages import Capability, MessageType from trezor.messages.Features import Features from trezor.messages.Success import Success from trezor.wire import register @@ -37,30 +37,30 @@ def get_features() -> Features: f.flags = storage.device.get_flags() f.recovery_mode = storage.recovery.is_in_progress() if utils.BITCOIN_ONLY: - f.features = [ - Feature.Bitcoin, - Feature.Crypto, - Feature.Shamir, - Feature.ShamirGroups, + f.capabilities = [ + Capability.Bitcoin, + Capability.Crypto, + Capability.Shamir, + Capability.ShamirGroups, ] else: - f.features = [ - Feature.Bitcoin, - Feature.Bitcoin_like, - Feature.Binance, - Feature.Cardano, - Feature.Crypto, - Feature.EOS, - Feature.Ethereum, - Feature.Lisk, - Feature.Monero, - Feature.NEM, - Feature.Ripple, - Feature.Stellar, - Feature.Tezos, - Feature.U2F, - Feature.Shamir, - Feature.ShamirGroups, + f.capabilities = [ + Capability.Bitcoin, + Capability.Bitcoin_like, + Capability.Binance, + Capability.Cardano, + Capability.Crypto, + Capability.EOS, + Capability.Ethereum, + Capability.Lisk, + Capability.Monero, + Capability.NEM, + Capability.Ripple, + Capability.Stellar, + Capability.Tezos, + Capability.U2F, + Capability.Shamir, + Capability.ShamirGroups, ] return f diff --git a/core/src/trezor/messages/Feature.py b/core/src/trezor/messages/Capability.py similarity index 100% rename from core/src/trezor/messages/Feature.py rename to core/src/trezor/messages/Capability.py diff --git a/core/src/trezor/messages/Features.py b/core/src/trezor/messages/Features.py index 1556c1e6d..139ab0b78 100644 --- a/core/src/trezor/messages/Features.py +++ b/core/src/trezor/messages/Features.py @@ -6,10 +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, 15, 16] + EnumTypeCapability = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] except ImportError: Dict, List, Optional = None, None, None # type: ignore - EnumTypeFeature = None # type: ignore + EnumTypeCapability = None # type: ignore class Features(p.MessageType): @@ -45,7 +45,7 @@ class Features(p.MessageType): unfinished_backup: bool = None, no_backup: bool = None, recovery_mode: bool = None, - features: List[EnumTypeFeature] = None, + capabilities: List[EnumTypeCapability] = None, ) -> None: self.vendor = vendor self.major_version = major_version @@ -75,7 +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 [] + self.capabilities = capabilities if capabilities is not None else [] @classmethod def get_fields(cls) -> Dict: @@ -108,5 +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, 15, 16)), p.FLAG_REPEATED), + 30: ('capabilities', p.EnumType("Capability", (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)), p.FLAG_REPEATED), } diff --git a/legacy/firmware/fsm_msg_common.h b/legacy/firmware/fsm_msg_common.h index 594e3920c..bb12db1b0 100644 --- a/legacy/firmware/fsm_msg_common.h +++ b/legacy/firmware/fsm_msg_common.h @@ -84,19 +84,19 @@ void fsm_msgGetFeatures(const GetFeatures *msg) { strlcpy(resp->model, "1", sizeof(resp->model)); #if BITCOIN_ONLY - resp->features_count = 2; - resp->features[0] = Feature_Feature_Bitcoin; - resp->features[1] = Feature_Feature_Crypto; + resp->capabilities_count = 2; + resp->capabilities[0] = Capability_Capability_Bitcoin; + resp->capabilities[1] = Capability_Capability_Crypto; #else - resp->features_count = 8; - resp->features[0] = Feature_Feature_Bitcoin; - resp->features[1] = Feature_Feature_Bitcoin_like; - resp->features[2] = Feature_Feature_Crypto; - resp->features[3] = Feature_Feature_Ethereum; - resp->features[4] = Feature_Feature_Lisk; - resp->features[5] = Feature_Feature_NEM; - resp->features[6] = Feature_Feature_Stellar; - resp->features[7] = Feature_Feature_U2F; + resp->capabilities_count = 8; + resp->capabilities[0] = Capability_Capability_Bitcoin; + resp->capabilities[1] = Capability_Capability_Bitcoin_like; + resp->capabilities[2] = Capability_Capability_Crypto; + resp->capabilities[3] = Capability_Capability_Ethereum; + resp->capabilities[4] = Capability_Capability_Lisk; + resp->capabilities[5] = Capability_Capability_NEM; + resp->capabilities[6] = Capability_Capability_Stellar; + resp->capabilities[7] = Capability_Capability_U2F; #endif msg_write(MessageType_MessageType_Features, resp); diff --git a/legacy/firmware/protob/messages-management.options b/legacy/firmware/protob/messages-management.options index 3df823797..bd7971d7c 100644 --- a/legacy/firmware/protob/messages-management.options +++ b/legacy/firmware/protob/messages-management.options @@ -9,7 +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 +Features.capabilities 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/Capability.py similarity index 100% rename from python/src/trezorlib/messages/Feature.py rename to python/src/trezorlib/messages/Capability.py diff --git a/python/src/trezorlib/messages/Features.py b/python/src/trezorlib/messages/Features.py index 5e22895df..31fbe93f1 100644 --- a/python/src/trezorlib/messages/Features.py +++ b/python/src/trezorlib/messages/Features.py @@ -6,10 +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, 15, 16] + EnumTypeCapability = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] except ImportError: Dict, List, Optional = None, None, None # type: ignore - EnumTypeFeature = None # type: ignore + EnumTypeCapability = None # type: ignore class Features(p.MessageType): @@ -45,7 +45,7 @@ class Features(p.MessageType): unfinished_backup: bool = None, no_backup: bool = None, recovery_mode: bool = None, - features: List[EnumTypeFeature] = None, + capabilities: List[EnumTypeCapability] = None, ) -> None: self.vendor = vendor self.major_version = major_version @@ -75,7 +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 [] + self.capabilities = capabilities if capabilities is not None else [] @classmethod def get_fields(cls) -> Dict: @@ -108,5 +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, 15, 16)), p.FLAG_REPEATED), + 30: ('capabilities', p.EnumType("Capability", (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)), p.FLAG_REPEATED), } diff --git a/python/src/trezorlib/messages/__init__.py b/python/src/trezorlib/messages/__init__.py index f28813cb1..8415b1cb1 100644 --- a/python/src/trezorlib/messages/__init__.py +++ b/python/src/trezorlib/messages/__init__.py @@ -254,8 +254,8 @@ from . import BinanceOrderSide from . import BinanceOrderType from . import BinanceTimeInForce from . import ButtonRequestType +from . import Capability from . import FailureType -from . import Feature from . import InputScriptType from . import LiskTransactionType from . import MessageType diff --git a/tools/build_protobuf b/tools/build_protobuf index 80409b984..b5484f582 100755 --- a/tools/build_protobuf +++ b/tools/build_protobuf @@ -69,17 +69,17 @@ do_rebuild() { # TODO: make this less hackish # maybe introduce attribute "altcoin" in protobuf? if [ "$APPLY_BITCOIN_ONLY" == "TRUE" ]; then - sed -i "3ifrom trezor import utils\n" "$DESTDIR"/Feature.py + sed -i "3ifrom trezor import utils\n" "$DESTDIR"/Capability.py sed -i "3ifrom trezor import utils\n" "$DESTDIR"/MessageType.py sed -i "/^EthereumGetPublicKey/iif not utils.BITCOIN_ONLY:" "$DESTDIR"/MessageType.py for altcoin in Ethereum NEM Lisk Tezos Stellar Cardano Ripple Monero DebugMonero Eos Binance; do - sed -i "s:^$altcoin: $altcoin:" "$DESTDIR"/Feature.py + sed -i "s:^$altcoin: $altcoin:" "$DESTDIR"/Capability.py sed -i "s:^$altcoin: $altcoin:" "$DESTDIR"/MessageType.py done - sed -i "/^Bitcoin_like/iif not utils.BITCOIN_ONLY:" "$DESTDIR"/Feature.py - sed -i "/^EOS/iif not utils.BITCOIN_ONLY:" "$DESTDIR"/Feature.py + sed -i "/^Bitcoin_like/iif not utils.BITCOIN_ONLY:" "$DESTDIR"/Capability.py + sed -i "/^EOS/iif not utils.BITCOIN_ONLY:" "$DESTDIR"/Capability.py for feature in Bitcoin_like EOS U2F; do - sed -i "s:^$feature: $feature:" "$DESTDIR"/Feature.py + sed -i "s:^$feature: $feature:" "$DESTDIR"/Capability.py done fi # ENDTODO