usawa

Signed, immutable accounting.
Log | Files | Refs | Submodules | LICENSE

commit aeda762ca9107c7a94b253efe3f44f6fd19f712e
parent 322a72c568cb37852b350f248bb35064180c3902
Author: Carlosokumu <carlosokumu254@gmail.com>
Date:   Tue, 17 Mar 2026 22:57:05 +0300

add a statemanager purposely for checking  if the wallet has been setup

Diffstat:
Adummy/usawa/core/state_manager.py | 28++++++++++++++++++++++++++++
1 file changed, 28 insertions(+), 0 deletions(-)

diff --git a/dummy/usawa/core/state_manager.py b/dummy/usawa/core/state_manager.py @@ -0,0 +1,28 @@ +import json +from pathlib import Path + +STATE_FILE = Path.home() / ".local" / "share" / "usawa" / "state.json" + + +class StateManager: + + @staticmethod + def get_state() -> dict: + if STATE_FILE.exists(): + return json.loads(STATE_FILE.read_text()) + return {} + + @staticmethod + def save_state(data: dict): + STATE_FILE.parent.mkdir(parents=True, exist_ok=True) + STATE_FILE.write_text(json.dumps(data, indent=2)) + + @staticmethod + def get(key: str, default=None): + return StateManager.get_state().get(key, default) + + @staticmethod + def set(key: str, value): + state = StateManager.get_state() + state[key] = value + StateManager.save_state(state)