Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Controller cleanup: lazy imports no longer required #496

Merged
merged 2 commits into from
Feb 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions src/seedsigner/controller.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import time
import logging

import time
import traceback

from embit.descriptor import Descriptor
from embit.psbt import PSBT
from PIL.Image import Image

from seedsigner.gui.toast import BaseToastOverlayManagerThread
from seedsigner.models.psbt_parser import PSBTParser
from seedsigner.models.seed import Seed
from seedsigner.models.seed_storage import SeedStorage
from seedsigner.models.settings import Settings
from seedsigner.models.singleton import Singleton
from seedsigner.models.threads import BaseThread
from seedsigner.views.screensaver import ScreensaverScreen
from seedsigner.views.view import Destination


Expand Down Expand Up @@ -97,18 +103,18 @@ class Controller(Singleton):

# Declare class member vars with type hints to enable richer IDE support throughout
# the code.
_storage: 'SeedStorage' = None # TODO: Rename "storage" to something more indicative of its temp, in-memory state
_storage: SeedStorage = None # TODO: Rename "storage" to something more indicative of its temp, in-memory state
settings: Settings = None

# TODO: Refactor these flow-related attrs that survive across multiple Screens.
# TODO: Should all in-memory flow-related attrs get wiped on MainMenuView?
psbt: 'embit.psbt.PSBT' = None
psbt_seed: 'Seed' = None
psbt_parser: 'PSBTParser' = None
psbt: PSBT = None
psbt_seed: Seed = None
psbt_parser: PSBTParser = None

unverified_address = None

multisig_wallet_descriptor: 'embit.descriptor.Descriptor' = None
multisig_wallet_descriptor: Descriptor = None

image_entropy_preview_frames: list[Image] = None
image_entropy_final_image: Image = None
Expand All @@ -129,8 +135,8 @@ class Controller(Singleton):
resume_main_flow: str = None

back_stack: BackStack = None
screensaver: 'ScreensaverScreen' = None
toast_notification_thread: 'BaseToastOverlayManagerThread' = None
screensaver: ScreensaverScreen = None
toast_notification_thread: BaseToastOverlayManagerThread = None


@classmethod
Expand Down Expand Up @@ -205,7 +211,7 @@ def storage(self):
return self._storage


def get_seed(self, seed_num: int) -> 'Seed':
def get_seed(self, seed_num: int) -> Seed:
if seed_num < len(self.storage.seeds):
return self.storage.seeds[seed_num]
else:
Expand Down Expand Up @@ -394,7 +400,7 @@ def start_screensaver(self):
print("Controller: Screensaver started")


def activate_toast(self, toast_manager_thread: 'BaseToastOverlayManagerThread'):
def activate_toast(self, toast_manager_thread: BaseToastOverlayManagerThread):
"""
Ensures that the Controller has explicit control over which processes get to
claim the Renderer.lock and which need to (potentially) release it.
Expand Down