From cb7152542d9ab0c07d12eeb79567c1ce7c2d7d35 Mon Sep 17 00:00:00 2001 From: matejcik Date: Wed, 17 Mar 2021 11:24:55 +0100 Subject: [PATCH] feat: drop DebugLinkShowText functionality --- common/protob/messages-debug.proto | 26 ---------- common/protob/messages.proto | 1 - core/CHANGELOG.md | 1 + core/src/apps/debug/__init__.py | 1 - core/src/apps/debug/show_text.py | 49 ------------------- core/src/trezor/messages/DebugLinkShowText.py | 38 -------------- .../trezor/messages/DebugLinkShowTextItem.py | 30 ------------ .../trezor/messages/DebugLinkShowTextStyle.py | 14 ------ core/src/trezor/messages/MessageType.py | 1 - python/CHANGELOG.md | 1 + python/src/trezorlib/cli/debug.py | 49 +------------------ python/src/trezorlib/cli/trezorctl.py | 1 - python/src/trezorlib/debuglink.py | 15 ------ .../trezorlib/messages/DebugLinkShowText.py | 38 -------------- .../messages/DebugLinkShowTextItem.py | 30 ------------ .../messages/DebugLinkShowTextStyle.py | 14 ------ python/src/trezorlib/messages/MessageType.py | 1 - python/src/trezorlib/messages/__init__.py | 3 -- 18 files changed, 3 insertions(+), 310 deletions(-) delete mode 100644 core/src/apps/debug/show_text.py delete mode 100644 core/src/trezor/messages/DebugLinkShowText.py delete mode 100644 core/src/trezor/messages/DebugLinkShowTextItem.py delete mode 100644 core/src/trezor/messages/DebugLinkShowTextStyle.py delete mode 100644 python/src/trezorlib/messages/DebugLinkShowText.py delete mode 100644 python/src/trezorlib/messages/DebugLinkShowTextItem.py delete mode 100644 python/src/trezorlib/messages/DebugLinkShowTextStyle.py diff --git a/common/protob/messages-debug.proto b/common/protob/messages-debug.proto index 4cf41752c7..fdda7d4af9 100644 --- a/common/protob/messages-debug.proto +++ b/common/protob/messages-debug.proto @@ -58,32 +58,6 @@ message DebugLinkRecordScreen { optional string target_directory = 1; // empty or missing to stop recording } -/** - * Request: Show text on the screen - * @start - * @next Success - */ - message DebugLinkShowText { - optional string header_text = 1; // screen header text - repeated DebugLinkShowTextItem body_text = 2; // body text segments - optional string header_icon = 3; // icon name in ui.style - optional string icon_color = 4; // color name in ui.style - - message DebugLinkShowTextItem { - optional DebugLinkShowTextStyle style = 1; - optional string content = 2; - } - - enum DebugLinkShowTextStyle { - NORMAL = 0; - BOLD = 1; - MONO = 2; - BR = 4; - BR_HALF = 5; - SET_COLOR = 6; - } -} - /** * Request: Computer asks for device state * @start diff --git a/common/protob/messages.proto b/common/protob/messages.proto index 019309b5c5..b513628c5f 100644 --- a/common/protob/messages.proto +++ b/common/protob/messages.proto @@ -136,7 +136,6 @@ enum MessageType { MessageType_DebugLinkLayout = 9001 [(wire_debug_out) = true]; MessageType_DebugLinkReseedRandom = 9002 [(wire_debug_in) = true]; MessageType_DebugLinkRecordScreen = 9003 [(wire_debug_in) = true]; - MessageType_DebugLinkShowText = 9004 [(wire_debug_in) = true]; MessageType_DebugLinkEraseSdCard = 9005 [(wire_debug_in) = true]; MessageType_DebugLinkWatchLayout = 9006 [(wire_debug_in) = true]; diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index 279c80dc1f..eae87420f5 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -57,6 +57,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Removed - PIVX support +- dropped debug-only `DebugLinkShowText` functionality ### Fixed - Path warning is not shown on `GetAddress(show_display=False)` call. [#1206] diff --git a/core/src/apps/debug/__init__.py b/core/src/apps/debug/__init__.py index deec7709eb..4a68b0fe0f 100644 --- a/core/src/apps/debug/__init__.py +++ b/core/src/apps/debug/__init__.py @@ -185,7 +185,6 @@ if __debug__: config.wipe() wire.add(MessageType.LoadDevice, __name__, "load_device") - wire.add(MessageType.DebugLinkShowText, __name__, "show_text") wire.register(MessageType.DebugLinkDecision, dispatch_DebugLinkDecision) # type: ignore wire.register(MessageType.DebugLinkGetState, dispatch_DebugLinkGetState) wire.register(MessageType.DebugLinkReseedRandom, dispatch_DebugLinkReseedRandom) diff --git a/core/src/apps/debug/show_text.py b/core/src/apps/debug/show_text.py deleted file mode 100644 index c7092dbee9..0000000000 --- a/core/src/apps/debug/show_text.py +++ /dev/null @@ -1,49 +0,0 @@ -import trezor.messages.DebugLinkShowTextStyle as S -from trezor import ui, wire -from trezor.messages.DebugLinkShowText import DebugLinkShowText -from trezor.messages.Success import Success -from trezor.ui import style, text -from trezor.ui.components.tt.text import Text - -from apps.common.confirm import confirm - -STYLES = { - S.NORMAL: ui.NORMAL, - S.BOLD: ui.BOLD, - S.MONO: ui.MONO, - S.BR: text.BR, - S.BR_HALF: text.BR_HALF, -} - - -async def show_text(ctx: wire.Context, msg: DebugLinkShowText) -> Success: - if msg.header_icon is not None: - icon_name = "ICON_" + msg.header_icon - icon = getattr(style, icon_name) - if not isinstance(icon, str): - raise wire.DataError("Invalid icon name: {}".format(msg.header_icon)) - else: - icon = style.ICON_DEFAULT - - if msg.icon_color is not None: - color = getattr(style, msg.icon_color) - if not isinstance(color, int): - raise wire.DataError("Invalid color name: {}".format(msg.icon_color)) - else: - color = style.ORANGE_ICON - - dlg = Text(msg.header_text, icon, color, new_lines=False) - for item in msg.body_text: - if item.style in STYLES: - dlg.content.append(STYLES[item.style]) - elif item.style == S.SET_COLOR: - color = getattr(style, item.content) - if not isinstance(color, int): - raise wire.DataError("Invalid color name: {}".format(item.content)) - dlg.content.append(color) - - elif item.content is not None: - dlg.content.append(item.content) - - await confirm(ctx, dlg) - return Success("text shown") diff --git a/core/src/trezor/messages/DebugLinkShowText.py b/core/src/trezor/messages/DebugLinkShowText.py deleted file mode 100644 index 9098e247b7..0000000000 --- a/core/src/trezor/messages/DebugLinkShowText.py +++ /dev/null @@ -1,38 +0,0 @@ -# Automatically generated by pb2py -# fmt: off -import protobuf as p - -from .DebugLinkShowTextItem import DebugLinkShowTextItem - -if __debug__: - try: - from typing import Dict, List # noqa: F401 - from typing_extensions import Literal # noqa: F401 - except ImportError: - pass - - -class DebugLinkShowText(p.MessageType): - MESSAGE_WIRE_TYPE = 9004 - - def __init__( - self, - *, - body_text: List[DebugLinkShowTextItem] = None, - header_text: str = None, - header_icon: str = None, - icon_color: str = None, - ) -> None: - self.body_text = body_text if body_text is not None else [] - self.header_text = header_text - self.header_icon = header_icon - self.icon_color = icon_color - - @classmethod - def get_fields(cls) -> Dict: - return { - 1: ('header_text', p.UnicodeType, None), - 2: ('body_text', DebugLinkShowTextItem, p.FLAG_REPEATED), - 3: ('header_icon', p.UnicodeType, None), - 4: ('icon_color', p.UnicodeType, None), - } diff --git a/core/src/trezor/messages/DebugLinkShowTextItem.py b/core/src/trezor/messages/DebugLinkShowTextItem.py deleted file mode 100644 index bd714f515b..0000000000 --- a/core/src/trezor/messages/DebugLinkShowTextItem.py +++ /dev/null @@ -1,30 +0,0 @@ -# Automatically generated by pb2py -# fmt: off -import protobuf as p - -if __debug__: - try: - from typing import Dict, List # noqa: F401 - from typing_extensions import Literal # noqa: F401 - EnumTypeDebugLinkShowTextStyle = Literal[0, 1, 2, 4, 5, 6] - except ImportError: - pass - - -class DebugLinkShowTextItem(p.MessageType): - - def __init__( - self, - *, - style: EnumTypeDebugLinkShowTextStyle = None, - content: str = None, - ) -> None: - self.style = style - self.content = content - - @classmethod - def get_fields(cls) -> Dict: - return { - 1: ('style', p.EnumType("DebugLinkShowTextStyle", (0, 1, 2, 4, 5, 6)), None), - 2: ('content', p.UnicodeType, None), - } diff --git a/core/src/trezor/messages/DebugLinkShowTextStyle.py b/core/src/trezor/messages/DebugLinkShowTextStyle.py deleted file mode 100644 index 8ead39e99c..0000000000 --- a/core/src/trezor/messages/DebugLinkShowTextStyle.py +++ /dev/null @@ -1,14 +0,0 @@ -# Automatically generated by pb2py -# fmt: off -if __debug__: - try: - from typing_extensions import Literal # noqa: F401 - except ImportError: - pass - -NORMAL: Literal[0] = 0 -BOLD: Literal[1] = 1 -MONO: Literal[2] = 2 -BR: Literal[4] = 4 -BR_HALF: Literal[5] = 5 -SET_COLOR: Literal[6] = 6 diff --git a/core/src/trezor/messages/MessageType.py b/core/src/trezor/messages/MessageType.py index c273eff6b0..c882511507 100644 --- a/core/src/trezor/messages/MessageType.py +++ b/core/src/trezor/messages/MessageType.py @@ -89,7 +89,6 @@ DebugLinkFlashErase: Literal[113] = 113 DebugLinkLayout: Literal[9001] = 9001 DebugLinkReseedRandom: Literal[9002] = 9002 DebugLinkRecordScreen: Literal[9003] = 9003 -DebugLinkShowText: Literal[9004] = 9004 DebugLinkEraseSdCard: Literal[9005] = 9005 DebugLinkWatchLayout: Literal[9006] = 9006 if not utils.BITCOIN_ONLY: diff --git a/python/CHANGELOG.md b/python/CHANGELOG.md index 94cd97b2cf..09507b3e0e 100644 --- a/python/CHANGELOG.md +++ b/python/CHANGELOG.md @@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Removed - dropped Python 3.5 support [#810] +- dropped debug-only `trezorctl debug show-text` functionality ## [0.12.2] - 2020-08-27 diff --git a/python/src/trezorlib/cli/debug.py b/python/src/trezorlib/cli/debug.py index 2499c7eedb..8c579716d0 100644 --- a/python/src/trezorlib/cli/debug.py +++ b/python/src/trezorlib/cli/debug.py @@ -16,9 +16,7 @@ import click -from .. import debuglink, mapping, messages, protobuf -from ..messages import DebugLinkShowTextStyle as S -from . import with_client +from .. import mapping, messages, protobuf @click.group(name="debug") @@ -26,51 +24,6 @@ def cli(): """Miscellaneous debug features.""" -STYLES = { - "@@NORMAL": S.NORMAL, - "@@BOLD": S.BOLD, - "@@MONO": S.MONO, - "@@BR": S.BR, - "@@BR_HALF": S.BR_HALF, -} - - -@cli.command() -@click.option("-i", "--icon", help="Header icon name") -@click.option("-c", "--color", help="Header icon color") -@click.option("-h", "--header", help="Header text", default="Showing text") -@click.argument("body") -@with_client -def show_text(client, icon, color, header, body): - """Show text on Trezor display. - - For usage instructions, see: - https://github.com/trezor/trezor-firmware/blob/master/docs/python/show-text.md - """ - body = body.split() - body_text = [] - words = [] - - def _flush(): - if words: - body_text.append((None, " ".join(words))) - words.clear() - - for word in body: - if word in STYLES: - _flush() - body_text.append((STYLES[word], None)) - elif word.startswith("%%"): - _flush() - body_text.append((S.SET_COLOR, word[2:])) - else: - words.append(word) - - _flush() - - return debuglink.show_text(client, header, body_text, icon=icon, icon_color=color) - - @cli.command() @click.argument("message_name_or_type") @click.argument("hex_data") diff --git a/python/src/trezorlib/cli/trezorctl.py b/python/src/trezorlib/cli/trezorctl.py index fcbeaad78b..ea2b8a62c4 100755 --- a/python/src/trezorlib/cli/trezorctl.py +++ b/python/src/trezorlib/cli/trezorctl.py @@ -63,7 +63,6 @@ COMMAND_ALIASES = { "sd-protect": device.sd_protect, "load-device": device.load, "self-test": device.self_test, - "show-text": debug.show_text, "get-entropy": crypto.get_entropy, "encrypt-keyvalue": crypto.encrypt_keyvalue, "decrypt-keyvalue": crypto.decrypt_keyvalue, diff --git a/python/src/trezorlib/debuglink.py b/python/src/trezorlib/debuglink.py index a17223d1de..ba08ec8744 100644 --- a/python/src/trezorlib/debuglink.py +++ b/python/src/trezorlib/debuglink.py @@ -664,18 +664,3 @@ def self_test(client): payload=b"\x00\xFF\x55\xAA\x66\x99\x33\xCCABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!\x00\xFF\x55\xAA\x66\x99\x33\xCC" ) ) - - -@expect(messages.Success, field="message") -def show_text(client, header_text, body_text, icon=None, icon_color=None): - body_text = [ - messages.DebugLinkShowTextItem(style=style, content=content) - for style, content in body_text - ] - msg = messages.DebugLinkShowText( - header_text=header_text, - body_text=body_text, - header_icon=icon, - icon_color=icon_color, - ) - return client.call(msg) diff --git a/python/src/trezorlib/messages/DebugLinkShowText.py b/python/src/trezorlib/messages/DebugLinkShowText.py deleted file mode 100644 index e6d3b79f67..0000000000 --- a/python/src/trezorlib/messages/DebugLinkShowText.py +++ /dev/null @@ -1,38 +0,0 @@ -# Automatically generated by pb2py -# fmt: off -from .. import protobuf as p - -from .DebugLinkShowTextItem import DebugLinkShowTextItem - -if __debug__: - try: - from typing import Dict, List # noqa: F401 - from typing_extensions import Literal # noqa: F401 - except ImportError: - pass - - -class DebugLinkShowText(p.MessageType): - MESSAGE_WIRE_TYPE = 9004 - - def __init__( - self, - *, - body_text: List[DebugLinkShowTextItem] = None, - header_text: str = None, - header_icon: str = None, - icon_color: str = None, - ) -> None: - self.body_text = body_text if body_text is not None else [] - self.header_text = header_text - self.header_icon = header_icon - self.icon_color = icon_color - - @classmethod - def get_fields(cls) -> Dict: - return { - 1: ('header_text', p.UnicodeType, None), - 2: ('body_text', DebugLinkShowTextItem, p.FLAG_REPEATED), - 3: ('header_icon', p.UnicodeType, None), - 4: ('icon_color', p.UnicodeType, None), - } diff --git a/python/src/trezorlib/messages/DebugLinkShowTextItem.py b/python/src/trezorlib/messages/DebugLinkShowTextItem.py deleted file mode 100644 index a8af170df7..0000000000 --- a/python/src/trezorlib/messages/DebugLinkShowTextItem.py +++ /dev/null @@ -1,30 +0,0 @@ -# Automatically generated by pb2py -# fmt: off -from .. import protobuf as p - -if __debug__: - try: - from typing import Dict, List # noqa: F401 - from typing_extensions import Literal # noqa: F401 - EnumTypeDebugLinkShowTextStyle = Literal[0, 1, 2, 4, 5, 6] - except ImportError: - pass - - -class DebugLinkShowTextItem(p.MessageType): - - def __init__( - self, - *, - style: EnumTypeDebugLinkShowTextStyle = None, - content: str = None, - ) -> None: - self.style = style - self.content = content - - @classmethod - def get_fields(cls) -> Dict: - return { - 1: ('style', p.EnumType("DebugLinkShowTextStyle", (0, 1, 2, 4, 5, 6)), None), - 2: ('content', p.UnicodeType, None), - } diff --git a/python/src/trezorlib/messages/DebugLinkShowTextStyle.py b/python/src/trezorlib/messages/DebugLinkShowTextStyle.py deleted file mode 100644 index 8ead39e99c..0000000000 --- a/python/src/trezorlib/messages/DebugLinkShowTextStyle.py +++ /dev/null @@ -1,14 +0,0 @@ -# Automatically generated by pb2py -# fmt: off -if __debug__: - try: - from typing_extensions import Literal # noqa: F401 - except ImportError: - pass - -NORMAL: Literal[0] = 0 -BOLD: Literal[1] = 1 -MONO: Literal[2] = 2 -BR: Literal[4] = 4 -BR_HALF: Literal[5] = 5 -SET_COLOR: Literal[6] = 6 diff --git a/python/src/trezorlib/messages/MessageType.py b/python/src/trezorlib/messages/MessageType.py index 279d777dec..6f7e20982c 100644 --- a/python/src/trezorlib/messages/MessageType.py +++ b/python/src/trezorlib/messages/MessageType.py @@ -87,7 +87,6 @@ DebugLinkFlashErase: Literal[113] = 113 DebugLinkLayout: Literal[9001] = 9001 DebugLinkReseedRandom: Literal[9002] = 9002 DebugLinkRecordScreen: Literal[9003] = 9003 -DebugLinkShowText: Literal[9004] = 9004 DebugLinkEraseSdCard: Literal[9005] = 9005 DebugLinkWatchLayout: Literal[9006] = 9006 EthereumGetPublicKey: Literal[450] = 450 diff --git a/python/src/trezorlib/messages/__init__.py b/python/src/trezorlib/messages/__init__.py index d0efebf800..e99f9d51d5 100644 --- a/python/src/trezorlib/messages/__init__.py +++ b/python/src/trezorlib/messages/__init__.py @@ -59,8 +59,6 @@ from .DebugLinkMemoryRead import DebugLinkMemoryRead from .DebugLinkMemoryWrite import DebugLinkMemoryWrite from .DebugLinkRecordScreen import DebugLinkRecordScreen from .DebugLinkReseedRandom import DebugLinkReseedRandom -from .DebugLinkShowText import DebugLinkShowText -from .DebugLinkShowTextItem import DebugLinkShowTextItem from .DebugLinkState import DebugLinkState from .DebugLinkStop import DebugLinkStop from .DebugLinkWatchLayout import DebugLinkWatchLayout @@ -312,7 +310,6 @@ from . import Capability from . import CardanoAddressType from . import CardanoCertificateType from . import CardanoPoolRelayType -from . import DebugLinkShowTextStyle from . import DebugSwipeDirection from . import DecredStakingSpendType from . import FailureType