From 766f7d2cd13635fbdb61afa569f6aeb927085bf1 Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Wed, 9 Oct 2024 18:49:51 +0200 Subject: [PATCH] fix: emulator.get_debug_state response --- src/dashboard/js/index.js | 1 + src/emulator.py | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/dashboard/js/index.js b/src/dashboard/js/index.js index caa27bf..302e104 100644 --- a/src/dashboard/js/index.js +++ b/src/dashboard/js/index.js @@ -162,6 +162,7 @@ const app = createApp({ if ( "response" in dataObject && + typeof dataObject.response === 'string' && dataObject.response.includes("Emulator downloaded") ) { this.downloadMessage = ""; diff --git a/src/emulator.py b/src/emulator.py index d09613e..9949d89 100644 --- a/src/emulator.py +++ b/src/emulator.py @@ -910,15 +910,18 @@ def get_debug_state() -> Dict[str, Any]: debug_state_dict: Dict[str, Any] = {} for key in dir(debug_state): val = getattr(debug_state, key) - # Not interested in private attributes and non-JSON fields (bytes) + # Not interested in private or uppercase attributes if key.startswith("__") or key[0].isupper(): continue + # Not interested in methods + if callable(val): + continue + # Transforming bytes to string if isinstance(val, bytes): try: val = val.decode("utf-8") except UnicodeDecodeError: val = val.hex() - debug_state_dict[key] = val return debug_state_dict @@ -941,9 +944,9 @@ def get_screen_content() -> ScreenContent: if __name__ == "__main__": # read_and_confirm_mnemonic() # read_and_confirm_mnemonic_t3t1() - read_and_confirm_shamir_mnemonic_t3t1(3, 2) + # read_and_confirm_shamir_mnemonic_t3t1(3, 2) # read_and_confirm_shamir_mnemonic_t2t1(3, 2) - # state = get_debug_state() - # print("state", state) + state = get_debug_state() + print("state", state) # screen = get_screen_content() # print("screen", screen)