algokit-utils 2.4.0b1__py3-none-any.whl → 3.0.0__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/__init__.py +23 -181
- algokit_utils/_debugging.py +89 -45
- algokit_utils/_legacy_v2/__init__.py +177 -0
- algokit_utils/{_ensure_funded.py → _legacy_v2/_ensure_funded.py} +21 -24
- algokit_utils/{_transfer.py → _legacy_v2/_transfer.py} +26 -23
- algokit_utils/_legacy_v2/account.py +203 -0
- algokit_utils/_legacy_v2/application_client.py +1472 -0
- algokit_utils/_legacy_v2/application_specification.py +21 -0
- algokit_utils/_legacy_v2/asset.py +168 -0
- algokit_utils/_legacy_v2/common.py +28 -0
- algokit_utils/_legacy_v2/deploy.py +822 -0
- algokit_utils/_legacy_v2/logic_error.py +14 -0
- algokit_utils/{models.py → _legacy_v2/models.py} +16 -45
- algokit_utils/_legacy_v2/network_clients.py +144 -0
- algokit_utils/account.py +12 -183
- algokit_utils/accounts/__init__.py +2 -0
- algokit_utils/accounts/account_manager.py +912 -0
- algokit_utils/accounts/kmd_account_manager.py +161 -0
- algokit_utils/algorand.py +359 -0
- algokit_utils/application_client.py +9 -1447
- algokit_utils/application_specification.py +39 -197
- algokit_utils/applications/__init__.py +7 -0
- algokit_utils/applications/abi.py +275 -0
- algokit_utils/applications/app_client.py +2108 -0
- algokit_utils/applications/app_deployer.py +725 -0
- algokit_utils/applications/app_factory.py +1134 -0
- algokit_utils/applications/app_manager.py +578 -0
- algokit_utils/applications/app_spec/__init__.py +2 -0
- algokit_utils/applications/app_spec/arc32.py +207 -0
- algokit_utils/applications/app_spec/arc56.py +989 -0
- algokit_utils/applications/enums.py +40 -0
- algokit_utils/asset.py +32 -168
- algokit_utils/assets/__init__.py +1 -0
- algokit_utils/assets/asset_manager.py +336 -0
- algokit_utils/beta/_utils.py +36 -0
- algokit_utils/beta/account_manager.py +4 -195
- algokit_utils/beta/algorand_client.py +4 -314
- algokit_utils/beta/client_manager.py +5 -74
- algokit_utils/beta/composer.py +5 -712
- algokit_utils/clients/__init__.py +2 -0
- algokit_utils/clients/client_manager.py +738 -0
- algokit_utils/clients/dispenser_api_client.py +224 -0
- algokit_utils/common.py +8 -26
- algokit_utils/config.py +76 -29
- algokit_utils/deploy.py +7 -894
- algokit_utils/dispenser_api.py +8 -176
- algokit_utils/errors/__init__.py +1 -0
- algokit_utils/errors/logic_error.py +121 -0
- algokit_utils/logic_error.py +7 -82
- algokit_utils/models/__init__.py +8 -0
- algokit_utils/models/account.py +217 -0
- algokit_utils/models/amount.py +200 -0
- algokit_utils/models/application.py +91 -0
- algokit_utils/models/network.py +29 -0
- algokit_utils/models/simulate.py +11 -0
- algokit_utils/models/state.py +68 -0
- algokit_utils/models/transaction.py +100 -0
- algokit_utils/network_clients.py +7 -128
- algokit_utils/protocols/__init__.py +2 -0
- algokit_utils/protocols/account.py +22 -0
- algokit_utils/protocols/typed_clients.py +108 -0
- algokit_utils/transactions/__init__.py +3 -0
- algokit_utils/transactions/transaction_composer.py +2499 -0
- algokit_utils/transactions/transaction_creator.py +688 -0
- algokit_utils/transactions/transaction_sender.py +1219 -0
- {algokit_utils-2.4.0b1.dist-info → algokit_utils-3.0.0.dist-info}/METADATA +11 -7
- algokit_utils-3.0.0.dist-info/RECORD +70 -0
- {algokit_utils-2.4.0b1.dist-info → algokit_utils-3.0.0.dist-info}/WHEEL +1 -1
- algokit_utils-2.4.0b1.dist-info/RECORD +0 -24
- {algokit_utils-2.4.0b1.dist-info → algokit_utils-3.0.0.dist-info}/LICENSE +0 -0
algokit_utils/__init__.py
CHANGED
|
@@ -1,182 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
from algokit_utils._ensure_funded import EnsureBalanceParameters, EnsureFundedResponse, ensure_funded
|
|
3
|
-
from algokit_utils._transfer import TransferAssetParameters, TransferParameters, transfer, transfer_asset
|
|
4
|
-
from algokit_utils.account import (
|
|
5
|
-
create_kmd_wallet_account,
|
|
6
|
-
get_account,
|
|
7
|
-
get_account_from_mnemonic,
|
|
8
|
-
get_dispenser_account,
|
|
9
|
-
get_kmd_wallet_account,
|
|
10
|
-
get_localnet_default_account,
|
|
11
|
-
get_or_create_kmd_wallet_account,
|
|
12
|
-
)
|
|
13
|
-
from algokit_utils.application_client import (
|
|
14
|
-
ApplicationClient,
|
|
15
|
-
execute_atc_with_logic_error,
|
|
16
|
-
get_next_version,
|
|
17
|
-
get_sender_from_signer,
|
|
18
|
-
num_extra_program_pages,
|
|
19
|
-
)
|
|
20
|
-
from algokit_utils.application_specification import (
|
|
21
|
-
ApplicationSpecification,
|
|
22
|
-
AppSpecStateDict,
|
|
23
|
-
CallConfig,
|
|
24
|
-
DefaultArgumentDict,
|
|
25
|
-
DefaultArgumentType,
|
|
26
|
-
MethodConfigDict,
|
|
27
|
-
MethodHints,
|
|
28
|
-
OnCompleteActionName,
|
|
29
|
-
)
|
|
30
|
-
from algokit_utils.asset import opt_in, opt_out
|
|
31
|
-
from algokit_utils.common import Program
|
|
32
|
-
from algokit_utils.deploy import (
|
|
33
|
-
DELETABLE_TEMPLATE_NAME,
|
|
34
|
-
NOTE_PREFIX,
|
|
35
|
-
UPDATABLE_TEMPLATE_NAME,
|
|
36
|
-
ABICallArgs,
|
|
37
|
-
ABICallArgsDict,
|
|
38
|
-
ABICreateCallArgs,
|
|
39
|
-
ABICreateCallArgsDict,
|
|
40
|
-
AppDeployMetaData,
|
|
41
|
-
AppLookup,
|
|
42
|
-
AppMetaData,
|
|
43
|
-
AppReference,
|
|
44
|
-
DeployCallArgs,
|
|
45
|
-
DeployCallArgsDict,
|
|
46
|
-
DeployCreateCallArgs,
|
|
47
|
-
DeployCreateCallArgsDict,
|
|
48
|
-
DeploymentFailedError,
|
|
49
|
-
DeployResponse,
|
|
50
|
-
OnSchemaBreak,
|
|
51
|
-
OnUpdate,
|
|
52
|
-
OperationPerformed,
|
|
53
|
-
TemplateValueDict,
|
|
54
|
-
TemplateValueMapping,
|
|
55
|
-
get_app_id_from_tx_id,
|
|
56
|
-
get_creator_apps,
|
|
57
|
-
replace_template_variables,
|
|
58
|
-
)
|
|
59
|
-
from algokit_utils.dispenser_api import (
|
|
60
|
-
DISPENSER_ACCESS_TOKEN_KEY,
|
|
61
|
-
DISPENSER_REQUEST_TIMEOUT,
|
|
62
|
-
DispenserFundResponse,
|
|
63
|
-
DispenserLimitResponse,
|
|
64
|
-
TestNetDispenserApiClient,
|
|
65
|
-
)
|
|
66
|
-
from algokit_utils.logic_error import LogicError
|
|
67
|
-
from algokit_utils.models import (
|
|
68
|
-
ABIArgsDict,
|
|
69
|
-
ABIMethod,
|
|
70
|
-
ABITransactionResponse,
|
|
71
|
-
Account,
|
|
72
|
-
CommonCallParameters, # noqa: F401
|
|
73
|
-
CommonCallParametersDict, # noqa: F401
|
|
74
|
-
CreateCallParameters,
|
|
75
|
-
CreateCallParametersDict,
|
|
76
|
-
CreateTransactionParameters,
|
|
77
|
-
OnCompleteCallParameters,
|
|
78
|
-
OnCompleteCallParametersDict,
|
|
79
|
-
RawTransactionParameters, # noqa: F401
|
|
80
|
-
TransactionParameters,
|
|
81
|
-
TransactionParametersDict,
|
|
82
|
-
TransactionResponse,
|
|
83
|
-
)
|
|
84
|
-
from algokit_utils.network_clients import (
|
|
85
|
-
AlgoClientConfig,
|
|
86
|
-
get_algod_client,
|
|
87
|
-
get_algonode_config,
|
|
88
|
-
get_default_localnet_config,
|
|
89
|
-
get_indexer_client,
|
|
90
|
-
get_kmd_client_from_algod_client,
|
|
91
|
-
is_localnet,
|
|
92
|
-
is_mainnet,
|
|
93
|
-
is_testnet,
|
|
94
|
-
)
|
|
1
|
+
"""AlgoKit Python Utilities - a set of utilities for building solutions on Algorand
|
|
95
2
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
"ABICreateCallArgsDict",
|
|
119
|
-
"ABIMethod",
|
|
120
|
-
"CreateCallParameters",
|
|
121
|
-
"CreateCallParametersDict",
|
|
122
|
-
"CreateTransactionParameters",
|
|
123
|
-
"DeployCallArgs",
|
|
124
|
-
"DeployCreateCallArgs",
|
|
125
|
-
"DeployCallArgsDict",
|
|
126
|
-
"DeployCreateCallArgsDict",
|
|
127
|
-
"OnCompleteCallParameters",
|
|
128
|
-
"OnCompleteCallParametersDict",
|
|
129
|
-
"TransactionParameters",
|
|
130
|
-
"TransactionParametersDict",
|
|
131
|
-
"ApplicationClient",
|
|
132
|
-
"DeployResponse",
|
|
133
|
-
"OnUpdate",
|
|
134
|
-
"OnSchemaBreak",
|
|
135
|
-
"OperationPerformed",
|
|
136
|
-
"TemplateValueDict",
|
|
137
|
-
"TemplateValueMapping",
|
|
138
|
-
"Program",
|
|
139
|
-
"execute_atc_with_logic_error",
|
|
140
|
-
"get_app_id_from_tx_id",
|
|
141
|
-
"get_next_version",
|
|
142
|
-
"get_sender_from_signer",
|
|
143
|
-
"num_extra_program_pages",
|
|
144
|
-
"AppSpecStateDict",
|
|
145
|
-
"ApplicationSpecification",
|
|
146
|
-
"CallConfig",
|
|
147
|
-
"DefaultArgumentDict",
|
|
148
|
-
"DefaultArgumentType",
|
|
149
|
-
"MethodConfigDict",
|
|
150
|
-
"OnCompleteActionName",
|
|
151
|
-
"MethodHints",
|
|
152
|
-
"LogicError",
|
|
153
|
-
"ABITransactionResponse",
|
|
154
|
-
"Account",
|
|
155
|
-
"TransactionResponse",
|
|
156
|
-
"AlgoClientConfig",
|
|
157
|
-
"get_algod_client",
|
|
158
|
-
"get_algonode_config",
|
|
159
|
-
"get_default_localnet_config",
|
|
160
|
-
"get_indexer_client",
|
|
161
|
-
"get_kmd_client_from_algod_client",
|
|
162
|
-
"is_localnet",
|
|
163
|
-
"is_mainnet",
|
|
164
|
-
"is_testnet",
|
|
165
|
-
"TestNetDispenserApiClient",
|
|
166
|
-
"DispenserFundResponse",
|
|
167
|
-
"DispenserLimitResponse",
|
|
168
|
-
"DISPENSER_ACCESS_TOKEN_KEY",
|
|
169
|
-
"DISPENSER_REQUEST_TIMEOUT",
|
|
170
|
-
"EnsureBalanceParameters",
|
|
171
|
-
"EnsureFundedResponse",
|
|
172
|
-
"TransferParameters",
|
|
173
|
-
"ensure_funded",
|
|
174
|
-
"transfer",
|
|
175
|
-
"TransferAssetParameters",
|
|
176
|
-
"transfer_asset",
|
|
177
|
-
"opt_in",
|
|
178
|
-
"opt_out",
|
|
179
|
-
"persist_sourcemaps",
|
|
180
|
-
"PersistSourceMapInput",
|
|
181
|
-
"simulate_and_persist_response",
|
|
182
|
-
]
|
|
3
|
+
This module provides commonly used utilities and types at the root level for convenience.
|
|
4
|
+
For more specific functionality, import directly from the relevant submodules:
|
|
5
|
+
|
|
6
|
+
from algokit_utils.accounts import KmdAccountManager
|
|
7
|
+
from algokit_utils.applications import AppClient
|
|
8
|
+
from algokit_utils.applications.app_spec import Arc52Contract
|
|
9
|
+
etc.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
# Core types and utilities that are commonly used
|
|
13
|
+
from algokit_utils.applications import * # noqa: F403
|
|
14
|
+
from algokit_utils.assets import * # noqa: F403
|
|
15
|
+
from algokit_utils.protocols import * # noqa: F403
|
|
16
|
+
from algokit_utils.models import * # noqa: F403
|
|
17
|
+
from algokit_utils.accounts import * # noqa: F403
|
|
18
|
+
from algokit_utils.clients import * # noqa: F403
|
|
19
|
+
from algokit_utils.transactions import * # noqa: F403
|
|
20
|
+
from algokit_utils.errors import * # noqa: F403
|
|
21
|
+
from algokit_utils.algorand import * # noqa: F403
|
|
22
|
+
|
|
23
|
+
# Legacy types and utilities
|
|
24
|
+
from algokit_utils._legacy_v2 import * # noqa: F403
|
algokit_utils/_debugging.py
CHANGED
|
@@ -14,7 +14,8 @@ from algosdk.atomic_transaction_composer import (
|
|
|
14
14
|
from algosdk.encoding import checksum
|
|
15
15
|
from algosdk.v2client.models import SimulateRequest, SimulateRequestTransactionGroup, SimulateTraceConfig
|
|
16
16
|
|
|
17
|
-
from algokit_utils.common import Program
|
|
17
|
+
from algokit_utils._legacy_v2.common import Program
|
|
18
|
+
from algokit_utils.models.application import CompiledTeal
|
|
18
19
|
|
|
19
20
|
if typing.TYPE_CHECKING:
|
|
20
21
|
from algosdk.v2client.algod import AlgodClient
|
|
@@ -64,7 +65,11 @@ class AVMDebuggerSourceMap:
|
|
|
64
65
|
@dataclass
|
|
65
66
|
class PersistSourceMapInput:
|
|
66
67
|
def __init__(
|
|
67
|
-
self,
|
|
68
|
+
self,
|
|
69
|
+
app_name: str,
|
|
70
|
+
file_name: str,
|
|
71
|
+
raw_teal: str | None = None,
|
|
72
|
+
compiled_teal: CompiledTeal | Program | None = None,
|
|
68
73
|
):
|
|
69
74
|
self.compiled_teal = compiled_teal
|
|
70
75
|
self.app_name = app_name
|
|
@@ -76,7 +81,9 @@ class PersistSourceMapInput:
|
|
|
76
81
|
return cls(app_name, file_name, raw_teal=raw_teal)
|
|
77
82
|
|
|
78
83
|
@classmethod
|
|
79
|
-
def from_compiled_teal(
|
|
84
|
+
def from_compiled_teal(
|
|
85
|
+
cls, compiled_teal: CompiledTeal | Program, app_name: str, file_name: str
|
|
86
|
+
) -> "PersistSourceMapInput":
|
|
80
87
|
return cls(app_name, file_name, compiled_teal=compiled_teal)
|
|
81
88
|
|
|
82
89
|
@property
|
|
@@ -112,24 +119,35 @@ def _write_to_file(path: Path, content: str) -> None:
|
|
|
112
119
|
path.write_text(content)
|
|
113
120
|
|
|
114
121
|
|
|
115
|
-
def _build_avm_sourcemap(
|
|
122
|
+
def _build_avm_sourcemap(
|
|
116
123
|
*,
|
|
117
124
|
app_name: str,
|
|
118
125
|
file_name: str,
|
|
119
126
|
output_path: Path,
|
|
120
127
|
client: "AlgodClient",
|
|
121
128
|
raw_teal: str | None = None,
|
|
122
|
-
compiled_teal: Program | None = None,
|
|
129
|
+
compiled_teal: CompiledTeal | Program | None = None,
|
|
123
130
|
with_sources: bool = True,
|
|
124
131
|
) -> AVMDebuggerSourceMapEntry:
|
|
125
132
|
if not raw_teal and not compiled_teal:
|
|
126
133
|
raise ValueError("Either raw teal or compiled teal must be provided")
|
|
127
134
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
checksum(
|
|
131
|
-
|
|
132
|
-
|
|
135
|
+
# Handle both legacy Program and new CompiledTeal
|
|
136
|
+
if isinstance(compiled_teal, Program):
|
|
137
|
+
program_hash = base64.b64encode(checksum(compiled_teal.raw_binary)).decode()
|
|
138
|
+
source_map = compiled_teal.source_map.__dict__
|
|
139
|
+
teal_content = compiled_teal.teal
|
|
140
|
+
elif isinstance(compiled_teal, CompiledTeal):
|
|
141
|
+
program_hash = base64.b64encode(checksum(compiled_teal.compiled_base64_to_bytes)).decode()
|
|
142
|
+
source_map = compiled_teal.source_map.__dict__ if compiled_teal.source_map else {}
|
|
143
|
+
teal_content = compiled_teal.teal
|
|
144
|
+
else:
|
|
145
|
+
# Handle raw TEAL case
|
|
146
|
+
result = Program(str(raw_teal), client=client)
|
|
147
|
+
program_hash = base64.b64encode(checksum(result.raw_binary)).decode()
|
|
148
|
+
source_map = result.source_map.__dict__
|
|
149
|
+
teal_content = result.teal
|
|
150
|
+
|
|
133
151
|
source_map["sources"] = [f"{file_name}{TEAL_FILE_EXT}"] if with_sources else []
|
|
134
152
|
|
|
135
153
|
output_dir_path = output_path / ALGOKIT_DIR / SOURCES_DIR / app_name
|
|
@@ -138,7 +156,7 @@ def _build_avm_sourcemap( # noqa: PLR0913
|
|
|
138
156
|
_write_to_file(source_map_output_path, json.dumps(source_map))
|
|
139
157
|
|
|
140
158
|
if with_sources:
|
|
141
|
-
_write_to_file(teal_output_path,
|
|
159
|
+
_write_to_file(teal_output_path, teal_content)
|
|
142
160
|
|
|
143
161
|
return AVMDebuggerSourceMapEntry(str(source_map_output_path), program_hash)
|
|
144
162
|
|
|
@@ -169,12 +187,11 @@ def persist_sourcemaps(
|
|
|
169
187
|
) -> None:
|
|
170
188
|
"""
|
|
171
189
|
Persist the sourcemaps for the given sources as an AlgoKit AVM Debugger compliant artifacts.
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
Default is True, as needed by an AlgoKit AVM debugger.
|
|
190
|
+
|
|
191
|
+
:param sources: A list of PersistSourceMapInput objects.
|
|
192
|
+
:param project_root: The root directory of the project.
|
|
193
|
+
:param client: An AlgodClient object for interacting with the Algorand blockchain.
|
|
194
|
+
:param with_sources: If True, it will dump teal source files along with sourcemaps.
|
|
178
195
|
"""
|
|
179
196
|
|
|
180
197
|
for source in sources:
|
|
@@ -189,17 +206,17 @@ def persist_sourcemaps(
|
|
|
189
206
|
)
|
|
190
207
|
|
|
191
208
|
|
|
192
|
-
def simulate_response(
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
"""
|
|
209
|
+
def simulate_response(
|
|
210
|
+
atc: AtomicTransactionComposer,
|
|
211
|
+
algod_client: "AlgodClient",
|
|
212
|
+
allow_more_logs: bool | None = None,
|
|
213
|
+
allow_empty_signatures: bool | None = None,
|
|
214
|
+
allow_unnamed_resources: bool | None = None,
|
|
215
|
+
extra_opcode_budget: int | None = None,
|
|
216
|
+
exec_trace_config: SimulateTraceConfig | None = None,
|
|
217
|
+
simulation_round: int | None = None,
|
|
218
|
+
) -> SimulateAtomicTransactionResponse:
|
|
219
|
+
"""Simulate atomic transaction group execution"""
|
|
203
220
|
|
|
204
221
|
unsigned_txn_groups = atc.build_group()
|
|
205
222
|
empty_signer = EmptySigner()
|
|
@@ -209,28 +226,46 @@ def simulate_response(atc: AtomicTransactionComposer, algod_client: "AlgodClient
|
|
|
209
226
|
trace_config = SimulateTraceConfig(enable=True, stack_change=True, scratch_change=True, state_change=True)
|
|
210
227
|
|
|
211
228
|
simulate_request = SimulateRequest(
|
|
212
|
-
txn_groups=txn_group,
|
|
229
|
+
txn_groups=txn_group,
|
|
230
|
+
allow_more_logs=allow_more_logs if allow_more_logs is not None else True,
|
|
231
|
+
round=simulation_round,
|
|
232
|
+
extra_opcode_budget=extra_opcode_budget if extra_opcode_budget is not None else 0,
|
|
233
|
+
allow_unnamed_resources=allow_unnamed_resources if allow_unnamed_resources is not None else True,
|
|
234
|
+
allow_empty_signatures=allow_empty_signatures if allow_empty_signatures is not None else True,
|
|
235
|
+
exec_trace_config=exec_trace_config if exec_trace_config is not None else trace_config,
|
|
213
236
|
)
|
|
237
|
+
|
|
214
238
|
return atc.simulate(algod_client, simulate_request)
|
|
215
239
|
|
|
216
240
|
|
|
217
241
|
def simulate_and_persist_response(
|
|
218
|
-
atc: AtomicTransactionComposer,
|
|
242
|
+
atc: AtomicTransactionComposer,
|
|
243
|
+
project_root: Path,
|
|
244
|
+
algod_client: "AlgodClient",
|
|
245
|
+
buffer_size_mb: float = 256,
|
|
246
|
+
allow_more_logs: bool | None = None,
|
|
247
|
+
allow_empty_signatures: bool | None = None,
|
|
248
|
+
allow_unnamed_resources: bool | None = None,
|
|
249
|
+
extra_opcode_budget: int | None = None,
|
|
250
|
+
exec_trace_config: SimulateTraceConfig | None = None,
|
|
251
|
+
simulation_round: int | None = None,
|
|
219
252
|
) -> SimulateAtomicTransactionResponse:
|
|
220
|
-
"""
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
:param project_root:
|
|
227
|
-
:param algod_client:
|
|
228
|
-
:param buffer_size_mb:
|
|
229
|
-
:
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
253
|
+
"""Simulates atomic transactions and persists simulation response to a JSON file.
|
|
254
|
+
|
|
255
|
+
Simulates the atomic transactions using the provided AtomicTransactionComposer and AlgodClient,
|
|
256
|
+
then persists the simulation response to an AlgoKit AVM Debugger compliant JSON file.
|
|
257
|
+
|
|
258
|
+
:param atc: AtomicTransactionComposer containing transactions to simulate and persist
|
|
259
|
+
:param project_root: Root directory path of the project
|
|
260
|
+
:param algod_client: Algorand client instance
|
|
261
|
+
:param buffer_size_mb: Size of trace buffer in megabytes, defaults to 256
|
|
262
|
+
:param allow_more_logs: Flag to allow additional logs, defaults to None
|
|
263
|
+
:param allow_empty_signatures: Flag to allow empty signatures, defaults to None
|
|
264
|
+
:param allow_unnamed_resources: Flag to allow unnamed resources, defaults to None
|
|
265
|
+
:param extra_opcode_budget: Additional opcode budget, defaults to None
|
|
266
|
+
:param exec_trace_config: Execution trace configuration, defaults to None
|
|
267
|
+
:param simulation_round: Round number for simulation, defa ults to None
|
|
268
|
+
:return: Simulated response after persisting for AlgoKit AVM Debugger consumption
|
|
234
269
|
"""
|
|
235
270
|
atc_to_simulate = atc.clone()
|
|
236
271
|
sp = algod_client.suggested_params()
|
|
@@ -240,7 +275,16 @@ def simulate_and_persist_response(
|
|
|
240
275
|
txn_with_sign.txn.last_valid_round = sp.last
|
|
241
276
|
txn_with_sign.txn.genesis_hash = sp.gh
|
|
242
277
|
|
|
243
|
-
response = simulate_response(
|
|
278
|
+
response = simulate_response(
|
|
279
|
+
atc_to_simulate,
|
|
280
|
+
algod_client,
|
|
281
|
+
allow_more_logs,
|
|
282
|
+
allow_empty_signatures,
|
|
283
|
+
allow_unnamed_resources,
|
|
284
|
+
extra_opcode_budget,
|
|
285
|
+
exec_trace_config,
|
|
286
|
+
simulation_round,
|
|
287
|
+
)
|
|
244
288
|
txn_results = response.simulate_response["txn-groups"]
|
|
245
289
|
|
|
246
290
|
txn_types = [
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"""AlgoKit Python Utilities (Legacy V2) - a set of utilities for building solutions on Algorand
|
|
2
|
+
|
|
3
|
+
This module provides commonly used utilities and types at the root level for convenience.
|
|
4
|
+
For more specific functionality, import directly from the relevant submodules:
|
|
5
|
+
|
|
6
|
+
from algokit_utils.accounts import KmdAccountManager
|
|
7
|
+
from algokit_utils.applications import AppClient
|
|
8
|
+
from algokit_utils.applications.app_spec import Arc52Contract
|
|
9
|
+
etc.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
# Debugging utilities
|
|
13
|
+
from algokit_utils._legacy_v2._ensure_funded import (
|
|
14
|
+
EnsureBalanceParameters,
|
|
15
|
+
EnsureFundedResponse,
|
|
16
|
+
ensure_funded,
|
|
17
|
+
)
|
|
18
|
+
from algokit_utils._legacy_v2._transfer import (
|
|
19
|
+
TransferAssetParameters,
|
|
20
|
+
TransferParameters,
|
|
21
|
+
transfer,
|
|
22
|
+
transfer_asset,
|
|
23
|
+
)
|
|
24
|
+
from algokit_utils._legacy_v2.account import (
|
|
25
|
+
create_kmd_wallet_account,
|
|
26
|
+
get_account,
|
|
27
|
+
get_account_from_mnemonic,
|
|
28
|
+
get_dispenser_account,
|
|
29
|
+
get_kmd_wallet_account,
|
|
30
|
+
get_localnet_default_account,
|
|
31
|
+
get_or_create_kmd_wallet_account,
|
|
32
|
+
)
|
|
33
|
+
from algokit_utils._legacy_v2.application_client import (
|
|
34
|
+
ApplicationClient,
|
|
35
|
+
execute_atc_with_logic_error,
|
|
36
|
+
get_next_version,
|
|
37
|
+
get_sender_from_signer,
|
|
38
|
+
num_extra_program_pages,
|
|
39
|
+
)
|
|
40
|
+
from algokit_utils._legacy_v2.application_specification import (
|
|
41
|
+
ApplicationSpecification,
|
|
42
|
+
AppSpecStateDict,
|
|
43
|
+
CallConfig,
|
|
44
|
+
DefaultArgumentDict,
|
|
45
|
+
DefaultArgumentType,
|
|
46
|
+
MethodConfigDict,
|
|
47
|
+
MethodHints,
|
|
48
|
+
OnCompleteActionName,
|
|
49
|
+
)
|
|
50
|
+
from algokit_utils._legacy_v2.asset import opt_in, opt_out
|
|
51
|
+
from algokit_utils._legacy_v2.common import Program
|
|
52
|
+
from algokit_utils._legacy_v2.deploy import (
|
|
53
|
+
NOTE_PREFIX,
|
|
54
|
+
ABICallArgs,
|
|
55
|
+
ABICallArgsDict,
|
|
56
|
+
ABICreateCallArgs,
|
|
57
|
+
ABICreateCallArgsDict,
|
|
58
|
+
AppDeployMetaData,
|
|
59
|
+
AppLookup,
|
|
60
|
+
AppMetaData,
|
|
61
|
+
AppReference,
|
|
62
|
+
DeployCallArgs,
|
|
63
|
+
DeployCallArgsDict,
|
|
64
|
+
DeployCreateCallArgs,
|
|
65
|
+
DeployCreateCallArgsDict,
|
|
66
|
+
DeploymentFailedError,
|
|
67
|
+
DeployResponse,
|
|
68
|
+
TemplateValueDict,
|
|
69
|
+
TemplateValueMapping,
|
|
70
|
+
get_app_id_from_tx_id,
|
|
71
|
+
get_creator_apps,
|
|
72
|
+
replace_template_variables,
|
|
73
|
+
)
|
|
74
|
+
from algokit_utils._legacy_v2.models import (
|
|
75
|
+
ABIArgsDict,
|
|
76
|
+
ABIMethod,
|
|
77
|
+
ABITransactionResponse,
|
|
78
|
+
Account,
|
|
79
|
+
CommonCallParameters,
|
|
80
|
+
CommonCallParametersDict,
|
|
81
|
+
CreateCallParameters,
|
|
82
|
+
CreateCallParametersDict,
|
|
83
|
+
CreateTransactionParameters,
|
|
84
|
+
OnCompleteCallParameters,
|
|
85
|
+
OnCompleteCallParametersDict,
|
|
86
|
+
TransactionParameters,
|
|
87
|
+
TransactionParametersDict,
|
|
88
|
+
TransactionResponse,
|
|
89
|
+
)
|
|
90
|
+
from algokit_utils._legacy_v2.network_clients import (
|
|
91
|
+
AlgoClientConfig,
|
|
92
|
+
get_algod_client,
|
|
93
|
+
get_algonode_config,
|
|
94
|
+
get_default_localnet_config,
|
|
95
|
+
get_indexer_client,
|
|
96
|
+
get_kmd_client_from_algod_client,
|
|
97
|
+
is_localnet,
|
|
98
|
+
is_mainnet,
|
|
99
|
+
is_testnet,
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
__all__ = [
|
|
103
|
+
"NOTE_PREFIX",
|
|
104
|
+
"ABIArgsDict",
|
|
105
|
+
"ABICallArgs",
|
|
106
|
+
"ABICallArgsDict",
|
|
107
|
+
"ABICreateCallArgs",
|
|
108
|
+
"ABICreateCallArgsDict",
|
|
109
|
+
"ABIMethod",
|
|
110
|
+
"ABITransactionResponse",
|
|
111
|
+
"Account",
|
|
112
|
+
"AlgoClientConfig",
|
|
113
|
+
"AppDeployMetaData",
|
|
114
|
+
"AppLookup",
|
|
115
|
+
"AppMetaData",
|
|
116
|
+
"AppReference",
|
|
117
|
+
"AppSpecStateDict",
|
|
118
|
+
"ApplicationClient",
|
|
119
|
+
"ApplicationSpecification",
|
|
120
|
+
"CallConfig",
|
|
121
|
+
"CommonCallParameters",
|
|
122
|
+
"CommonCallParametersDict",
|
|
123
|
+
"CreateCallParameters",
|
|
124
|
+
"CreateCallParametersDict",
|
|
125
|
+
"CreateTransactionParameters",
|
|
126
|
+
"DefaultArgumentDict",
|
|
127
|
+
"DefaultArgumentType",
|
|
128
|
+
"DeployCallArgs",
|
|
129
|
+
"DeployCallArgsDict",
|
|
130
|
+
"DeployCreateCallArgs",
|
|
131
|
+
"DeployCreateCallArgsDict",
|
|
132
|
+
"DeployResponse",
|
|
133
|
+
"DeploymentFailedError",
|
|
134
|
+
"EnsureBalanceParameters",
|
|
135
|
+
"EnsureFundedResponse",
|
|
136
|
+
"MethodConfigDict",
|
|
137
|
+
"MethodHints",
|
|
138
|
+
"OnCompleteActionName",
|
|
139
|
+
"OnCompleteCallParameters",
|
|
140
|
+
"OnCompleteCallParametersDict",
|
|
141
|
+
"Program",
|
|
142
|
+
"TemplateValueDict",
|
|
143
|
+
"TemplateValueMapping",
|
|
144
|
+
"TransactionParameters",
|
|
145
|
+
"TransactionParametersDict",
|
|
146
|
+
"TransactionResponse",
|
|
147
|
+
"TransferAssetParameters",
|
|
148
|
+
"TransferParameters",
|
|
149
|
+
# Legacy v2 functions
|
|
150
|
+
"create_kmd_wallet_account",
|
|
151
|
+
"ensure_funded",
|
|
152
|
+
"execute_atc_with_logic_error",
|
|
153
|
+
"get_account",
|
|
154
|
+
"get_account_from_mnemonic",
|
|
155
|
+
"get_algod_client",
|
|
156
|
+
"get_algonode_config",
|
|
157
|
+
"get_app_id_from_tx_id",
|
|
158
|
+
"get_creator_apps",
|
|
159
|
+
"get_default_localnet_config",
|
|
160
|
+
"get_dispenser_account",
|
|
161
|
+
"get_indexer_client",
|
|
162
|
+
"get_kmd_client_from_algod_client",
|
|
163
|
+
"get_kmd_wallet_account",
|
|
164
|
+
"get_localnet_default_account",
|
|
165
|
+
"get_next_version",
|
|
166
|
+
"get_or_create_kmd_wallet_account",
|
|
167
|
+
"get_sender_from_signer",
|
|
168
|
+
"is_localnet",
|
|
169
|
+
"is_mainnet",
|
|
170
|
+
"is_testnet",
|
|
171
|
+
"num_extra_program_pages",
|
|
172
|
+
"opt_in",
|
|
173
|
+
"opt_out",
|
|
174
|
+
"replace_template_variables",
|
|
175
|
+
"transfer",
|
|
176
|
+
"transfer_asset",
|
|
177
|
+
]
|
|
@@ -4,17 +4,16 @@ from algosdk.account import address_from_private_key
|
|
|
4
4
|
from algosdk.atomic_transaction_composer import AccountTransactionSigner
|
|
5
5
|
from algosdk.transaction import SuggestedParams
|
|
6
6
|
from algosdk.v2client.algod import AlgodClient
|
|
7
|
+
from typing_extensions import deprecated
|
|
7
8
|
|
|
8
|
-
from algokit_utils._transfer import TransferParameters, transfer
|
|
9
|
-
from algokit_utils.account import get_dispenser_account
|
|
10
|
-
from algokit_utils.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
)
|
|
14
|
-
from algokit_utils.models import Account
|
|
15
|
-
from algokit_utils.network_clients import is_testnet
|
|
9
|
+
from algokit_utils._legacy_v2._transfer import TransferParameters, transfer
|
|
10
|
+
from algokit_utils._legacy_v2.account import get_dispenser_account
|
|
11
|
+
from algokit_utils._legacy_v2.models import Account
|
|
12
|
+
from algokit_utils._legacy_v2.network_clients import is_testnet
|
|
13
|
+
from algokit_utils.clients.dispenser_api_client import TestNetDispenserApiClient
|
|
16
14
|
|
|
17
15
|
|
|
16
|
+
@deprecated("Use `algorand.account.ensure_funded()` instead")
|
|
18
17
|
@dataclass(kw_only=True)
|
|
19
18
|
class EnsureBalanceParameters:
|
|
20
19
|
"""Parameters for ensuring an account has a minimum number of µALGOs"""
|
|
@@ -63,7 +62,7 @@ def _get_address_to_fund(parameters: EnsureBalanceParameters) -> str:
|
|
|
63
62
|
if isinstance(parameters.account_to_fund, str):
|
|
64
63
|
return parameters.account_to_fund
|
|
65
64
|
else:
|
|
66
|
-
return str(address_from_private_key(parameters.account_to_fund.private_key))
|
|
65
|
+
return str(address_from_private_key(parameters.account_to_fund.private_key))
|
|
67
66
|
|
|
68
67
|
|
|
69
68
|
def _get_account_info(client: AlgodClient, address_to_fund: str) -> dict:
|
|
@@ -85,9 +84,7 @@ def _calculate_fund_amount(
|
|
|
85
84
|
def _fund_using_dispenser_api(
|
|
86
85
|
dispenser_client: TestNetDispenserApiClient, address_to_fund: str, fund_amount_micro_algos: int
|
|
87
86
|
) -> EnsureFundedResponse | None:
|
|
88
|
-
response = dispenser_client.fund(
|
|
89
|
-
address=address_to_fund, amount=fund_amount_micro_algos, asset_id=DispenserAssetName.ALGO
|
|
90
|
-
)
|
|
87
|
+
response = dispenser_client.fund(address=address_to_fund, amount=fund_amount_micro_algos)
|
|
91
88
|
|
|
92
89
|
return EnsureFundedResponse(transaction_id=response.tx_id, amount=response.amount)
|
|
93
90
|
|
|
@@ -111,28 +108,28 @@ def _fund_using_transfer(
|
|
|
111
108
|
fee_micro_algos=parameters.fee_micro_algos,
|
|
112
109
|
),
|
|
113
110
|
)
|
|
114
|
-
transaction_id = response.get_txid()
|
|
111
|
+
transaction_id = response.get_txid()
|
|
115
112
|
return EnsureFundedResponse(transaction_id=transaction_id, amount=response.amt)
|
|
116
113
|
|
|
117
114
|
|
|
115
|
+
@deprecated(
|
|
116
|
+
"Use `algorand.account.ensure_funded()`, `algorand.account.ensure_funded_from_environment()`, "
|
|
117
|
+
"or `algorand.account.ensure_funded_from_testnet_dispenser_api()` instead"
|
|
118
|
+
)
|
|
118
119
|
def ensure_funded(
|
|
119
120
|
client: AlgodClient,
|
|
120
121
|
parameters: EnsureBalanceParameters,
|
|
121
122
|
) -> EnsureFundedResponse | None:
|
|
122
123
|
"""
|
|
123
|
-
Funds a given account using a funding source
|
|
124
|
-
(accounting for ALGOs locked in minimum balance requirement)
|
|
125
|
-
see <https://developer.algorand.org/docs/get-details/accounts/#minimum-balance>
|
|
126
|
-
|
|
124
|
+
Funds a given account using a funding source to ensure it has sufficient spendable ALGOs.
|
|
127
125
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
specifies the account to fund and the minimum spending balance.
|
|
126
|
+
Ensures the target account has enough ALGOs free to spend after accounting for ALGOs locked in minimum balance
|
|
127
|
+
requirements. See https://developer.algorand.org/docs/get-details/accounts/#minimum-balance for details on minimum
|
|
128
|
+
balance requirements.
|
|
132
129
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
130
|
+
:param client: An instance of the AlgodClient class from the AlgoSDK library
|
|
131
|
+
:param parameters: Parameters specifying the account to fund and minimum spending balance requirements
|
|
132
|
+
:return: If funds are needed, returns payment transaction details or dispenser API response. Returns None if no funding needed
|
|
136
133
|
"""
|
|
137
134
|
|
|
138
135
|
address_to_fund = _get_address_to_fund(parameters)
|