algokit-utils 3.0.0b9__py3-none-any.whl → 3.0.0b11__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of algokit-utils might be problematic. Click here for more details.
- algokit_utils/_legacy_v2/_ensure_funded.py +3 -7
- algokit_utils/_legacy_v2/_transfer.py +5 -2
- algokit_utils/_legacy_v2/account.py +5 -5
- algokit_utils/_legacy_v2/deploy.py +1 -1
- algokit_utils/_legacy_v2/network_clients.py +10 -6
- algokit_utils/accounts/account_manager.py +71 -67
- algokit_utils/algorand.py +105 -11
- algokit_utils/application_specification.py +1 -1
- algokit_utils/applications/abi.py +8 -12
- algokit_utils/applications/app_client.py +132 -44
- algokit_utils/applications/app_deployer.py +93 -2
- algokit_utils/applications/app_factory.py +315 -1
- algokit_utils/applications/app_manager.py +110 -2
- algokit_utils/applications/app_spec/arc56.py +171 -205
- algokit_utils/assets/asset_manager.py +47 -31
- algokit_utils/clients/client_manager.py +76 -0
- algokit_utils/clients/dispenser_api_client.py +32 -3
- algokit_utils/models/application.py +30 -0
- algokit_utils/models/state.py +9 -0
- algokit_utils/transactions/transaction_composer.py +366 -182
- algokit_utils/transactions/transaction_creator.py +550 -18
- algokit_utils/transactions/transaction_sender.py +645 -0
- {algokit_utils-3.0.0b9.dist-info → algokit_utils-3.0.0b11.dist-info}/METADATA +1 -1
- {algokit_utils-3.0.0b9.dist-info → algokit_utils-3.0.0b11.dist-info}/RECORD +26 -26
- {algokit_utils-3.0.0b9.dist-info → algokit_utils-3.0.0b11.dist-info}/WHEEL +1 -1
- {algokit_utils-3.0.0b9.dist-info → algokit_utils-3.0.0b11.dist-info}/LICENSE +0 -0
|
@@ -119,6 +119,9 @@ class AppManager:
|
|
|
119
119
|
and interacting with application boxes.
|
|
120
120
|
|
|
121
121
|
:param algod_client: The Algorand client instance to use for interacting with the network
|
|
122
|
+
|
|
123
|
+
:example:
|
|
124
|
+
>>> app_manager = AppManager(algod_client)
|
|
122
125
|
"""
|
|
123
126
|
|
|
124
127
|
def __init__(self, algod_client: algod.AlgodClient):
|
|
@@ -158,6 +161,14 @@ class AppManager:
|
|
|
158
161
|
:param template_params: Parameters to substitute in the template
|
|
159
162
|
:param deployment_metadata: Deployment control parameters
|
|
160
163
|
:return: The compiled TEAL code and associated metadata
|
|
164
|
+
|
|
165
|
+
:example:
|
|
166
|
+
>>> app_manager = AppManager(algod_client)
|
|
167
|
+
>>> teal_template_code =
|
|
168
|
+
... # This is a TEAL template
|
|
169
|
+
... # It can contain template variables like {TMPL_UPDATABLE} and {TMPL_DELETABLE}
|
|
170
|
+
...
|
|
171
|
+
>>> compiled_teal = app_manager.compile_teal_template(teal_template_code)
|
|
161
172
|
"""
|
|
162
173
|
|
|
163
174
|
teal_code = AppManager.strip_teal_comments(teal_template_code)
|
|
@@ -173,8 +184,13 @@ class AppManager:
|
|
|
173
184
|
|
|
174
185
|
:param teal_code: The TEAL source code
|
|
175
186
|
:return: The cached compilation result if available, None otherwise
|
|
176
|
-
"""
|
|
177
187
|
|
|
188
|
+
:example:
|
|
189
|
+
>>> app_manager = AppManager(algod_client)
|
|
190
|
+
>>> teal_code = "RETURN 1"
|
|
191
|
+
>>> compiled_teal = app_manager.compile_teal(teal_code)
|
|
192
|
+
>>> compilation_result = app_manager.get_compilation_result(teal_code)
|
|
193
|
+
"""
|
|
178
194
|
return self._compilation_results.get(teal_code)
|
|
179
195
|
|
|
180
196
|
def get_by_id(self, app_id: int) -> AppInformation:
|
|
@@ -182,6 +198,11 @@ class AppManager:
|
|
|
182
198
|
|
|
183
199
|
:param app_id: The application ID
|
|
184
200
|
:return: Information about the application
|
|
201
|
+
|
|
202
|
+
:example:
|
|
203
|
+
>>> app_manager = AppManager(algod_client)
|
|
204
|
+
>>> app_id = 1234567890
|
|
205
|
+
>>> app_info = app_manager.get_by_id(app_id)
|
|
185
206
|
"""
|
|
186
207
|
|
|
187
208
|
app = self._algod.application_info(app_id)
|
|
@@ -207,6 +228,11 @@ class AppManager:
|
|
|
207
228
|
|
|
208
229
|
:param app_id: The application ID
|
|
209
230
|
:return: The application's global state
|
|
231
|
+
|
|
232
|
+
:example:
|
|
233
|
+
>>> app_manager = AppManager(algod_client)
|
|
234
|
+
>>> app_id = 123
|
|
235
|
+
>>> global_state = app_manager.get_global_state(app_id)
|
|
210
236
|
"""
|
|
211
237
|
|
|
212
238
|
return self.get_by_id(app_id).global_state
|
|
@@ -218,6 +244,12 @@ class AppManager:
|
|
|
218
244
|
:param address: The account address
|
|
219
245
|
:return: The account's local state for the application
|
|
220
246
|
:raises ValueError: If local state is not found
|
|
247
|
+
|
|
248
|
+
:example:
|
|
249
|
+
>>> app_manager = AppManager(algod_client)
|
|
250
|
+
>>> app_id = 123
|
|
251
|
+
>>> address = "SENDER_ADDRESS"
|
|
252
|
+
>>> local_state = app_manager.get_local_state(app_id, address)
|
|
221
253
|
"""
|
|
222
254
|
|
|
223
255
|
app_info = self._algod.account_application_info(address, app_id)
|
|
@@ -231,6 +263,11 @@ class AppManager:
|
|
|
231
263
|
|
|
232
264
|
:param app_id: The application ID
|
|
233
265
|
:return: List of box names
|
|
266
|
+
|
|
267
|
+
:example:
|
|
268
|
+
>>> app_manager = AppManager(algod_client)
|
|
269
|
+
>>> app_id = 123
|
|
270
|
+
>>> box_names = app_manager.get_box_names(app_id)
|
|
234
271
|
"""
|
|
235
272
|
|
|
236
273
|
box_result = self._algod.application_boxes(app_id)
|
|
@@ -250,6 +287,12 @@ class AppManager:
|
|
|
250
287
|
:param app_id: The application ID
|
|
251
288
|
:param box_name: The box identifier
|
|
252
289
|
:return: The box value as bytes
|
|
290
|
+
|
|
291
|
+
:example:
|
|
292
|
+
>>> app_manager = AppManager(algod_client)
|
|
293
|
+
>>> app_id = 123
|
|
294
|
+
>>> box_name = "BOX_NAME"
|
|
295
|
+
>>> box_value = app_manager.get_box_value(app_id, box_name)
|
|
253
296
|
"""
|
|
254
297
|
|
|
255
298
|
name = AppManager.get_box_reference(box_name)[1]
|
|
@@ -263,6 +306,12 @@ class AppManager:
|
|
|
263
306
|
:param app_id: The application ID
|
|
264
307
|
:param box_names: List of box identifiers
|
|
265
308
|
:return: List of box values as bytes
|
|
309
|
+
|
|
310
|
+
:example:
|
|
311
|
+
>>> app_manager = AppManager(algod_client)
|
|
312
|
+
>>> app_id = 123
|
|
313
|
+
>>> box_names = ["BOX_NAME_1", "BOX_NAME_2"]
|
|
314
|
+
>>> box_values = app_manager.get_box_values(app_id, box_names)
|
|
266
315
|
"""
|
|
267
316
|
|
|
268
317
|
return [self.get_box_value(app_id, box_name) for box_name in box_names]
|
|
@@ -275,6 +324,13 @@ class AppManager:
|
|
|
275
324
|
:param abi_type: The ABI type to decode with
|
|
276
325
|
:return: The decoded box value
|
|
277
326
|
:raises ValueError: If decoding fails
|
|
327
|
+
|
|
328
|
+
:example:
|
|
329
|
+
>>> app_manager = AppManager(algod_client)
|
|
330
|
+
>>> app_id = 123
|
|
331
|
+
>>> box_name = "BOX_NAME"
|
|
332
|
+
>>> abi_type = ABIType.UINT
|
|
333
|
+
>>> box_value = app_manager.get_box_value_from_abi_type(app_id, box_name, abi_type)
|
|
278
334
|
"""
|
|
279
335
|
|
|
280
336
|
value = self.get_box_value(app_id, box_name)
|
|
@@ -294,6 +350,13 @@ class AppManager:
|
|
|
294
350
|
:param box_names: List of box identifiers
|
|
295
351
|
:param abi_type: The ABI type to decode with
|
|
296
352
|
:return: List of decoded box values
|
|
353
|
+
|
|
354
|
+
:example:
|
|
355
|
+
>>> app_manager = AppManager(algod_client)
|
|
356
|
+
>>> app_id = 123
|
|
357
|
+
>>> box_names = ["BOX_NAME_1", "BOX_NAME_2"]
|
|
358
|
+
>>> abi_type = ABIType.UINT
|
|
359
|
+
>>> box_values = app_manager.get_box_values_from_abi_type(app_id, box_names, abi_type)
|
|
297
360
|
"""
|
|
298
361
|
|
|
299
362
|
return [self.get_box_value_from_abi_type(app_id, box_name, abi_type) for box_name in box_names]
|
|
@@ -305,6 +368,12 @@ class AppManager:
|
|
|
305
368
|
:param box_id: The box identifier
|
|
306
369
|
:return: Tuple of (app_id, box_name_bytes)
|
|
307
370
|
:raises ValueError: If box identifier type is invalid
|
|
371
|
+
|
|
372
|
+
:example:
|
|
373
|
+
>>> app_manager = AppManager(algod_client)
|
|
374
|
+
>>> app_id = 123
|
|
375
|
+
>>> box_name = "BOX_NAME"
|
|
376
|
+
>>> box_reference = app_manager.get_box_reference(box_name)
|
|
308
377
|
"""
|
|
309
378
|
|
|
310
379
|
if isinstance(box_id, (BoxReference | AlgosdkBoxReference)):
|
|
@@ -333,8 +402,14 @@ class AppManager:
|
|
|
333
402
|
:param confirmation: The transaction confirmation
|
|
334
403
|
:param method: The ABI method
|
|
335
404
|
:return: The parsed ABI return value, or None if not available
|
|
336
|
-
"""
|
|
337
405
|
|
|
406
|
+
:example:
|
|
407
|
+
>>> app_manager = AppManager(algod_client)
|
|
408
|
+
>>> app_id = 123
|
|
409
|
+
>>> method = "METHOD_NAME"
|
|
410
|
+
>>> confirmation = algod_client.pending_transaction_info(tx_id)
|
|
411
|
+
>>> abi_return = app_manager.get_abi_return(confirmation, method)
|
|
412
|
+
"""
|
|
338
413
|
if not method:
|
|
339
414
|
return None
|
|
340
415
|
|
|
@@ -357,6 +432,12 @@ class AppManager:
|
|
|
357
432
|
:param state: The raw application state
|
|
358
433
|
:return: Decoded application state
|
|
359
434
|
:raises ValueError: If unknown state data type is encountered
|
|
435
|
+
|
|
436
|
+
:example:
|
|
437
|
+
>>> app_manager = AppManager(algod_client)
|
|
438
|
+
>>> app_id = 123
|
|
439
|
+
>>> state = app_manager.get_global_state(app_id)
|
|
440
|
+
>>> decoded_state = app_manager.decode_app_state(state)
|
|
360
441
|
"""
|
|
361
442
|
|
|
362
443
|
state_values: dict[str, AppState] = {}
|
|
@@ -407,6 +488,13 @@ class AppManager:
|
|
|
407
488
|
:param template_values: Template variable values to substitute
|
|
408
489
|
:return: TEAL code with substituted values
|
|
409
490
|
:raises ValueError: If template value type is unexpected
|
|
491
|
+
|
|
492
|
+
:example:
|
|
493
|
+
>>> app_manager = AppManager(algod_client)
|
|
494
|
+
>>> app_id = 123
|
|
495
|
+
>>> program = "RETURN 1"
|
|
496
|
+
>>> template_values = {"TMPL_UPDATABLE": True, "TMPL_DELETABLE": True}
|
|
497
|
+
>>> updated_program = app_manager.replace_template_variables(program, template_values)
|
|
410
498
|
"""
|
|
411
499
|
|
|
412
500
|
program_lines = program.splitlines()
|
|
@@ -437,6 +525,15 @@ class AppManager:
|
|
|
437
525
|
:param params: The deploy-time control parameters
|
|
438
526
|
:return: TEAL code with substituted control parameters
|
|
439
527
|
:raises ValueError: If template variables not found in code
|
|
528
|
+
|
|
529
|
+
:example:
|
|
530
|
+
>>> app_manager = AppManager(algod_client)
|
|
531
|
+
>>> app_id = 123
|
|
532
|
+
>>> teal_template_code = "RETURN 1"
|
|
533
|
+
>>> params = {"TMPL_UPDATABLE": True, "TMPL_DELETABLE": True}
|
|
534
|
+
>>> updated_teal_code = app_manager.replace_teal_template_deploy_time_control_params(
|
|
535
|
+
teal_template_code, params
|
|
536
|
+
)
|
|
440
537
|
"""
|
|
441
538
|
|
|
442
539
|
updatable = params.get("updatable")
|
|
@@ -461,6 +558,17 @@ class AppManager:
|
|
|
461
558
|
|
|
462
559
|
@staticmethod
|
|
463
560
|
def strip_teal_comments(teal_code: str) -> str:
|
|
561
|
+
"""Strip comments from TEAL code.
|
|
562
|
+
|
|
563
|
+
:param teal_code: The TEAL code to strip comments from
|
|
564
|
+
:return: The TEAL code with comments stripped
|
|
565
|
+
|
|
566
|
+
:example:
|
|
567
|
+
>>> app_manager = AppManager(algod_client)
|
|
568
|
+
>>> teal_code = "RETURN 1"
|
|
569
|
+
>>> stripped_teal_code = app_manager.strip_teal_comments(teal_code)
|
|
570
|
+
"""
|
|
571
|
+
|
|
464
572
|
def _strip_comment(line: str) -> str:
|
|
465
573
|
comment_idx = _find_unquoted_string(line, "//")
|
|
466
574
|
if comment_idx is None:
|