Skip to content

Commit 07c4694

Browse files
committed
fix(core): misc fix
1. fix Solana signing issue 2. optimize Ethereum sign-typed-data display 3. optimize the auto screen off logic
1 parent 0f4d0cf commit 07c4694

9 files changed

Lines changed: 28 additions & 86 deletions

File tree

core/src/apps/base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,9 @@ def boot() -> None:
822822
)
823823
workflow_handlers.register(MessageType.UnLockDevice, handle_UnLockDevice)
824824

825-
reload_settings_from_storage()
825+
reload_settings_from_storage(
826+
timeout_ms=10 * 1000 if utils.is_rest_by_usb_lock() else None
827+
)
826828
from trezor.lvglui.scrs import fingerprints
827829

828830
if config.is_unlocked() and fingerprints.is_unlocked():

core/src/apps/ethereum/onekey/sign_typed_data.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,4 +593,5 @@ async def confirm_domain(ctx: Context, typed_data_envelope: TypedDataEnvelope) -
593593
eip712_domain[member.name] = value
594594
from ..layout import confirm_domain
595595

596-
await confirm_domain(ctx, eip712_domain)
596+
if eip712_domain:
597+
await confirm_domain(ctx, eip712_domain)

core/src/apps/solana/sign_tx.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ async def sign_tx(
6767
print(
6868
f"Invalid signer used: {PublicKey(fee_payer.get())} != {PublicKey(signer_pub_key_bytes)}"
6969
)
70-
raise wire.DataError("Invalid signer used")
70+
else:
71+
raise wire.DataError("Invalid signer used")
7172
else:
7273
if PublicKey(signer_pub_key_bytes) not in accounts_keys[:sigs_count]:
7374
raise wire.DataError("Invalid transaction params")

core/src/apps/solana/spl/spl_token_program.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ async def parse(ctx: wire.Context, accounts: list[PublicKey], data: bytes) -> No
437437
from ..constents import SPL_TOKEN_PROGRAM_ID
438438

439439
owner_address = None
440-
if hasattr(ctx, "extra"):
440+
if ctx.extra is not None:
441441
owner_address = try_get_token_account_owner_address(
442442
params.dest.get(),
443443
SPL_TOKEN_PROGRAM_ID.get(),

core/src/trezor/lvglui/scrs/template.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2741,7 +2741,7 @@ def __init__(
27412741
if warning_banner_text:
27422742
self.warning_banner = Banner(
27432743
self.content_area,
2744-
3,
2744+
2,
27452745
warning_banner_text,
27462746
)
27472747
self.warning_banner.align_to(self.title, lv.ALIGN.OUT_BOTTOM_MID, 0, 40)

core/src/trezor/messages.py

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8869,44 +8869,6 @@ def __init__(
88698869
def is_type_of(cls, msg: Any) -> TypeGuard["StellarSignedTx"]:
88708870
return isinstance(msg, cls)
88718871

8872-
class StellarSignMessage(protobuf.MessageType):
8873-
address_n: "list[int]"
8874-
message: "bytes"
8875-
8876-
def __init__(
8877-
self,
8878-
*,
8879-
message: "bytes",
8880-
address_n: "list[int] | None" = None,
8881-
) -> None:
8882-
pass
8883-
8884-
@classmethod
8885-
def is_type_of(cls, msg: Any) -> TypeGuard["StellarSignMessage"]:
8886-
return isinstance(msg, cls)
8887-
8888-
class StellarSignAuthorization(protobuf.MessageType):
8889-
address_n: "list[int]"
8890-
network_passphrase: "str"
8891-
nonce: "int"
8892-
expiration: "int"
8893-
invocation: "bytes"
8894-
8895-
def __init__(
8896-
self,
8897-
*,
8898-
network_passphrase: "str",
8899-
nonce: "int",
8900-
expiration: "int",
8901-
invocation: "bytes",
8902-
address_n: "list[int] | None" = None,
8903-
) -> None:
8904-
pass
8905-
8906-
@classmethod
8907-
def is_type_of(cls, msg: Any) -> TypeGuard["StellarSignAuthorization"]:
8908-
return isinstance(msg, cls)
8909-
89108872
class SuiGetAddress(protobuf.MessageType):
89118873
address_n: "list[int]"
89128874
show_display: "bool | None"

core/src/trezor/uart.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ async def handle_usb_state():
182182
while True:
183183
try:
184184
utils.USB_STATE_CHANGED = False
185+
utils.unmark_rest_by_usb_lock()
185186
usb_state = loop.wait(io.USB_STATE)
186187
state, enable = await usb_state
187188
if enable is not None and utils.is_usb_enabled():
@@ -226,6 +227,7 @@ async def handle_usb_state():
226227
else:
227228
config.lock()
228229
await safe_reloop()
230+
utils.mark_rest_by_usb_lock()
229231
await workflow.spawn(utils.internal_reloop())
230232
elif not usb_auto_lock and not state:
231233
await safe_reloop(ack=False)

core/src/trezor/utils.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ def board_version() -> str:
8888
CHARGE_ENABLE: bool | None = None
8989
CHARGING = False
9090
USB_STATE_CHANGED = False
91+
_REST_AFTER_USB_LOCK = False
9192
RESTART_MAIN_LOOP = False
9293
_WIRE_BUSY = False
9394
_PENDING_SLEEP_AFTER_CANCEL = False
@@ -387,6 +388,22 @@ def mark_collecting_fingerprint_done():
387388
_COLLECTING_FINGERPRINT = False
388389

389390

391+
def is_rest_by_usb_lock():
392+
return _REST_AFTER_USB_LOCK
393+
394+
395+
def mark_rest_by_usb_lock():
396+
global _REST_AFTER_USB_LOCK
397+
398+
_REST_AFTER_USB_LOCK = True
399+
400+
401+
def unmark_rest_by_usb_lock():
402+
global _REST_AFTER_USB_LOCK
403+
404+
_REST_AFTER_USB_LOCK = False
405+
406+
390407
def set_backup_none():
391408
global _CURRENT_BACKUP_METHOD
392409
_CURRENT_BACKUP_METHOD = BACKUP_METHOD_NONE

python/src/trezorlib/messages.py

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -11052,49 +11052,6 @@ def __init__(
1105211052
self.signature = signature
1105311053

1105411054

11055-
class StellarSignMessage(protobuf.MessageType):
11056-
MESSAGE_WIRE_TYPE = None
11057-
FIELDS = {
11058-
1: protobuf.Field("address_n", "uint32", repeated=True, required=False),
11059-
2: protobuf.Field("message", "bytes", repeated=False, required=True),
11060-
}
11061-
11062-
def __init__(
11063-
self,
11064-
*,
11065-
message: "bytes",
11066-
address_n: Optional[Sequence["int"]] = None,
11067-
) -> None:
11068-
self.address_n: Sequence["int"] = address_n if address_n is not None else []
11069-
self.message = message
11070-
11071-
11072-
class StellarSignAuthorization(protobuf.MessageType):
11073-
MESSAGE_WIRE_TYPE = None
11074-
FIELDS = {
11075-
1: protobuf.Field("address_n", "uint32", repeated=True, required=False),
11076-
2: protobuf.Field("network_passphrase", "string", repeated=False, required=True),
11077-
3: protobuf.Field("nonce", "uint64", repeated=False, required=True),
11078-
4: protobuf.Field("expiration", "uint32", repeated=False, required=True),
11079-
5: protobuf.Field("invocation", "bytes", repeated=False, required=True),
11080-
}
11081-
11082-
def __init__(
11083-
self,
11084-
*,
11085-
network_passphrase: "str",
11086-
nonce: "int",
11087-
expiration: "int",
11088-
invocation: "bytes",
11089-
address_n: Optional[Sequence["int"]] = None,
11090-
) -> None:
11091-
self.address_n: Sequence["int"] = address_n if address_n is not None else []
11092-
self.network_passphrase = network_passphrase
11093-
self.nonce = nonce
11094-
self.expiration = expiration
11095-
self.invocation = invocation
11096-
11097-
1109811055
class SuiGetAddress(protobuf.MessageType):
1109911056
MESSAGE_WIRE_TYPE = 11100
1110011057
FIELDS = {

0 commit comments

Comments
 (0)