From fff3b8c97f6c21bae982d8ce481926315c2cfb21 Mon Sep 17 00:00:00 2001 From: Ritchie Date: Tue, 27 Aug 2024 18:35:02 +0800 Subject: [PATCH] fix(core): fix conflict and style check --- common/protob/messages-ur.proto | 16 --- core/mocks/generated/trezorconfig.pyi | 6 +- .../ur_registry/chains/bitcoin/transaction.py | 3 + core/src/trezor/lvglui/scrs/homescreen.py | 122 +++++++++--------- core/src/trezor/lvglui/scrs/template.py | 1 - core/src/trezor/messages.py | 30 ----- core/src/trezor/uart.py | 4 +- core/src/trezor/ui/layouts/lvgl/__init__.py | 3 +- python/src/trezorlib/messages.py | 31 ----- 9 files changed, 68 insertions(+), 148 deletions(-) delete mode 100644 common/protob/messages-ur.proto diff --git a/common/protob/messages-ur.proto b/common/protob/messages-ur.proto deleted file mode 100644 index bfaf94f67..000000000 --- a/common/protob/messages-ur.proto +++ /dev/null @@ -1,16 +0,0 @@ -syntax = "proto2"; -package hw.trezor.messages.ur; - -// Sugar for easier handling in Java -option java_package = "com.satoshilabs.trezor.lib.protobuf"; -option java_outer_classname = "TrezorMessageUR"; - -message URCryptoHdkey { - repeated uint32 address_n = 1; - optional bool show_display = 2; -} - -message URResponse { - optional string data = 1; // Sui address as hex-encoded string -} - diff --git a/core/mocks/generated/trezorconfig.pyi b/core/mocks/generated/trezorconfig.pyi index d9ae2e9f3..7e8f6f6b7 100644 --- a/core/mocks/generated/trezorconfig.pyi +++ b/core/mocks/generated/trezorconfig.pyi @@ -116,9 +116,9 @@ def set_needs_backup(needs_backup: bool = False) -> bool: # extmod/modtrezorconfig/modtrezorconfig.c def get_val_len(app: int, key: int, public: bool = False) -> int: """ - Gets the length of the value of the given key for the given app (or None if not set). - Raises a RuntimeError if decryption or authentication of the stored - value fails. + Gets the length of the value of the given key for the given app (or None + if not set). Raises a RuntimeError if decryption or authentication of + the stored value fails. """ diff --git a/core/src/apps/ur_registry/chains/bitcoin/transaction.py b/core/src/apps/ur_registry/chains/bitcoin/transaction.py index 43e1c2454..3818217e4 100644 --- a/core/src/apps/ur_registry/chains/bitcoin/transaction.py +++ b/core/src/apps/ur_registry/chains/bitcoin/transaction.py @@ -391,7 +391,10 @@ async def run(self): # Determine if we need to do more passes to sign everything if our_keys > passes: passes = our_keys + if not found: # None of our keys were in hd_keypaths or in partial_sigs + # This input is not one of ours + raise Exception("Invalid input params") # append to inputs inputs.append(txinputtype) self.inputs = inputs diff --git a/core/src/trezor/lvglui/scrs/homescreen.py b/core/src/trezor/lvglui/scrs/homescreen.py index 6b0bf9407..d87a073a8 100644 --- a/core/src/trezor/lvglui/scrs/homescreen.py +++ b/core/src/trezor/lvglui/scrs/homescreen.py @@ -1189,23 +1189,21 @@ def __init__(self, prev_scr=None): self.content_area, self.subtitle, padding_row=2 ) + self.onekey = ListItemBtn( + self.container, + _(i18n_keys.ITEM__ONEKEY_WALLET), + _(i18n_keys.CONTENT__BTC_AND_EVM_COMPATIBLE_NETWORKS), + left_img_src="A:/res/ok-logo-48.png", + ) + self.onekey.text_layout_vertical() + self.mm = ListItemBtn( self.container, _(i18n_keys.ITEM__METAMASK_WALLET), _(i18n_keys.CONTENT__ETH_AND_EVM_POWERED_NETWORK), left_img_src="A:/res/mm-logo-48.png", ) - self.mm.text_layout_vertical() - - self.onekey = ListItemBtn( - self.container, - _(i18n_keys.ITEM__ONEKEY_WALLET), - "BTC·EVM", - left_img_src="A:/res/ok-logo-48.png", - ) - self.onekey.text_layout_vertical(pad_top=17, pad_ver=20) - # self.onekey.disable() - # self.onekey.add_flag(lv.obj.FLAG.HIDDEN) + self.mm.text_layout_vertical(pad_top=17, pad_ver=20) self.okx = ListItemBtn( self.container, @@ -1250,12 +1248,13 @@ def on_click(self, event_obj): ) return ConnectWallet( - _(i18n_keys.ITEM__ONEKEY_WALLET), - "Ethereum, Polygon, Avalanche, Base and other EVM networks.", None, - "A:/res/ok-logo-96.png", - encoder, + None, + None, + encoder=encoder, + subtitle=_(i18n_keys.CONTENT__OPEN_ONEKEY_SCAN_THE_QRCODE), ) + elif target == self.mm: qr_data = ( retrieval_hd_key() @@ -1387,56 +1386,55 @@ def __init__( ) self.qr.align_to(self.subtitle, lv.ALIGN.OUT_BOTTOM_LEFT, 0, 40) - self.panel = lv.obj(self.content_area) - self.panel.set_size(456, lv.SIZE.CONTENT) - self.panel.add_style( - StyleWrapper() - .bg_color(lv_colors.ONEKEY_GRAY_3) - .bg_opa() - .radius(40) - .border_width(0) - .pad_hor(24) - .pad_ver(12) - .text_color(lv_colors.WHITE), - 0, - ) - self.label_top = lv.label(self.panel) - self.label_top.set_text(_(i18n_keys.LIST_KEY__SUPPORTED_CHAINS)) - self.label_top.add_style( - StyleWrapper().text_font(font_GeistSemiBold26).pad_ver(4).pad_hor(0), 0 - ) - self.label_top.align(lv.ALIGN.TOP_LEFT, 0, 0) - self.line = lv.line(self.panel) - self.line.set_size(408, 1) - self.line.add_style( - StyleWrapper().bg_color(lv_colors.ONEKEY_GRAY_2).bg_opa(), 0 - ) - self.line.align_to(self.label_top, lv.ALIGN.OUT_BOTTOM_LEFT, 0, 9) - self.label_bottom = lv.label(self.panel) - self.label_bottom.set_width(408) - self.label_bottom.add_style( - StyleWrapper().text_font(font_GeistRegular26).pad_ver(12).pad_hor(0), 0 - ) - self.scrolling = False - self.content_area.clear_flag(lv.obj.FLAG.SCROLL_ELASTIC) - self.content_area.clear_flag(lv.obj.FLAG.SCROLL_MOMENTUM) - self.content_area.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF) - self.label_bottom.set_long_mode(lv.label.LONG.WRAP) - self.label_bottom.set_text(support_chains) - self.label_bottom.align_to(self.line, lv.ALIGN.OUT_BOTTOM_LEFT, 0, 0) - self.panel.align_to(self.qr, lv.ALIGN.OUT_BOTTOM_MID, 0, 32) + if wallet_name and support_chains: + self.panel = lv.obj(self.content_area) + self.panel.set_size(456, lv.SIZE.CONTENT) + self.panel.add_style( + StyleWrapper() + .bg_color(lv_colors.ONEKEY_GRAY_3) + .bg_opa() + .radius(40) + .border_width(0) + .pad_hor(24) + .pad_ver(12) + .text_color(lv_colors.WHITE), + 0, + ) + self.label_top = lv.label(self.panel) + self.label_top.set_text(_(i18n_keys.LIST_KEY__SUPPORTED_CHAINS)) + self.label_top.add_style( + StyleWrapper().text_font(font_GeistSemiBold26).pad_ver(4).pad_hor(0), 0 + ) + self.label_top.align(lv.ALIGN.TOP_LEFT, 0, 0) + self.line = lv.line(self.panel) + self.line.set_size(408, 1) + self.line.add_style( + StyleWrapper().bg_color(lv_colors.ONEKEY_GRAY_2).bg_opa(), 0 + ) + self.line.align_to(self.label_top, lv.ALIGN.OUT_BOTTOM_LEFT, 0, 9) + self.label_bottom = lv.label(self.panel) + self.label_bottom.set_width(408) + self.label_bottom.add_style( + StyleWrapper().text_font(font_GeistRegular26).pad_ver(12).pad_hor(0), 0 + ) + # self.content_area.clear_flag(lv.obj.FLAG.SCROLL_ELASTIC) + # self.content_area.clear_flag(lv.obj.FLAG.SCROLL_MOMENTUM) + self.content_area.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF) + self.label_bottom.set_long_mode(lv.label.LONG.WRAP) + self.label_bottom.set_text(support_chains) + self.label_bottom.align_to(self.line, lv.ALIGN.OUT_BOTTOM_LEFT, 0, 0) + self.panel.align_to(self.qr, lv.ALIGN.OUT_BOTTOM_MID, 0, 32) self.nav_back.add_event_cb(self.on_nav_back, lv.EVENT.CLICKED, None) self.add_event_cb(self.on_nav_back, lv.EVENT.GESTURE, None) - self.add_event_cb(self.on_scroll_begin, lv.EVENT.SCROLL_BEGIN, None) - self.add_event_cb(self.on_scroll_end, lv.EVENT.SCROLL_END, None) + if encoder is not None: workflow.spawn(self.update_qr()) - def on_scroll_begin(self, event_obj): - self.scrolling = True + # def on_scroll_begin(self, event_obj): + # self.scrolling = True - def on_scroll_end(self, event_obj): - self.scrolling = False + # def on_scroll_end(self, event_obj): + # self.scrolling = False def on_nav_back(self, event_obj): code = event_obj.code @@ -1463,9 +1461,9 @@ async def update_qr(self): if stop_single in racer.finished: self.destroy() return - if self.scrolling: - await loop.sleep(5000) - continue + # if self.scrolling: + # await loop.sleep(5000) + # continue assert self.encoder is not None qr_data = self.encoder.next_part() self.qr.update(qr_data, len(qr_data)) diff --git a/core/src/trezor/lvglui/scrs/template.py b/core/src/trezor/lvglui/scrs/template.py index 59e0fbb8f..26382f029 100644 --- a/core/src/trezor/lvglui/scrs/template.py +++ b/core/src/trezor/lvglui/scrs/template.py @@ -3174,7 +3174,6 @@ def __init__( title, subtitle, qr_code, - primary_color, encoder=None, ): super().__init__( diff --git a/core/src/trezor/messages.py b/core/src/trezor/messages.py index fd907af99..19983aa5c 100644 --- a/core/src/trezor/messages.py +++ b/core/src/trezor/messages.py @@ -8672,36 +8672,6 @@ def __init__( def is_type_of(cls, msg: Any) -> TypeGuard["TronUnDelegateResourceContract"]: return isinstance(msg, cls) - class URCryptoHdkey(protobuf.MessageType): - address_n: "list[int]" - show_display: "bool | None" - - def __init__( - self, - *, - address_n: "list[int] | None" = None, - show_display: "bool | None" = None, - ) -> None: - pass - - @classmethod - def is_type_of(cls, msg: Any) -> TypeGuard["URCryptoHdkey"]: - return isinstance(msg, cls) - - class URResponse(protobuf.MessageType): - data: "str | None" - - def __init__( - self, - *, - data: "str | None" = None, - ) -> None: - pass - - @classmethod - def is_type_of(cls, msg: Any) -> TypeGuard["URResponse"]: - return isinstance(msg, cls) - class WebAuthnListResidentCredentials(protobuf.MessageType): @classmethod diff --git a/core/src/trezor/uart.py b/core/src/trezor/uart.py index f452acd7e..7bd59d2fa 100644 --- a/core/src/trezor/uart.py +++ b/core/src/trezor/uart.py @@ -1,13 +1,11 @@ import ustruct from micropython import const +from typing import TYPE_CHECKING from storage import device from trezor import config, io, log, loop, motor, utils, workflow from trezor.lvglui import StatusBar - -# from trezor.lvglui.scrs.charging import ChargingPromptScr from trezor.ui import display -from typing import TYPE_CHECKING from apps import base diff --git a/core/src/trezor/ui/layouts/lvgl/__init__.py b/core/src/trezor/ui/layouts/lvgl/__init__.py index 3cbf9659e..febe343d0 100644 --- a/core/src/trezor/ui/layouts/lvgl/__init__.py +++ b/core/src/trezor/ui/layouts/lvgl/__init__.py @@ -2058,10 +2058,9 @@ async def show_ur_response( screen = UrResponse( title, - _(i18n_keys.CONTENT__RETUNRN_TO_THE_APP_AND_SCAN_THE_SIGNED_TX_QR_CODE_BELOW), + _(i18n_keys.TITLE_CONFIRM_ADDRESS_DESC), qr_code=qr_code, encoder=encoder, - primary_color=ctx.primary_color, ) await ctx.wait(screen.request()) diff --git a/python/src/trezorlib/messages.py b/python/src/trezorlib/messages.py index 2dc30107e..d81ccdc1a 100644 --- a/python/src/trezorlib/messages.py +++ b/python/src/trezorlib/messages.py @@ -10735,37 +10735,6 @@ def __init__( self.receiver_address = receiver_address -class URCryptoHdkey(protobuf.MessageType): - MESSAGE_WIRE_TYPE = 21000 - FIELDS = { - 1: protobuf.Field("address_n", "uint32", repeated=True, required=False), - 2: protobuf.Field("show_display", "bool", repeated=False, required=False), - } - - def __init__( - self, - *, - address_n: Optional[Sequence["int"]] = None, - show_display: Optional["bool"] = None, - ) -> None: - self.address_n: Sequence["int"] = address_n if address_n is not None else [] - self.show_display = show_display - - -class URResponse(protobuf.MessageType): - MESSAGE_WIRE_TYPE = 21001 - FIELDS = { - 1: protobuf.Field("data", "string", repeated=False, required=False), - } - - def __init__( - self, - *, - data: Optional["str"] = None, - ) -> None: - self.data = data - - class WebAuthnListResidentCredentials(protobuf.MessageType): MESSAGE_WIRE_TYPE = 800