From 6a858073abf85e6d52c9ce1a2d6b39ef05770eaa Mon Sep 17 00:00:00 2001
From: kmochocki <kmochocki@syncad.com>
Date: Fri, 14 Jul 2023 13:54:40 +0000
Subject: [PATCH] Dynamic global properties are stored in app state

---
 clive/__private/core/app_state.py         | 9 +++++++++
 clive/__private/core/commands/commands.py | 4 +++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/clive/__private/core/app_state.py b/clive/__private/core/app_state.py
index 653bc8d335..cda3da94fc 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 c93c74e26e..a44308785e 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()
-- 
GitLab