From 89d9c1f816f34364898799b2049f71176de470a0 Mon Sep 17 00:00:00 2001 From: M1nd3r Date: Thu, 28 Nov 2024 17:59:56 +0100 Subject: [PATCH] fix(trezorlib): fox ping command, add ping to session [no changelog] --- python/src/trezorlib/cli/trezorctl.py | 4 +--- python/src/trezorlib/transport/session.py | 6 ++++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/python/src/trezorlib/cli/trezorctl.py b/python/src/trezorlib/cli/trezorctl.py index 0ad7152418..da784a5a6b 100755 --- a/python/src/trezorlib/cli/trezorctl.py +++ b/python/src/trezorlib/cli/trezorctl.py @@ -337,9 +337,7 @@ def ping(session: "Session", message: str, button_protection: bool) -> str: """Send ping message.""" # TODO return short-circuit from old client for old Trezors - return session.call( - messages.Ping(message=message, button_protection=button_protection) - ) + return session.ping(message, button_protection) @cli.command() diff --git a/python/src/trezorlib/transport/session.py b/python/src/trezorlib/transport/session.py index f8441c0fc7..7ba6535801 100644 --- a/python/src/trezorlib/transport/session.py +++ b/python/src/trezorlib/transport/session.py @@ -73,6 +73,12 @@ class Session: def end(self) -> t.Any: return self.call(messages.EndSession()) + def ping(self, message: str, button_protection: bool | None = None) -> str: + resp: messages.Success = self.call( + messages.Ping(message=message, button_protection=button_protection) + ) + return resp.message or "" + @property def features(self) -> messages.Features: return self.client.features