From 23ed7774004990c59f3fb20e44dfa78ec39f8b64 Mon Sep 17 00:00:00 2001 From: user Date: Fri, 1 Mar 2024 23:14:38 +0300 Subject: [PATCH] dev@locazia: fix circular import --- app/core/_config.py | 2 -- app/core/_secrets.py | 6 +++--- app/core/active_config.py | 4 ++++ 3 files changed, 7 insertions(+), 5 deletions(-) create mode 100644 app/core/active_config.py diff --git a/app/core/_config.py b/app/core/_config.py index df03a28..7478fe0 100644 --- a/app/core/_config.py +++ b/app/core/_config.py @@ -12,8 +12,6 @@ if not os.path.exists(UPLOADS_DIR): os.makedirs(UPLOADS_DIR) CONFIG_FILE = os.getenv('CONFIG_FILE') or f"{UPLOADS_DIR}/../config" -from app.core.models._config import ConfigFile -config_manager = ConfigFile(CONFIG_FILE) TELEGRAM_API_KEY = os.environ.get('TELEGRAM_API_KEY') assert TELEGRAM_API_KEY, "Telegram API_KEY required" diff --git a/app/core/_secrets.py b/app/core/_secrets.py index a68cc1c..046ceca 100644 --- a/app/core/_secrets.py +++ b/app/core/_secrets.py @@ -1,5 +1,5 @@ from nacl.bindings import crypto_sign_seed_keypair -from app.core._config import config_manager +from app.core.active_config import active_config from app.core.logger import make_log from app.core._blockchain.ton.wallet_v3cr3 import WalletV3CR3 from os import urandom, getenv @@ -7,11 +7,11 @@ from tonsdk.utils import Address def load_hot_pair(): - hot_seed = config_manager.get('private_key') + hot_seed = active_config.get('private_key') if hot_seed is None: make_log("HotWallet", "No seed found, generating new one", level='info') hot_seed = urandom(32).hex() - config_manager.set('private_key', hot_seed) + active_config.set('private_key', hot_seed) return load_hot_pair() public_key, private_key = crypto_sign_seed_keypair(bytes.fromhex(hot_seed)) diff --git a/app/core/active_config.py b/app/core/active_config.py new file mode 100644 index 0000000..07ab3e8 --- /dev/null +++ b/app/core/active_config.py @@ -0,0 +1,4 @@ +from app.core.models._config import ConfigFile +from app.core._config import CONFIG_FILE + +active_config = ConfigFile(CONFIG_FILE)