algokit-utils 2.3.1b2__py3-none-any.whl → 2.3.2b1__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 CHANGED
@@ -39,14 +39,14 @@ def get_account_from_mnemonic(mnemonic: str) -> Account:
39
39
 
40
40
  def create_kmd_wallet_account(kmd_client: "KMDClient", name: str) -> Account:
41
41
  """Creates a wallet with specified name"""
42
- wallet_id = kmd_client.create_wallet(name, "")["id"] # type: ignore[no-untyped-call]
43
- wallet_handle = kmd_client.init_wallet_handle(wallet_id, "") # type: ignore[no-untyped-call]
44
- kmd_client.generate_key(wallet_handle) # type: ignore[no-untyped-call]
42
+ wallet_id = kmd_client.create_wallet(name, "")["id"]
43
+ wallet_handle = kmd_client.init_wallet_handle(wallet_id, "")
44
+ kmd_client.generate_key(wallet_handle)
45
45
 
46
- key_ids: list[str] = kmd_client.list_keys(wallet_handle) # type: ignore[no-untyped-call]
46
+ key_ids: list[str] = kmd_client.list_keys(wallet_handle)
47
47
  account_key = key_ids[0]
48
48
 
49
- private_account_key = kmd_client.export_key(wallet_handle, "", account_key) # type: ignore[no-untyped-call]
49
+ private_account_key = kmd_client.export_key(wallet_handle, "", account_key)
50
50
  return get_account_from_mnemonic(from_private_key(private_account_key)) # type: ignore[no-untyped-call]
51
51
 
52
52
 
@@ -116,15 +116,15 @@ def get_kmd_wallet_account(
116
116
  predicate: "Callable[[dict[str, Any]], bool] | None" = None,
117
117
  ) -> Account | None:
118
118
  """Returns wallet matching specified name and predicate or None if not found"""
119
- wallets: list[dict] = kmd_client.list_wallets() # type: ignore[no-untyped-call]
119
+ wallets: list[dict] = kmd_client.list_wallets()
120
120
 
121
121
  wallet = next((w for w in wallets if w["name"] == name), None)
122
122
  if wallet is None:
123
123
  return None
124
124
 
125
125
  wallet_id = wallet["id"]
126
- wallet_handle = kmd_client.init_wallet_handle(wallet_id, "") # type: ignore[no-untyped-call]
127
- key_ids: list[str] = kmd_client.list_keys(wallet_handle) # type: ignore[no-untyped-call]
126
+ wallet_handle = kmd_client.init_wallet_handle(wallet_id, "")
127
+ key_ids: list[str] = kmd_client.list_keys(wallet_handle)
128
128
  matched_account_key = None
129
129
  if predicate:
130
130
  for key in key_ids:
@@ -138,7 +138,7 @@ def get_kmd_wallet_account(
138
138
  if not matched_account_key:
139
139
  return None
140
140
 
141
- private_account_key = kmd_client.export_key(wallet_handle, "", matched_account_key) # type: ignore[no-untyped-call]
141
+ private_account_key = kmd_client.export_key(wallet_handle, "", matched_account_key)
142
142
  return get_account_from_mnemonic(from_private_key(private_account_key)) # type: ignore[no-untyped-call]
143
143
 
144
144
 
@@ -49,6 +49,7 @@ from algokit_utils.models import (
49
49
  CreateCallParametersDict,
50
50
  OnCompleteCallParameters,
51
51
  OnCompleteCallParametersDict,
52
+ SimulationTrace,
52
53
  TransactionParameters,
53
54
  TransactionParametersDict,
54
55
  TransactionResponse,
@@ -232,7 +233,7 @@ class ApplicationClient:
232
233
  ) -> "ApplicationClient":
233
234
  """Creates a copy of this ApplicationClient, using the new signer, sender and app_id values if provided.
234
235
  Will also substitute provided template_values into the associated app_spec in the copy"""
235
- new_client: "ApplicationClient" = copy.copy(self)
236
+ new_client: ApplicationClient = copy.copy(self)
236
237
  new_client._prepare( # noqa: SLF001
237
238
  new_client, signer=signer, sender=sender, app_id=app_id, template_values=template_values
238
239
  )
@@ -1236,7 +1237,7 @@ def _try_convert_to_logic_error(
1236
1237
  source_ex: Exception | str,
1237
1238
  approval_program: str,
1238
1239
  approval_source_map: SourceMap | typing.Callable[[], SourceMap | None] | None = None,
1239
- simulate_traces: list | None = None,
1240
+ simulate_traces: list[SimulationTrace] | None = None,
1240
1241
  ) -> Exception | None:
1241
1242
  source_ex_str = str(source_ex)
1242
1243
  logic_error_data = parse_logic_error(source_ex_str)
@@ -1297,7 +1298,7 @@ def execute_atc_with_logic_error(
1297
1298
  raise ex
1298
1299
 
1299
1300
 
1300
- def _create_simulate_traces(simulate: SimulateAtomicTransactionResponse) -> list[dict[str, Any]]:
1301
+ def _create_simulate_traces(simulate: SimulateAtomicTransactionResponse) -> list[SimulationTrace]:
1301
1302
  traces = []
1302
1303
  if hasattr(simulate, "simulate_response") and hasattr(simulate, "failed_at") and simulate.failed_at:
1303
1304
  for txn_group in simulate.simulate_response["txn-groups"]:
@@ -1307,12 +1308,12 @@ def _create_simulate_traces(simulate: SimulateAtomicTransactionResponse) -> list
1307
1308
  txn_result = txn_group.get("txn-results", [{}])[0]
1308
1309
  exec_trace = txn_result.get("exec-trace", {})
1309
1310
  traces.append(
1310
- {
1311
- "app-budget-added": app_budget_added,
1312
- "app-budget-consumed": app_budget_consumed,
1313
- "failure-message": failure_message,
1314
- "exec-trace": exec_trace,
1315
- }
1311
+ SimulationTrace(
1312
+ app_budget_added=app_budget_added,
1313
+ app_budget_consumed=app_budget_consumed,
1314
+ failure_message=failure_message,
1315
+ exec_trace=exec_trace,
1316
+ )
1316
1317
  )
1317
1318
  return traces
1318
1319
 
@@ -567,7 +567,7 @@ class AlgokitComposer:
567
567
 
568
568
  return isinstance(x, bool | int | float | str | bytes)
569
569
 
570
- def _build_method_call(
570
+ def _build_method_call( # noqa: C901, PLR0912
571
571
  self, params: MethodCallParams, suggested_params: algosdk.transaction.SuggestedParams
572
572
  ) -> list[TransactionWithSigner]:
573
573
  method_args = []
@@ -633,7 +633,7 @@ class AlgokitComposer:
633
633
 
634
634
  return self._build_atc(method_atc)
635
635
 
636
- def _build_txn(
636
+ def _build_txn( # noqa: C901, PLR0912
637
637
  self,
638
638
  txn: TransactionWithSigner | TxnParams | AtomicTransactionComposer,
639
639
  suggested_params: algosdk.transaction.SuggestedParams,
algokit_utils/deploy.py CHANGED
@@ -325,29 +325,45 @@ def add_deploy_template_variables(
325
325
 
326
326
 
327
327
  def _find_unquoted_string(line: str, token: str, start: int = 0, end: int = -1) -> int | None:
328
- """Find the first string within a line of TEAL. Only matches outside of quotes are returned.
328
+ """Find the first string within a line of TEAL. Only matches outside of quotes and base64 are returned.
329
329
  Returns None if not found"""
330
330
 
331
331
  if end < 0:
332
332
  end = len(line)
333
333
  idx = start
334
- in_quotes = False
334
+ in_quotes = in_base64 = False
335
335
  while idx < end:
336
336
  current_char = line[idx]
337
337
  match current_char:
338
- case "\\":
339
- if in_quotes: # skip next character
340
- idx += 1
338
+ # enter base64
339
+ case " " | "(" if not in_quotes and _last_token_base64(line, idx):
340
+ in_base64 = True
341
+ # exit base64
342
+ case " " | ")" if not in_quotes and in_base64:
343
+ in_base64 = False
344
+ # escaped char
345
+ case "\\" if in_quotes:
346
+ # skip next character
347
+ idx += 1
348
+ # quote boundary
341
349
  case '"':
342
350
  in_quotes = not in_quotes
343
- case _:
351
+ # can test for match
352
+ case _ if not in_quotes and not in_base64 and line.startswith(token, idx):
344
353
  # only match if not in quotes and string matches
345
- if not in_quotes and line.startswith(token, idx):
346
- return idx
354
+ return idx
347
355
  idx += 1
348
356
  return None
349
357
 
350
358
 
359
+ def _last_token_base64(line: str, idx: int) -> bool:
360
+ try:
361
+ *_, last = line[:idx].split()
362
+ except ValueError:
363
+ return False
364
+ return last in ("base64", "b64")
365
+
366
+
351
367
  def _find_template_token(line: str, token: str, start: int = 0, end: int = -1) -> int | None:
352
368
  """Find the first template token within a line of TEAL. Only matches outside of quotes are returned.
353
369
  Only full token matches are returned, i.e. TMPL_STR will not match against TMPL_STRING
@@ -851,7 +867,7 @@ def _convert_deploy_args(
851
867
  signer: TransactionSigner | None,
852
868
  sender: str | None,
853
869
  ) -> tuple[ABIMethod | bool | None, ABIArgsDict, CreateCallParameters]:
854
- args = _args.__dict__ if isinstance(_args, DeployCallArgs) else (_args or {})
870
+ args = _args.__dict__ if isinstance(_args, DeployCallArgs) else dict(_args or {})
855
871
 
856
872
  # return most derived type, unused parameters are ignored
857
873
  parameters = CreateCallParameters(
@@ -2,6 +2,8 @@ import re
2
2
  from copy import copy
3
3
  from typing import TYPE_CHECKING, TypedDict
4
4
 
5
+ from algokit_utils.models import SimulationTrace
6
+
5
7
  if TYPE_CHECKING:
6
8
  from algosdk.source_map import SourceMap as AlgoSourceMap
7
9
 
@@ -46,7 +48,7 @@ class LogicError(Exception):
46
48
  message: str,
47
49
  pc: int,
48
50
  logic_error: Exception | None = None,
49
- traces: list | None = None,
51
+ traces: list[SimulationTrace] | None = None,
50
52
  ):
51
53
  self.logic_error = logic_error
52
54
  self.logic_error_str = logic_error_str
algokit_utils/models.py CHANGED
@@ -230,3 +230,11 @@ class CommonCallParameters(TransactionParameters):
230
230
  @deprecated(reason="Use TransactionParametersDict instead", version="1.3.1")
231
231
  class CommonCallParametersDict(TransactionParametersDict):
232
232
  """Deprecated, use TransactionParametersDict instead"""
233
+
234
+
235
+ @dataclasses.dataclass
236
+ class SimulationTrace:
237
+ app_budget_added: int | None
238
+ app_budget_consumed: int | None
239
+ failure_message: str | None
240
+ exec_trace: dict[str, object]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: algokit-utils
3
- Version: 2.3.1b2
3
+ Version: 2.3.2b1
4
4
  Summary: Utilities for Algorand development for use by AlgoKit
5
5
  License: MIT
6
6
  Author: Algorand Foundation
@@ -11,6 +11,7 @@ Classifier: Programming Language :: Python :: 3
11
11
  Classifier: Programming Language :: Python :: 3.10
12
12
  Classifier: Programming Language :: Python :: 3.11
13
13
  Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
14
15
  Requires-Dist: deprecated (>=1.2.14,<2.0.0)
15
16
  Requires-Dist: httpx (>=0.23.1,<0.24.0)
16
17
  Requires-Dist: py-algorand-sdk (>=2.4.0,<3.0.0)
@@ -2,23 +2,23 @@ algokit_utils/__init__.py,sha256=Xc9NVy3cETI2qzbkkAea2YrZ9-CLtZLHnuS1UHQ13wQ,490
2
2
  algokit_utils/_debugging.py,sha256=4UC5NZGqxF32y742TUB34rX9kWaObXCCPOs-lbkQjGQ,10732
3
3
  algokit_utils/_ensure_funded.py,sha256=ZdEdUB43QGIQrg7cSSgNrDmWaLSUhli9x9I6juwKfgo,6786
4
4
  algokit_utils/_transfer.py,sha256=R9q8RoMHiwtqcwQjuGHEluMxIzmYqAsI5WrTsQd24Ds,6021
5
- algokit_utils/account.py,sha256=UIuOQZe28pQxjEP9TzhtYlOU20tUdzzS-nIIZM9Bp6Y,7364
6
- algokit_utils/application_client.py,sha256=xOZJ8i3y8wDJL0Uvaw1o-UmJKvSmbv8ib5RwGl4ar0w,58661
5
+ algokit_utils/account.py,sha256=JYovI84sxiU2mIbwNwWVuoEJBMuAPJauHx5jkKFrR7E,7067
6
+ algokit_utils/application_client.py,sha256=sDSUBsLhoPJkjTlkWLAOh-DLkEhLypH3p5VzJkSlIx4,58701
7
7
  algokit_utils/application_specification.py,sha256=XusOe7VrGPun2UoNspC9Ei202NzPkxRNx5USXiABuXc,7466
8
8
  algokit_utils/asset.py,sha256=jsc7T1dH9HZA3Yve2gRLObwUlK6xLDoQz0NxLLnqaGs,7216
9
9
  algokit_utils/beta/account_manager.py,sha256=dSb-jpBAWRfmKFYzG6T8t5vkh6ysX2NkZXl5UcZY5WA,8015
10
10
  algokit_utils/beta/algorand_client.py,sha256=y1CYYn_ADwgOLTVID9BFMvdubDgKqUfx9R6XH3PrzsA,12649
11
11
  algokit_utils/beta/client_manager.py,sha256=rW58VVBdYAV_5QwXNyt3VMP8NGon_IRhq1Dr35Mp31g,3117
12
- algokit_utils/beta/composer.py,sha256=qpIWQ6Xeysk1FzqW8AntHJ_go_W2qIEDB4uvGFOOdgM,28627
12
+ algokit_utils/beta/composer.py,sha256=isGd8obdf8F4Agnq-yG7mVHxt4VtihZFZNR9LHx5_ek,28673
13
13
  algokit_utils/common.py,sha256=K6-3_9dv2clDn0WMYb8AWE_N46kWWIXglZIPfHIowDs,812
14
14
  algokit_utils/config.py,sha256=oY3o1kPzVPRiQH--f4HzrMMNPojT078CSudqS9WQaEc,4279
15
- algokit_utils/deploy.py,sha256=ydE3QSq1lRkjXQC9zdFclywx8q1UgV9l-l3Mx-shbHg,34668
15
+ algokit_utils/deploy.py,sha256=AQz7FTeIpprI83jT470bSgAkqObZc1UgqWxWkEbJjEk,35216
16
16
  algokit_utils/dispenser_api.py,sha256=BpwEhKDig6qz54wbO-htG8hmLxFIrvdzXpESUb7Y1zw,5584
17
- algokit_utils/logic_error.py,sha256=YeE70qHZ6WBeoKCXqnto3uBg8R4ODXiNZkLmfEmASQo,2617
18
- algokit_utils/models.py,sha256=GWpZQ2bTGfkldM12VZntGlVJTFBTtWf5SM7ZYXC_LHE,8238
17
+ algokit_utils/logic_error.py,sha256=I9fJJ09zfpPlKgcJJ7fqC77BBPTz37QsSlGfZwXDdPQ,2684
18
+ algokit_utils/models.py,sha256=KMpSUv7XGjZ9_50U6qUjcPjGh9_7lsRj3ZlO9Fb2zyE,8421
19
19
  algokit_utils/network_clients.py,sha256=TlGRZ4l62_vi__AKg9zyVGiAawTrA0ca6AfPDzRL44E,5136
20
20
  algokit_utils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
- algokit_utils-2.3.1b2.dist-info/LICENSE,sha256=J5i7U1Q9Q2c7saUzlvFRmrCCFhQyXb5Juz_LO5omNUw,1076
22
- algokit_utils-2.3.1b2.dist-info/METADATA,sha256=bYg4HprMBpFc42M-oQ4KI76buhb_K5sXdkTtX02_ot4,2207
23
- algokit_utils-2.3.1b2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
24
- algokit_utils-2.3.1b2.dist-info/RECORD,,
21
+ algokit_utils-2.3.2b1.dist-info/LICENSE,sha256=J5i7U1Q9Q2c7saUzlvFRmrCCFhQyXb5Juz_LO5omNUw,1076
22
+ algokit_utils-2.3.2b1.dist-info/METADATA,sha256=FPpHJR9cdNhQ-uJt7kTdkox0MXNugTis61YYusNH8IQ,2258
23
+ algokit_utils-2.3.2b1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
24
+ algokit_utils-2.3.2b1.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.9.0
2
+ Generator: poetry-core 1.9.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any