@@ -23,25 +23,25 @@ class LedgerContext:
2323 def __init__ (self ) -> None :
2424 from _algopy_testing .models .account import AccountContextData , get_empty_account
2525
26- self .account_data = defaultdict [str , AccountContextData ](get_empty_account )
27- self .app_data : dict [int , ApplicationContextData ] = {}
28- self .asset_data : dict [int , AssetFields ] = {}
29- self .blocks : dict [int , dict [str , int ]] = {}
30- self .global_fields : GlobalFields = get_default_global_fields ()
26+ self ._account_data = defaultdict [str , AccountContextData ](get_empty_account )
27+ self ._app_data : dict [int , ApplicationContextData ] = {}
28+ self ._asset_data : dict [int , AssetFields ] = {}
29+ self ._blocks : dict [int , dict [str , int ]] = {}
30+ self ._global_fields : GlobalFields = get_default_global_fields ()
3131
3232 self ._asset_id = iter (range (1001 , 2 ** 64 ))
3333 self ._app_id = iter (range (1001 , 2 ** 64 ))
3434
35- def get_next_asset_id (self ) -> int :
35+ def _get_next_asset_id (self ) -> int :
3636 while True :
3737 asset_id = next (self ._asset_id )
38- if asset_id not in self .asset_data :
38+ if asset_id not in self ._asset_data :
3939 return asset_id
4040
41- def get_next_app_id (self ) -> int :
41+ def _get_next_app_id (self ) -> int :
4242 while True :
4343 app_id = next (self ._app_id )
44- if app_id not in self .app_data :
44+ if app_id not in self ._app_data :
4545 return app_id
4646
4747 def get_account (self , address : str ) -> algopy .Account :
@@ -68,7 +68,7 @@ def account_exists(self, address: str) -> bool:
6868 bool: True if the account exists, False otherwise.
6969 """
7070 assert_address_is_valid (address )
71- return address in self .account_data
71+ return address in self ._account_data
7272
7373 def update_account (
7474 self ,
@@ -84,11 +84,11 @@ def update_account(
8484 **account_fields: The fields to update.
8585 """
8686 assert_address_is_valid (address )
87- self .account_data [address ].fields .update (account_fields )
87+ self ._account_data [address ].fields .update (account_fields )
8888
8989 if opted_asset_balances is not None :
9090 for asset_id , balance in opted_asset_balances .items ():
91- self .account_data [address ].opted_asset_balances [UInt64 (asset_id )] = balance
91+ self ._account_data [address ].opted_asset_balances [UInt64 (asset_id )] = balance
9292
9393 def get_asset (self , asset_id : algopy .UInt64 | int ) -> algopy .Asset :
9494 """Get an asset by ID.
@@ -105,7 +105,7 @@ def get_asset(self, asset_id: algopy.UInt64 | int) -> algopy.Asset:
105105 import algopy
106106
107107 asset_id = int (asset_id ) if isinstance (asset_id , algopy .UInt64 ) else asset_id
108- if asset_id not in self .asset_data :
108+ if asset_id not in self ._asset_data :
109109 raise ValueError ("Asset not found in testing context!" )
110110
111111 return algopy .Asset (asset_id )
@@ -122,7 +122,7 @@ def asset_exists(self, asset_id: algopy.UInt64 | int) -> bool:
122122 import algopy
123123
124124 asset_id = int (asset_id ) if isinstance (asset_id , algopy .UInt64 ) else asset_id
125- return asset_id in self .asset_data
125+ return asset_id in self ._asset_data
126126
127127 def update_asset (self , asset_id : int , ** asset_fields : typing .Unpack [AssetFields ]) -> None :
128128 """Update asset fields.
@@ -134,9 +134,9 @@ def update_asset(self, asset_id: int, **asset_fields: typing.Unpack[AssetFields]
134134 Raises:
135135 ValueError: If the asset is not found.
136136 """
137- if asset_id not in self .asset_data :
137+ if asset_id not in self ._asset_data :
138138 raise ValueError ("Asset not found in testing context!" )
139- self .asset_data [asset_id ].update (asset_fields )
139+ self ._asset_data [asset_id ].update (asset_fields )
140140
141141 def get_app (
142142 self , app_id : algopy .Contract | algopy .Application | algopy .UInt64 | int
@@ -164,7 +164,7 @@ def app_exists(self, app_id: algopy.UInt64 | int) -> bool:
164164 bool: True if the application exists, False otherwise.
165165 """
166166 app_id = _get_app_id (app_id )
167- return app_id in self .app_data
167+ return app_id in self ._app_data
168168
169169 def update_app (
170170 self , app_id : int , ** application_fields : typing .Unpack [ApplicationFields ]
@@ -343,7 +343,7 @@ def set_block(
343343 seed (algopy.UInt64 | int): The block seed.
344344 timestamp (algopy.UInt64 | int): The block timestamp.
345345 """
346- self .blocks [index ] = {"seed" : int (seed ), "timestamp" : int (timestamp )}
346+ self ._blocks [index ] = {"seed" : int (seed ), "timestamp" : int (timestamp )}
347347
348348 def get_block_content (self , index : int , key : str ) -> int :
349349 """Get block content.
@@ -358,7 +358,7 @@ def get_block_content(self, index: int, key: str) -> int:
358358 Raises:
359359 ValueError: If the block content is not found.
360360 """
361- content = self .blocks .get (index , {}).get (key , None )
361+ content = self ._blocks .get (index , {}).get (key , None )
362362 if content is None :
363363 raise KeyError (
364364 f"Block content for index { index } and key { key } not found in testing context!"
@@ -383,7 +383,7 @@ def patch_global_fields(self, **global_fields: typing.Unpack[GlobalFields]) -> N
383383 f"Invalid field(s) found during patch for `Global`: { ', ' .join (invalid_keys )} "
384384 )
385385
386- self .global_fields .update (global_fields )
386+ self ._global_fields .update (global_fields )
387387
388388 def _get_app_data (
389389 self , app : algopy .UInt64 | algopy .Application | algopy .Contract | int
@@ -401,7 +401,7 @@ def _get_app_data(
401401 """
402402 app_id = _get_app_id (app )
403403 try :
404- return self .app_data [app_id ]
404+ return self ._app_data [app_id ]
405405 except KeyError :
406406 raise ValueError ("Unknown app id, is there an active transaction?" ) from None
407407
0 commit comments