diff --git a/clive/__private/core/app_state.py b/clive/__private/core/app_state.py index 653bc8d33503017c90ff65fedffc463a266745aa..cda3da94fcf4c5e924ffd97b237f528f876d88cc 100644 --- a/clive/__private/core/app_state.py +++ b/clive/__private/core/app_state.py @@ -3,6 +3,8 @@ from __future__ import annotations from dataclasses import dataclass from typing import TYPE_CHECKING +from clive.__private.core.commands.update_node_data import DynamicGlobalPropertiesT # noqa: TCH001 + if TYPE_CHECKING: from clive.__private.core.world import World @@ -12,6 +14,13 @@ class AppState: """A class that holds information about the current state of an application.""" world: World + _dynamic_global_properties: DynamicGlobalPropertiesT | None = None + + def get_dynamic_global_properties(self) -> DynamicGlobalPropertiesT: + if self._dynamic_global_properties is None: + self.world.commands.update_node_data(accounts=[]) + assert self._dynamic_global_properties is not None + return self._dynamic_global_properties def is_active(self) -> bool: wallets = self.world.beekeeper.api.list_wallets().wallets diff --git a/clive/__private/core/commands/commands.py b/clive/__private/core/commands/commands.py index c93c74e26e22e1d93d9b832ca20a5d1a176b3719..a44308785ecbeed1cc00aaa5faa01b6d75ef619e 100644 --- a/clive/__private/core/commands/commands.py +++ b/clive/__private/core/commands/commands.py @@ -95,4 +95,6 @@ class Commands: ).execute() def update_node_data(self, *, accounts: list[Account]) -> None: - UpdateNodeData(accounts=accounts, node=self.__world.node).execute() + self.__world.app_state._dynamic_global_properties = UpdateNodeData( + accounts=accounts, node=self.__world.node + ).execute_with_result()