mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-04-18 08:09:03 +00:00
fixup! feat(python): implement session based trezorlib
This commit is contained in:
parent
03e0eb552d
commit
b9e11d7939
@ -132,18 +132,6 @@ class TrezorClient:
|
||||
return session
|
||||
raise NotImplementedError
|
||||
|
||||
def resume_session(self, session: Session) -> Session:
|
||||
"""
|
||||
Note: this function potentially modifies the input session.
|
||||
"""
|
||||
from .transport.session import SessionV1
|
||||
|
||||
if isinstance(session, SessionV1):
|
||||
session.init_session()
|
||||
return session
|
||||
else:
|
||||
raise NotImplementedError
|
||||
|
||||
def get_seedless_session(self, new_session: bool = False) -> Session:
|
||||
from .transport.session import SessionV1
|
||||
|
||||
|
@ -45,7 +45,7 @@ from .messages import Capability, DebugWaitType
|
||||
from .protobuf import MessageType
|
||||
from .tools import parse_path
|
||||
from .transport import Timeout
|
||||
from .transport.session import Session, SessionV1, derive_seed
|
||||
from .transport.session import Session
|
||||
from .transport.thp.protocol_v1 import ProtocolV1Channel
|
||||
|
||||
if t.TYPE_CHECKING:
|
||||
@ -979,6 +979,9 @@ class SessionDebugWrapper(Session):
|
||||
self.actual_responses.append(resp)
|
||||
return resp
|
||||
|
||||
def resume(self) -> None:
|
||||
self._session.resume()
|
||||
|
||||
def set_expected_responses(
|
||||
self,
|
||||
expected: list["ExpectedMessage" | t.Tuple[bool, "ExpectedMessage"]],
|
||||
@ -1389,13 +1392,6 @@ class TrezorClientDebugLink(TrezorClient):
|
||||
session = SessionDebugWrapper(session)
|
||||
return session
|
||||
|
||||
def resume_session(self, session: Session) -> SessionDebugWrapper:
|
||||
if isinstance(session, SessionDebugWrapper):
|
||||
session._session = super().resume_session(session._session)
|
||||
return session
|
||||
else:
|
||||
return SessionDebugWrapper(super().resume_session(session))
|
||||
|
||||
def watch_layout(self, watch: bool = True) -> None:
|
||||
"""Enable or disable watching layout changes.
|
||||
|
||||
|
@ -59,6 +59,9 @@ class Session:
|
||||
def refresh_features(self) -> None:
|
||||
self.client.refresh_features()
|
||||
|
||||
def resume(self) -> None:
|
||||
pass
|
||||
|
||||
def end(self) -> t.Any:
|
||||
return self.call(messages.EndSession())
|
||||
|
||||
@ -138,6 +141,9 @@ class SessionV1(Session):
|
||||
session.init_session()
|
||||
return session
|
||||
|
||||
def resume(self) -> None:
|
||||
self.init_session(self.derive_cardano)
|
||||
|
||||
def _write(self, msg: t.Any) -> None:
|
||||
if t.TYPE_CHECKING:
|
||||
assert isinstance(self.client.protocol, ProtocolV1Channel)
|
||||
|
Loading…
Reference in New Issue
Block a user