mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-08 05:32:39 +00:00
chore: minor fixes in style and reducing unnecessary diffs with main
[no changelog]
This commit is contained in:
parent
aa3c07aee2
commit
2b3a63dbae
@ -226,7 +226,6 @@ def cli_main(
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
raise click.ClickException(f"Not a valid session id: {session_id}")
|
raise click.ClickException(f"Not a valid session id: {session_id}")
|
||||||
|
|
||||||
# ctx.obj = TrezorConnection(path, bytes_session_id, passphrase_on_host, script)
|
|
||||||
ctx.obj = TrezorConnection(path, bytes_session_id, passphrase_on_host, script)
|
ctx.obj = TrezorConnection(path, bytes_session_id, passphrase_on_host, script)
|
||||||
|
|
||||||
# Optionally record the screen into a specified directory.
|
# Optionally record the screen into a specified directory.
|
||||||
@ -299,7 +298,7 @@ def list_devices(no_resolve: bool) -> Optional[Iterable["Transport"]]:
|
|||||||
"""List connected Trezor devices."""
|
"""List connected Trezor devices."""
|
||||||
if no_resolve:
|
if no_resolve:
|
||||||
for d in enumerate_devices():
|
for d in enumerate_devices():
|
||||||
print(d.get_path())
|
click.echo(d.get_path())
|
||||||
return
|
return
|
||||||
|
|
||||||
from . import get_client
|
from . import get_client
|
||||||
@ -358,7 +357,6 @@ def get_session(
|
|||||||
obj.session_id = None
|
obj.session_id = None
|
||||||
|
|
||||||
with obj.client_context() as client:
|
with obj.client_context() as client:
|
||||||
|
|
||||||
if client.features.model == "1" and client.version < (1, 9, 0):
|
if client.features.model == "1" and client.version < (1, 9, 0):
|
||||||
raise click.ClickException(
|
raise click.ClickException(
|
||||||
"Upgrade your firmware to enable session support."
|
"Upgrade your firmware to enable session support."
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# This file is part of the Trezor project.
|
# This file is part of the Trezor project.
|
||||||
#
|
#
|
||||||
# Copyright (C) 2012-2024 SatoshiLabs and contributors
|
# Copyright (C) 2012-2022 SatoshiLabs and contributors
|
||||||
#
|
#
|
||||||
# This library is free software: you can redistribute it and/or modify
|
# This library is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU Lesser General Public License version 3
|
# it under the terms of the GNU Lesser General Public License version 3
|
||||||
@ -111,9 +111,7 @@ class UnstructuredJSONReader:
|
|||||||
def top_level_value(self, key: str) -> t.Any:
|
def top_level_value(self, key: str) -> t.Any:
|
||||||
return self.dict.get(key)
|
return self.dict.get(key)
|
||||||
|
|
||||||
def find_objects_with_key_and_value(
|
def find_objects_with_key_and_value(self, key: str, value: t.Any) -> list[AnyDict]:
|
||||||
self, key: str, value: t.Any
|
|
||||||
) -> list["AnyDict"]:
|
|
||||||
def recursively_find(data: t.Any) -> t.Iterator[t.Any]:
|
def recursively_find(data: t.Any) -> t.Iterator[t.Any]:
|
||||||
if isinstance(data, dict):
|
if isinstance(data, dict):
|
||||||
if data.get(key) == value:
|
if data.get(key) == value:
|
||||||
@ -430,7 +428,6 @@ def _make_input_func(
|
|||||||
|
|
||||||
|
|
||||||
class DebugLink:
|
class DebugLink:
|
||||||
|
|
||||||
def __init__(self, transport: "Transport", auto_interact: bool = True) -> None:
|
def __init__(self, transport: "Transport", auto_interact: bool = True) -> None:
|
||||||
self.transport = transport
|
self.transport = transport
|
||||||
self.allow_interactions = auto_interact
|
self.allow_interactions = auto_interact
|
||||||
@ -536,10 +533,7 @@ class DebugLink:
|
|||||||
self._write(msg)
|
self._write(msg)
|
||||||
return self._read()
|
return self._read()
|
||||||
|
|
||||||
def state(
|
def state(self, wait_type: DebugWaitType | None = None) -> messages.DebugLinkState:
|
||||||
self,
|
|
||||||
wait_type: DebugWaitType | None = None,
|
|
||||||
) -> messages.DebugLinkState:
|
|
||||||
if wait_type is None:
|
if wait_type is None:
|
||||||
wait_type = (
|
wait_type = (
|
||||||
DebugWaitType.CURRENT_LAYOUT
|
DebugWaitType.CURRENT_LAYOUT
|
||||||
@ -1040,7 +1034,6 @@ class MessageFilter:
|
|||||||
|
|
||||||
|
|
||||||
class MessageFilterGenerator:
|
class MessageFilterGenerator:
|
||||||
|
|
||||||
def __getattr__(self, key: str) -> t.Callable[..., "MessageFilter"]:
|
def __getattr__(self, key: str) -> t.Callable[..., "MessageFilter"]:
|
||||||
message_type = getattr(messages, key)
|
message_type = getattr(messages, key)
|
||||||
return MessageFilter(message_type).update_fields
|
return MessageFilter(message_type).update_fields
|
||||||
@ -1320,6 +1313,7 @@ class TrezorClientDebugLink(TrezorClient):
|
|||||||
|
|
||||||
self.reset_debug_features(new_management_session=True)
|
self.reset_debug_features(new_management_session=True)
|
||||||
self.sync_responses()
|
self.sync_responses()
|
||||||
|
|
||||||
# So that we can choose right screenshotting logic (T1 vs TT)
|
# So that we can choose right screenshotting logic (T1 vs TT)
|
||||||
# and know the supported debug capabilities
|
# and know the supported debug capabilities
|
||||||
self.debug.model = self.model
|
self.debug.model = self.model
|
||||||
@ -1340,7 +1334,6 @@ class TrezorClientDebugLink(TrezorClient):
|
|||||||
Clears all debugging state that might have been modified by a testcase.
|
Clears all debugging state that might have been modified by a testcase.
|
||||||
"""
|
"""
|
||||||
self.ui: DebugUI = DebugUI(self.debug)
|
self.ui: DebugUI = DebugUI(self.debug)
|
||||||
# self.pin_callback = self.ui.debug_callback_button
|
|
||||||
self.in_with_statement = False
|
self.in_with_statement = False
|
||||||
self.expected_responses: list[MessageFilter] | None = None
|
self.expected_responses: list[MessageFilter] | None = None
|
||||||
self.actual_responses: list[protobuf.MessageType] | None = None
|
self.actual_responses: list[protobuf.MessageType] | None = None
|
||||||
|
@ -389,23 +389,6 @@ def _return_success(msg: "Success") -> str | None:
|
|||||||
return _deprecation_retval_helper(msg.message, stacklevel=1)
|
return _deprecation_retval_helper(msg.message, stacklevel=1)
|
||||||
|
|
||||||
|
|
||||||
# def session(
|
|
||||||
# f: "Callable[Concatenate[TrezorClient, P], R]",
|
|
||||||
# ) -> "Callable[Concatenate[TrezorClient, P], R]":
|
|
||||||
# # Decorator wraps a BaseClient method
|
|
||||||
# # with session activation / deactivation
|
|
||||||
# @functools.wraps(f)
|
|
||||||
# def wrapped_f(client: "TrezorClient", *args: "P.args", **kwargs: "P.kwargs") -> "R":
|
|
||||||
# __tracebackhide__ = True # for pytest # pylint: disable=W0612
|
|
||||||
# client.open()
|
|
||||||
# try:
|
|
||||||
# return f(client, *args, **kwargs)
|
|
||||||
# finally:
|
|
||||||
# client.close()
|
|
||||||
|
|
||||||
# return wrapped_f
|
|
||||||
|
|
||||||
|
|
||||||
# de-camelcasifier
|
# de-camelcasifier
|
||||||
# https://stackoverflow.com/a/1176023/222189
|
# https://stackoverflow.com/a/1176023/222189
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# This file is part of the Trezor project.
|
# This file is part of the Trezor project.
|
||||||
#
|
#
|
||||||
# Copyright (C) 2012-2024 SatoshiLabs and contributors
|
# Copyright (C) 2012-2022 SatoshiLabs and contributors
|
||||||
#
|
#
|
||||||
# This library is free software: you can redistribute it and/or modify
|
# This library is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU Lesser General Public License version 3
|
# it under the terms of the GNU Lesser General Public License version 3
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# This file is part of the Trezor project.
|
# This file is part of the Trezor project.
|
||||||
#
|
#
|
||||||
# Copyright (C) 2012-2024 SatoshiLabs and contributors
|
# Copyright (C) 2012-2022 SatoshiLabs and contributors
|
||||||
#
|
#
|
||||||
# This library is free software: you can redistribute it and/or modify
|
# This library is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU Lesser General Public License version 3
|
# it under the terms of the GNU Lesser General Public License version 3
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# This file is part of the Trezor project.
|
# This file is part of the Trezor project.
|
||||||
#
|
#
|
||||||
# Copyright (C) 2012-2024 SatoshiLabs and contributors
|
# Copyright (C) 2012-2022 SatoshiLabs and contributors
|
||||||
#
|
#
|
||||||
# This library is free software: you can redistribute it and/or modify
|
# This library is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU Lesser General Public License version 3
|
# it under the terms of the GNU Lesser General Public License version 3
|
||||||
|
@ -6,7 +6,6 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import typing as t
|
import typing as t
|
||||||
from binascii import hexlify
|
from binascii import hexlify
|
||||||
from enum import IntEnum
|
|
||||||
|
|
||||||
import click
|
import click
|
||||||
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
|
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
|
||||||
@ -468,10 +467,3 @@ class ProtocolV2(ProtocolAndChannel):
|
|||||||
)
|
)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
class ControlByteType(IntEnum):
|
|
||||||
CHANNEL_ALLOCATION_RES = 1
|
|
||||||
HANDSHAKE_INIT_RES = 2
|
|
||||||
HANDSHAKE_COMP_RES = 3
|
|
||||||
ACK = 4
|
|
||||||
ENCRYPTED_TRANSPORT = 5
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# This file is part of the Trezor project.
|
# This file is part of the Trezor project.
|
||||||
#
|
#
|
||||||
# Copyright (C) 2012-2024 SatoshiLabs and contributors
|
# Copyright (C) 2012-2022 SatoshiLabs and contributors
|
||||||
#
|
#
|
||||||
# This library is free software: you can redistribute it and/or modify
|
# This library is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU Lesser General Public License version 3
|
# it under the terms of the GNU Lesser General Public License version 3
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# This file is part of the Trezor project.
|
# This file is part of the Trezor project.
|
||||||
#
|
#
|
||||||
# Copyright (C) 2012-2024 SatoshiLabs and contributors
|
# Copyright (C) 2012-2022 SatoshiLabs and contributors
|
||||||
#
|
#
|
||||||
# This library is free software: you can redistribute it and/or modify
|
# This library is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU Lesser General Public License version 3
|
# it under the terms of the GNU Lesser General Public License version 3
|
||||||
|
@ -24,14 +24,14 @@ from trezorlib.tools import parse_path
|
|||||||
def main() -> None:
|
def main() -> None:
|
||||||
# Use first connected device
|
# Use first connected device
|
||||||
client = get_default_client()
|
client = get_default_client()
|
||||||
session = client.get_session(derive_cardano=True)
|
session = client.get_session()
|
||||||
|
|
||||||
# Print out Trezor's features and settings
|
# Print out Trezor's features and settings
|
||||||
print(session.features)
|
print(session.features)
|
||||||
|
|
||||||
# Get the first address of first BIP44 account
|
# Get the first address of first BIP44 account
|
||||||
bip32_path = parse_path("44h/0h/0h/0/0")
|
bip32_path = parse_path("44h/0h/0h/0/0")
|
||||||
address = btc.get_address(session, "Bitcoin", bip32_path, False)
|
address = btc.get_address(session, "Bitcoin", bip32_path, True)
|
||||||
print("Bitcoin address:", address)
|
print("Bitcoin address:", address)
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ def set_language(session: Session, lang: str):
|
|||||||
language_data = build_and_sign_blob(lang, session)
|
language_data = build_and_sign_blob(lang, session)
|
||||||
with session:
|
with session:
|
||||||
device.change_language(session, language_data) # type: ignore
|
device.change_language(session, language_data) # type: ignore
|
||||||
|
_CURRENT_TRANSLATION.TR = TRANSLATIONS[lang]
|
||||||
|
|
||||||
def get_lang_json(lang: str) -> translations.JsonDef:
|
def get_lang_json(lang: str) -> translations.JsonDef:
|
||||||
assert lang in LANGUAGES
|
assert lang in LANGUAGES
|
||||||
|
Loading…
Reference in New Issue
Block a user