Skip to content

Commit

Permalink
fix(core): fix conflict and style check
Browse files Browse the repository at this point in the history
  • Loading branch information
somebodyLi committed Aug 27, 2024
1 parent 705b037 commit fff3b8c
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 148 deletions.
16 changes: 0 additions & 16 deletions common/protob/messages-ur.proto

This file was deleted.

6 changes: 3 additions & 3 deletions core/mocks/generated/trezorconfig.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""


Expand Down
3 changes: 3 additions & 0 deletions core/src/apps/ur_registry/chains/bitcoin/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
122 changes: 60 additions & 62 deletions core/src/trezor/lvglui/scrs/homescreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand All @@ -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))
Expand Down
1 change: 0 additions & 1 deletion core/src/trezor/lvglui/scrs/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -3174,7 +3174,6 @@ def __init__(
title,
subtitle,
qr_code,
primary_color,
encoder=None,
):
super().__init__(
Expand Down
30 changes: 0 additions & 30 deletions core/src/trezor/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions core/src/trezor/uart.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 1 addition & 2 deletions core/src/trezor/ui/layouts/lvgl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down
31 changes: 0 additions & 31 deletions python/src/trezorlib/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit fff3b8c

Please sign in to comment.