algokit-utils 0.1.2b2__py3-none-any.whl → 0.1.3__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/account.py +1 -1
- algokit_utils/application_client.py +50 -42
- {algokit_utils-0.1.2b2.dist-info → algokit_utils-0.1.3.dist-info}/METADATA +1 -1
- {algokit_utils-0.1.2b2.dist-info → algokit_utils-0.1.3.dist-info}/RECORD +6 -6
- {algokit_utils-0.1.2b2.dist-info → algokit_utils-0.1.3.dist-info}/LICENSE +0 -0
- {algokit_utils-0.1.2b2.dist-info → algokit_utils-0.1.3.dist-info}/WHEEL +0 -0
algokit_utils/account.py
CHANGED
|
@@ -128,7 +128,7 @@ def get_account(
|
|
|
128
128
|
|
|
129
129
|
if is_sandbox(client):
|
|
130
130
|
account = get_or_create_kmd_wallet_account(client, name, fund_with, kmd_client)
|
|
131
|
-
os.environ[mnemonic_key] = account.private_key
|
|
131
|
+
os.environ[mnemonic_key] = from_private_key(account.private_key) # type: ignore[no-untyped-call]
|
|
132
132
|
return account
|
|
133
133
|
|
|
134
134
|
raise Exception(f"Missing environment variable '{mnemonic_key}' when looking for account '{name}'")
|
|
@@ -185,7 +185,7 @@ class ApplicationClient:
|
|
|
185
185
|
self.app_spec = app_spec
|
|
186
186
|
self._approval_program: Program | None = None
|
|
187
187
|
self._clear_program: Program | None = None
|
|
188
|
-
self.
|
|
188
|
+
self.approval_source_map: SourceMap | None = None
|
|
189
189
|
self.existing_deployments = existing_deployments
|
|
190
190
|
self._indexer_client = indexer_client
|
|
191
191
|
if creator is not None:
|
|
@@ -214,24 +214,24 @@ class ApplicationClient:
|
|
|
214
214
|
self.signer = AccountTransactionSigner(creator.private_key)
|
|
215
215
|
else:
|
|
216
216
|
self.signer = None
|
|
217
|
-
|
|
217
|
+
if sender:
|
|
218
|
+
self.sender: str | None = sender
|
|
219
|
+
elif self.signer:
|
|
220
|
+
self.sender = _get_sender_from_signer(self.signer)
|
|
221
|
+
else:
|
|
222
|
+
self.sender = None
|
|
218
223
|
self.suggested_params = suggested_params
|
|
219
224
|
|
|
220
225
|
@property
|
|
221
226
|
def app_address(self) -> str:
|
|
222
227
|
return get_application_address(self.app_id)
|
|
223
228
|
|
|
224
|
-
# TODO: source map changes
|
|
225
229
|
@property
|
|
226
|
-
def approval(self) -> Program:
|
|
227
|
-
if not self._approval_program:
|
|
228
|
-
self._approval_program = Program(self.app_spec.approval_program, self.algod_client)
|
|
230
|
+
def approval(self) -> Program | None:
|
|
229
231
|
return self._approval_program
|
|
230
232
|
|
|
231
233
|
@property
|
|
232
|
-
def clear(self) -> Program:
|
|
233
|
-
if not self._clear_program:
|
|
234
|
-
self._clear_program = Program(self.app_spec.clear_program, self.algod_client)
|
|
234
|
+
def clear(self) -> Program | None:
|
|
235
235
|
return self._clear_program
|
|
236
236
|
|
|
237
237
|
def deploy(
|
|
@@ -497,7 +497,7 @@ class ApplicationClient:
|
|
|
497
497
|
extra_pages: int | None = None,
|
|
498
498
|
note: bytes | str | None = None,
|
|
499
499
|
lease: bytes | None = None,
|
|
500
|
-
) ->
|
|
500
|
+
) -> tuple[Program, Program]:
|
|
501
501
|
"""Adds a signed transaction with application id == 0 and the schema and source of client's app_spec to atc"""
|
|
502
502
|
|
|
503
503
|
approval_program, clear_program = self._substitute_template_and_compile(template_values)
|
|
@@ -524,6 +524,8 @@ class ApplicationClient:
|
|
|
524
524
|
lease=lease,
|
|
525
525
|
)
|
|
526
526
|
|
|
527
|
+
return approval_program, clear_program
|
|
528
|
+
|
|
527
529
|
def create(
|
|
528
530
|
self,
|
|
529
531
|
abi_method: Method | str | bool | None = None,
|
|
@@ -542,7 +544,7 @@ class ApplicationClient:
|
|
|
542
544
|
|
|
543
545
|
atc = AtomicTransactionComposer()
|
|
544
546
|
|
|
545
|
-
self.compose_create(
|
|
547
|
+
self._approval_program, self._clear_program = self.compose_create(
|
|
546
548
|
atc,
|
|
547
549
|
abi_method,
|
|
548
550
|
args,
|
|
@@ -571,7 +573,7 @@ class ApplicationClient:
|
|
|
571
573
|
template_values: TemplateValueDict | None = None,
|
|
572
574
|
note: bytes | str | None = None,
|
|
573
575
|
lease: bytes | None = None,
|
|
574
|
-
) ->
|
|
576
|
+
) -> tuple[Program, Program]:
|
|
575
577
|
"""Adds a signed transaction with on_complete=UpdateApplication to atc"""
|
|
576
578
|
|
|
577
579
|
self._load_reference_and_check_app_id()
|
|
@@ -592,6 +594,8 @@ class ApplicationClient:
|
|
|
592
594
|
lease=lease,
|
|
593
595
|
)
|
|
594
596
|
|
|
597
|
+
return approval_program, clear_program
|
|
598
|
+
|
|
595
599
|
def update(
|
|
596
600
|
self,
|
|
597
601
|
abi_method: Method | str | bool | None = None,
|
|
@@ -607,7 +611,7 @@ class ApplicationClient:
|
|
|
607
611
|
"""Submits a signed transaction with on_complete=UpdateApplication"""
|
|
608
612
|
|
|
609
613
|
atc = AtomicTransactionComposer()
|
|
610
|
-
self.compose_update(
|
|
614
|
+
self._approval_program, self._clear_program = self.compose_update(
|
|
611
615
|
atc,
|
|
612
616
|
abi_method,
|
|
613
617
|
args,
|
|
@@ -1064,21 +1068,11 @@ class ApplicationClient:
|
|
|
1064
1068
|
self._clear_program = Program(clear, self.algod_client)
|
|
1065
1069
|
return self._approval_program, self._clear_program
|
|
1066
1070
|
|
|
1067
|
-
def _get_approval_source_map(self) -> SourceMap:
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
return pattern.findall(program)
|
|
1071
|
+
def _get_approval_source_map(self) -> SourceMap | None:
|
|
1072
|
+
if self.approval:
|
|
1073
|
+
return self.approval.source_map
|
|
1071
1074
|
|
|
1072
|
-
|
|
1073
|
-
if self._approval_program:
|
|
1074
|
-
self._approval_source_map = self._approval_program.source_map
|
|
1075
|
-
else:
|
|
1076
|
-
# TODO: this will produce an incorrect source map for bytes as their length is not fixed
|
|
1077
|
-
template_values: TemplateValueDict = {k: 0 for k in _find_template_vars(self.app_spec.approval_program)}
|
|
1078
|
-
approval_program = replace_template_variables(self.app_spec.approval_program, template_values)
|
|
1079
|
-
approval = Program(approval_program, self.algod_client)
|
|
1080
|
-
self._approval_source_map = approval.source_map
|
|
1081
|
-
return self._approval_source_map
|
|
1075
|
+
return self.approval_source_map
|
|
1082
1076
|
|
|
1083
1077
|
def _add_method_call(
|
|
1084
1078
|
self,
|
|
@@ -1249,21 +1243,13 @@ class ApplicationClient:
|
|
|
1249
1243
|
confirmed_round=result.confirmed_round,
|
|
1250
1244
|
)
|
|
1251
1245
|
|
|
1252
|
-
def _execute_atc(self, atc: AtomicTransactionComposer
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
if source_map:
|
|
1260
|
-
raise LogicError(
|
|
1261
|
-
logic_error=ex,
|
|
1262
|
-
program=self.app_spec.approval_program,
|
|
1263
|
-
source_map=source_map,
|
|
1264
|
-
**logic_error_data,
|
|
1265
|
-
) from ex
|
|
1266
|
-
raise ex
|
|
1246
|
+
def _execute_atc(self, atc: AtomicTransactionComposer) -> AtomicTransactionResponse:
|
|
1247
|
+
return execute_atc_with_logic_error(
|
|
1248
|
+
atc,
|
|
1249
|
+
self.algod_client,
|
|
1250
|
+
approval_program=self.approval.teal if self.approval else self.app_spec.approval_program,
|
|
1251
|
+
approval_source_map=self._get_approval_source_map(),
|
|
1252
|
+
)
|
|
1267
1253
|
|
|
1268
1254
|
def _set_app_id_from_tx_id(self, tx_id: str) -> None:
|
|
1269
1255
|
self.app_id = get_app_id_from_tx_id(self.algod_client, tx_id)
|
|
@@ -1450,3 +1436,25 @@ def _get_deploy_control(
|
|
|
1450
1436
|
return _get_call_config(app_spec.bare_call_config, on_complete) != CallConfig.NEVER or any(
|
|
1451
1437
|
h for h in app_spec.hints.values() if _get_call_config(h.call_config, on_complete) != CallConfig.NEVER
|
|
1452
1438
|
)
|
|
1439
|
+
|
|
1440
|
+
|
|
1441
|
+
def execute_atc_with_logic_error(
|
|
1442
|
+
atc: AtomicTransactionComposer,
|
|
1443
|
+
algod_client: AlgodClient,
|
|
1444
|
+
wait_rounds: int = 4,
|
|
1445
|
+
approval_program: str | None = None,
|
|
1446
|
+
approval_source_map: SourceMap | None = None,
|
|
1447
|
+
) -> AtomicTransactionResponse:
|
|
1448
|
+
try:
|
|
1449
|
+
return atc.execute(algod_client, wait_rounds=wait_rounds)
|
|
1450
|
+
except Exception as ex:
|
|
1451
|
+
if approval_source_map and approval_program:
|
|
1452
|
+
logic_error_data = parse_logic_error(str(ex))
|
|
1453
|
+
if logic_error_data is not None:
|
|
1454
|
+
raise LogicError(
|
|
1455
|
+
logic_error=ex,
|
|
1456
|
+
program=approval_program,
|
|
1457
|
+
source_map=approval_source_map,
|
|
1458
|
+
**logic_error_data,
|
|
1459
|
+
) from ex
|
|
1460
|
+
raise ex
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
algokit_utils/__init__.py,sha256=JyifbVtU34vOhRKUfzTPAm3jdiRfBU8WJfWicznyxKg,2501
|
|
2
2
|
algokit_utils/_transfer.py,sha256=X9YrwxGuIhH4cHD7R1F6fyFGTkoGCoLZ9YFAI6japOk,1434
|
|
3
|
-
algokit_utils/account.py,sha256=
|
|
3
|
+
algokit_utils/account.py,sha256=PhNFg0rvavR1pg7SCuuHrp9fIpj0qv_FPXuPsSh7HRg,5063
|
|
4
4
|
algokit_utils/app.py,sha256=4_9sfVGP8BLfpIZKYSJQZxu_4qoDR2reOlkpg62VNVY,9692
|
|
5
|
-
algokit_utils/application_client.py,sha256=
|
|
5
|
+
algokit_utils/application_client.py,sha256=o1qA1QgLQfbR-36thDCAFlTXTjqhn3PvI9XCU-ixy2w,56305
|
|
6
6
|
algokit_utils/application_specification.py,sha256=eWaQq7cPjB7mOGzyv82wia46Umya-MC8GNoLbM3RS0o,7457
|
|
7
7
|
algokit_utils/logic_error.py,sha256=mbfs1P-QRhFRQcTnzf8GApKj5KD71T2F8uOEh132p4I,1906
|
|
8
8
|
algokit_utils/models.py,sha256=1gkqFsxNGN0ur1VrCBxbs_FO-45xb3KLBsNs_965xCE,97
|
|
9
9
|
algokit_utils/network_clients.py,sha256=6kjnEfy45BX9i5dU7jSvaBPi6i11VH6RMzEMejTnAB4,2596
|
|
10
10
|
algokit_utils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
-
algokit_utils-0.1.
|
|
12
|
-
algokit_utils-0.1.
|
|
13
|
-
algokit_utils-0.1.
|
|
14
|
-
algokit_utils-0.1.
|
|
11
|
+
algokit_utils-0.1.3.dist-info/LICENSE,sha256=J5i7U1Q9Q2c7saUzlvFRmrCCFhQyXb5Juz_LO5omNUw,1076
|
|
12
|
+
algokit_utils-0.1.3.dist-info/METADATA,sha256=OZQ3_ZxJ-WZDTdmbdEG_ivWecOOGwTAB6Q4bl8fKbLU,582
|
|
13
|
+
algokit_utils-0.1.3.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
|
|
14
|
+
algokit_utils-0.1.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|