arc56-generated-ansar-e2fd235e 1.2.2026072010__tar.gz
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.
- arc56_generated_ansar_e2fd235e-1.2.2026072010/.gitignore +16 -0
- arc56_generated_ansar_e2fd235e-1.2.2026072010/PKG-INFO +73 -0
- arc56_generated_ansar_e2fd235e-1.2.2026072010/README.md +60 -0
- arc56_generated_ansar_e2fd235e-1.2.2026072010/pyproject.toml +23 -0
- arc56_generated_ansar_e2fd235e-1.2.2026072010/src/arc56_generated_ansar_e2fd235e/HackathonContract_6b34a24a.py +427 -0
- arc56_generated_ansar_e2fd235e-1.2.2026072010/src/arc56_generated_ansar_e2fd235e/__init__.py +1 -0
- arc56_generated_ansar_e2fd235e-1.2.2026072010/src/arc56_generated_ansaria11_hackathon/HackathonContract_6b34a24a.py +427 -0
- arc56_generated_ansar_e2fd235e-1.2.2026072010/src/arc56_generated_ansaria11_hackathon/__init__.py +1 -0
- arc56_generated_ansar_e2fd235e-1.2.2026072010/state.json +17 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: arc56-generated-ansar_e2fd235e
|
|
3
|
+
Version: 1.2.2026072010
|
|
4
|
+
Summary: Generated ARC-56 Algorand smart-contract clients for ansaria11/Hackathon.
|
|
5
|
+
Project-URL: Homepage, https://github.com/scholtz/Arc56Registry
|
|
6
|
+
Project-URL: Repository, https://github.com/scholtz/Arc56Registry
|
|
7
|
+
Author: ansaria11
|
|
8
|
+
Keywords: Hackathon,algorand,ansaria11,arc56,avm,generated-client,smart-contract
|
|
9
|
+
Requires-Python: >=3.10
|
|
10
|
+
Requires-Dist: algokit-utils<5.0.0,>=4.2.3
|
|
11
|
+
Requires-Dist: py-algorand-sdk<3.0.0,>=2.11.1
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
# arc56-generated-ansar_e2fd235e
|
|
15
|
+
|
|
16
|
+
Auto-generated typed Algorand smart-contract clients for **[ansaria11/Hackathon](https://github.com/ansaria11/Hackathon)**,
|
|
17
|
+
built from the [ARC-56](https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0056.md)
|
|
18
|
+
specs listed below.
|
|
19
|
+
|
|
20
|
+
Generated by the [Arc56Registry](https://github.com/scholtz/Arc56Registry) pipeline,
|
|
21
|
+
using the [algorandfoundation/algokit-client-generator-py](https://github.com/algorandfoundation/algokit-client-generator-py)
|
|
22
|
+
ARC-56 client generator. Do not edit these files by hand — they are regenerated
|
|
23
|
+
automatically whenever the source ARC-56 spec changes.
|
|
24
|
+
|
|
25
|
+
## Install
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install arc56-generated-ansar_e2fd235e
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Basic usage
|
|
32
|
+
|
|
33
|
+
Each contract in this package is a separate module (a hash of its source URL is
|
|
34
|
+
appended to its filename to keep multiple contracts in the same repository from
|
|
35
|
+
colliding), containing a typed `<Name>Client` for interacting with an already-deployed
|
|
36
|
+
instance of that contract, plus a `<Name>Factory` for deploying new instances.
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from algokit_utils import AlgorandClient
|
|
40
|
+
from arc56_generated_ansar_e2fd235e import HackathonContract_6b34a24a
|
|
41
|
+
|
|
42
|
+
algorand = AlgorandClient.mainnet()
|
|
43
|
+
client = HackathonContract_6b34a24a.HackathonContractClient(
|
|
44
|
+
algorand=algorand,
|
|
45
|
+
app_id=123456789,
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
# call a contract method, e.g.:
|
|
49
|
+
# result = client.send.some_method(args=(...))
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### `full` vs `minimal` generator mode
|
|
53
|
+
|
|
54
|
+
Contracts in this package are generated with the client generator's `full` mode by
|
|
55
|
+
default, which emits both the typed `Client` and a deploy/create `Factory` class plus
|
|
56
|
+
deployment metadata (source code, bytecode, template variables). For the rare contract
|
|
57
|
+
whose `full`-mode output fails to generate or fails to byte-compile, this package falls
|
|
58
|
+
back to `minimal` mode (`Client` only, no `Factory`) for that contract instead of
|
|
59
|
+
failing outright. The contracts table below flags any contract generated this way;
|
|
60
|
+
every other contract includes a working `Factory`.
|
|
61
|
+
|
|
62
|
+
## Contracts included in this package
|
|
63
|
+
|
|
64
|
+
| Module | Client class | Source ARC-56 spec |
|
|
65
|
+
| --- | --- | --- |
|
|
66
|
+
| `HackathonContract_6b34a24a` | `HackathonContractClient` | [https://raw.githubusercontent.com/ansaria11/Hackathon/HEAD/projects/Hackathon-contracts/smart_contracts/artifacts/hackathon_contract/HackathonContract.arc56.json](https://raw.githubusercontent.com/ansaria11/Hackathon/HEAD/projects/Hackathon-contracts/smart_contracts/artifacts/hackathon_contract/HackathonContract.arc56.json) |
|
|
67
|
+
|
|
68
|
+
## Versioning
|
|
69
|
+
|
|
70
|
+
This package uses `1.<increment>.<yyyyMMddHH>`-style versioning: a new version is
|
|
71
|
+
published whenever any of the contracts above change, or whenever the client generator
|
|
72
|
+
itself is updated. See [Arc56Registry](https://github.com/scholtz/Arc56Registry) for
|
|
73
|
+
the full generation pipeline and source ARC-56 registry.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# arc56-generated-ansar_e2fd235e
|
|
2
|
+
|
|
3
|
+
Auto-generated typed Algorand smart-contract clients for **[ansaria11/Hackathon](https://github.com/ansaria11/Hackathon)**,
|
|
4
|
+
built from the [ARC-56](https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0056.md)
|
|
5
|
+
specs listed below.
|
|
6
|
+
|
|
7
|
+
Generated by the [Arc56Registry](https://github.com/scholtz/Arc56Registry) pipeline,
|
|
8
|
+
using the [algorandfoundation/algokit-client-generator-py](https://github.com/algorandfoundation/algokit-client-generator-py)
|
|
9
|
+
ARC-56 client generator. Do not edit these files by hand — they are regenerated
|
|
10
|
+
automatically whenever the source ARC-56 spec changes.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pip install arc56-generated-ansar_e2fd235e
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Basic usage
|
|
19
|
+
|
|
20
|
+
Each contract in this package is a separate module (a hash of its source URL is
|
|
21
|
+
appended to its filename to keep multiple contracts in the same repository from
|
|
22
|
+
colliding), containing a typed `<Name>Client` for interacting with an already-deployed
|
|
23
|
+
instance of that contract, plus a `<Name>Factory` for deploying new instances.
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
from algokit_utils import AlgorandClient
|
|
27
|
+
from arc56_generated_ansar_e2fd235e import HackathonContract_6b34a24a
|
|
28
|
+
|
|
29
|
+
algorand = AlgorandClient.mainnet()
|
|
30
|
+
client = HackathonContract_6b34a24a.HackathonContractClient(
|
|
31
|
+
algorand=algorand,
|
|
32
|
+
app_id=123456789,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
# call a contract method, e.g.:
|
|
36
|
+
# result = client.send.some_method(args=(...))
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### `full` vs `minimal` generator mode
|
|
40
|
+
|
|
41
|
+
Contracts in this package are generated with the client generator's `full` mode by
|
|
42
|
+
default, which emits both the typed `Client` and a deploy/create `Factory` class plus
|
|
43
|
+
deployment metadata (source code, bytecode, template variables). For the rare contract
|
|
44
|
+
whose `full`-mode output fails to generate or fails to byte-compile, this package falls
|
|
45
|
+
back to `minimal` mode (`Client` only, no `Factory`) for that contract instead of
|
|
46
|
+
failing outright. The contracts table below flags any contract generated this way;
|
|
47
|
+
every other contract includes a working `Factory`.
|
|
48
|
+
|
|
49
|
+
## Contracts included in this package
|
|
50
|
+
|
|
51
|
+
| Module | Client class | Source ARC-56 spec |
|
|
52
|
+
| --- | --- | --- |
|
|
53
|
+
| `HackathonContract_6b34a24a` | `HackathonContractClient` | [https://raw.githubusercontent.com/ansaria11/Hackathon/HEAD/projects/Hackathon-contracts/smart_contracts/artifacts/hackathon_contract/HackathonContract.arc56.json](https://raw.githubusercontent.com/ansaria11/Hackathon/HEAD/projects/Hackathon-contracts/smart_contracts/artifacts/hackathon_contract/HackathonContract.arc56.json) |
|
|
54
|
+
|
|
55
|
+
## Versioning
|
|
56
|
+
|
|
57
|
+
This package uses `1.<increment>.<yyyyMMddHH>`-style versioning: a new version is
|
|
58
|
+
published whenever any of the contracts above change, or whenever the client generator
|
|
59
|
+
itself is updated. See [Arc56Registry](https://github.com/scholtz/Arc56Registry) for
|
|
60
|
+
the full generation pipeline and source ARC-56 registry.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "arc56-generated-ansar_e2fd235e"
|
|
7
|
+
version = "1.2.2026072010"
|
|
8
|
+
description = "Generated ARC-56 Algorand smart-contract clients for ansaria11/Hackathon."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
authors = [{ name = "ansaria11" }]
|
|
12
|
+
keywords = ["algorand", "arc56", "avm", "smart-contract", "generated-client", "ansaria11", "Hackathon"]
|
|
13
|
+
dependencies = [
|
|
14
|
+
"algokit-utils>=4.2.3,<5.0.0",
|
|
15
|
+
"py-algorand-sdk>=2.11.1,<3.0.0",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
[project.urls]
|
|
19
|
+
Homepage = "https://github.com/scholtz/Arc56Registry"
|
|
20
|
+
Repository = "https://github.com/scholtz/Arc56Registry"
|
|
21
|
+
|
|
22
|
+
[tool.hatch.build.targets.wheel]
|
|
23
|
+
packages = ["src/arc56_generated_ansar_e2fd235e"]
|
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
# flake8: noqa
|
|
2
|
+
# fmt: off
|
|
3
|
+
# mypy: ignore-errors
|
|
4
|
+
# This file was automatically generated by algokit-client-generator.
|
|
5
|
+
# DO NOT MODIFY IT BY HAND.
|
|
6
|
+
# requires: algokit-utils@^3.0.0
|
|
7
|
+
|
|
8
|
+
# common
|
|
9
|
+
import dataclasses
|
|
10
|
+
import typing
|
|
11
|
+
# core algosdk
|
|
12
|
+
import algosdk
|
|
13
|
+
from algosdk.transaction import OnComplete
|
|
14
|
+
from algosdk.atomic_transaction_composer import TransactionSigner
|
|
15
|
+
from algosdk.source_map import SourceMap
|
|
16
|
+
from algosdk.transaction import Transaction
|
|
17
|
+
from algosdk.v2client.models import SimulateTraceConfig
|
|
18
|
+
# utils
|
|
19
|
+
import algokit_utils
|
|
20
|
+
from algokit_utils import AlgorandClient as _AlgoKitAlgorandClient
|
|
21
|
+
|
|
22
|
+
_APP_SPEC_JSON = r"""{"arcs": [22, 28], "bareActions": {"call": [], "create": ["NoOp"]}, "methods": [{"actions": {"call": ["NoOp"], "create": []}, "args": [{"type": "string", "name": "name"}], "name": "hello", "returns": {"type": "string"}, "events": [], "readonly": false, "recommendations": {}}], "name": "HackathonContract", "state": {"keys": {"box": {}, "global": {}, "local": {}}, "maps": {"box": {}, "global": {}, "local": {}}, "schema": {"global": {"bytes": 0, "ints": 0}, "local": {"bytes": 0, "ints": 0}}}, "structs": {}, "events": [], "networks": {}, "sourceInfo": {"approval": {"pcOffsetMethod": "none", "sourceInfo": [{"pc": [25], "errorMessage": "OnCompletion is not NoOp"}, {"pc": [66], "errorMessage": "can only call when creating"}, {"pc": [28], "errorMessage": "can only call when not creating"}]}, "clear": {"pcOffsetMethod": "none", "sourceInfo": []}}}"""
|
|
23
|
+
APP_SPEC = algokit_utils.Arc56Contract.from_json(_APP_SPEC_JSON)
|
|
24
|
+
|
|
25
|
+
def _parse_abi_args(args: object | None = None) -> list[object] | None:
|
|
26
|
+
"""Helper to parse ABI args into the format expected by underlying client"""
|
|
27
|
+
if args is None:
|
|
28
|
+
return None
|
|
29
|
+
|
|
30
|
+
def convert_dataclass(value: object) -> object:
|
|
31
|
+
if dataclasses.is_dataclass(value):
|
|
32
|
+
return tuple(convert_dataclass(getattr(value, field.name)) for field in dataclasses.fields(value))
|
|
33
|
+
elif isinstance(value, (list, tuple)):
|
|
34
|
+
return type(value)(convert_dataclass(item) for item in value)
|
|
35
|
+
return value
|
|
36
|
+
|
|
37
|
+
match args:
|
|
38
|
+
case tuple():
|
|
39
|
+
method_args = list(args)
|
|
40
|
+
case _ if dataclasses.is_dataclass(args):
|
|
41
|
+
method_args = [getattr(args, field.name) for field in dataclasses.fields(args)]
|
|
42
|
+
case _:
|
|
43
|
+
raise ValueError("Invalid 'args' type. Expected 'tuple' or 'TypedDict' for respective typed arguments.")
|
|
44
|
+
|
|
45
|
+
return [
|
|
46
|
+
convert_dataclass(arg) if not isinstance(arg, algokit_utils.AppMethodCallTransactionArgument) else arg
|
|
47
|
+
for arg in method_args
|
|
48
|
+
] if method_args else None
|
|
49
|
+
|
|
50
|
+
def _init_dataclass(cls: type, data: dict) -> object:
|
|
51
|
+
"""
|
|
52
|
+
Recursively instantiate a dataclass of type `cls` from `data`.
|
|
53
|
+
|
|
54
|
+
For each field on the dataclass, if the field type is also a dataclass
|
|
55
|
+
and the corresponding data is a dict, instantiate that field recursively.
|
|
56
|
+
"""
|
|
57
|
+
field_values = {}
|
|
58
|
+
for field in dataclasses.fields(cls):
|
|
59
|
+
field_value = data.get(field.name)
|
|
60
|
+
# Check if the field expects another dataclass and the value is a dict.
|
|
61
|
+
if dataclasses.is_dataclass(field.type) and isinstance(field_value, dict):
|
|
62
|
+
field_values[field.name] = _init_dataclass(typing.cast(type, field.type), field_value)
|
|
63
|
+
else:
|
|
64
|
+
field_values[field.name] = field_value
|
|
65
|
+
return cls(**field_values)
|
|
66
|
+
|
|
67
|
+
@dataclasses.dataclass(frozen=True, kw_only=True)
|
|
68
|
+
class HelloArgs:
|
|
69
|
+
"""Dataclass for hello arguments"""
|
|
70
|
+
name: str
|
|
71
|
+
|
|
72
|
+
@property
|
|
73
|
+
def abi_method_signature(self) -> str:
|
|
74
|
+
return "hello(string)string"
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class HackathonContractParams:
|
|
78
|
+
def __init__(self, app_client: algokit_utils.AppClient):
|
|
79
|
+
self.app_client = app_client
|
|
80
|
+
|
|
81
|
+
def hello(
|
|
82
|
+
self,
|
|
83
|
+
args: tuple[str] | HelloArgs,
|
|
84
|
+
params: algokit_utils.CommonAppCallParams | None = None
|
|
85
|
+
) -> algokit_utils.AppCallMethodCallParams:
|
|
86
|
+
method_args = _parse_abi_args(args)
|
|
87
|
+
params = params or algokit_utils.CommonAppCallParams()
|
|
88
|
+
return self.app_client.params.call(algokit_utils.AppClientMethodCallParams(**{
|
|
89
|
+
**dataclasses.asdict(params),
|
|
90
|
+
"method": "hello(string)string",
|
|
91
|
+
"args": method_args,
|
|
92
|
+
}))
|
|
93
|
+
|
|
94
|
+
def clear_state(
|
|
95
|
+
self,
|
|
96
|
+
params: algokit_utils.AppClientBareCallParams | None = None,
|
|
97
|
+
|
|
98
|
+
) -> algokit_utils.AppCallParams:
|
|
99
|
+
return self.app_client.params.bare.clear_state(
|
|
100
|
+
params,
|
|
101
|
+
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
class HackathonContractCreateTransactionParams:
|
|
106
|
+
def __init__(self, app_client: algokit_utils.AppClient):
|
|
107
|
+
self.app_client = app_client
|
|
108
|
+
|
|
109
|
+
def hello(
|
|
110
|
+
self,
|
|
111
|
+
args: tuple[str] | HelloArgs,
|
|
112
|
+
params: algokit_utils.CommonAppCallParams | None = None
|
|
113
|
+
) -> algokit_utils.BuiltTransactions:
|
|
114
|
+
method_args = _parse_abi_args(args)
|
|
115
|
+
params = params or algokit_utils.CommonAppCallParams()
|
|
116
|
+
return self.app_client.create_transaction.call(algokit_utils.AppClientMethodCallParams(**{
|
|
117
|
+
**dataclasses.asdict(params),
|
|
118
|
+
"method": "hello(string)string",
|
|
119
|
+
"args": method_args,
|
|
120
|
+
}))
|
|
121
|
+
|
|
122
|
+
def clear_state(
|
|
123
|
+
self,
|
|
124
|
+
params: algokit_utils.AppClientBareCallParams | None = None,
|
|
125
|
+
|
|
126
|
+
) -> Transaction:
|
|
127
|
+
return self.app_client.create_transaction.bare.clear_state(
|
|
128
|
+
params,
|
|
129
|
+
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
class HackathonContractSend:
|
|
134
|
+
def __init__(self, app_client: algokit_utils.AppClient):
|
|
135
|
+
self.app_client = app_client
|
|
136
|
+
|
|
137
|
+
def hello(
|
|
138
|
+
self,
|
|
139
|
+
args: tuple[str] | HelloArgs,
|
|
140
|
+
params: algokit_utils.CommonAppCallParams | None = None,
|
|
141
|
+
send_params: algokit_utils.SendParams | None = None
|
|
142
|
+
) -> algokit_utils.SendAppTransactionResult[str]:
|
|
143
|
+
method_args = _parse_abi_args(args)
|
|
144
|
+
params = params or algokit_utils.CommonAppCallParams()
|
|
145
|
+
response = self.app_client.send.call(algokit_utils.AppClientMethodCallParams(**{
|
|
146
|
+
**dataclasses.asdict(params),
|
|
147
|
+
"method": "hello(string)string",
|
|
148
|
+
"args": method_args,
|
|
149
|
+
}), send_params=send_params)
|
|
150
|
+
parsed_response = response
|
|
151
|
+
return typing.cast(algokit_utils.SendAppTransactionResult[str], parsed_response)
|
|
152
|
+
|
|
153
|
+
def clear_state(
|
|
154
|
+
self,
|
|
155
|
+
params: algokit_utils.AppClientBareCallParams | None = None,
|
|
156
|
+
send_params: algokit_utils.SendParams | None = None
|
|
157
|
+
) -> algokit_utils.SendAppTransactionResult[algokit_utils.ABIReturn]:
|
|
158
|
+
return self.app_client.send.bare.clear_state(
|
|
159
|
+
params,
|
|
160
|
+
send_params=send_params,
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
class HackathonContractState:
|
|
165
|
+
"""Methods to access state for the current HackathonContract app"""
|
|
166
|
+
|
|
167
|
+
def __init__(self, app_client: algokit_utils.AppClient):
|
|
168
|
+
self.app_client = app_client
|
|
169
|
+
|
|
170
|
+
class HackathonContractClient:
|
|
171
|
+
"""Client for interacting with HackathonContract smart contract"""
|
|
172
|
+
|
|
173
|
+
@typing.overload
|
|
174
|
+
def __init__(self, app_client: algokit_utils.AppClient) -> None: ...
|
|
175
|
+
|
|
176
|
+
@typing.overload
|
|
177
|
+
def __init__(
|
|
178
|
+
self,
|
|
179
|
+
*,
|
|
180
|
+
algorand: _AlgoKitAlgorandClient,
|
|
181
|
+
app_id: int,
|
|
182
|
+
app_name: str | None = None,
|
|
183
|
+
default_sender: str | None = None,
|
|
184
|
+
default_signer: TransactionSigner | None = None,
|
|
185
|
+
approval_source_map: SourceMap | None = None,
|
|
186
|
+
clear_source_map: SourceMap | None = None,
|
|
187
|
+
) -> None: ...
|
|
188
|
+
|
|
189
|
+
def __init__(
|
|
190
|
+
self,
|
|
191
|
+
app_client: algokit_utils.AppClient | None = None,
|
|
192
|
+
*,
|
|
193
|
+
algorand: _AlgoKitAlgorandClient | None = None,
|
|
194
|
+
app_id: int | None = None,
|
|
195
|
+
app_name: str | None = None,
|
|
196
|
+
default_sender: str | None = None,
|
|
197
|
+
default_signer: TransactionSigner | None = None,
|
|
198
|
+
approval_source_map: SourceMap | None = None,
|
|
199
|
+
clear_source_map: SourceMap | None = None,
|
|
200
|
+
) -> None:
|
|
201
|
+
if app_client:
|
|
202
|
+
self.app_client = app_client
|
|
203
|
+
elif algorand and app_id:
|
|
204
|
+
self.app_client = algokit_utils.AppClient(
|
|
205
|
+
algokit_utils.AppClientParams(
|
|
206
|
+
algorand=algorand,
|
|
207
|
+
app_spec=APP_SPEC,
|
|
208
|
+
app_id=app_id,
|
|
209
|
+
app_name=app_name,
|
|
210
|
+
default_sender=default_sender,
|
|
211
|
+
default_signer=default_signer,
|
|
212
|
+
approval_source_map=approval_source_map,
|
|
213
|
+
clear_source_map=clear_source_map,
|
|
214
|
+
)
|
|
215
|
+
)
|
|
216
|
+
else:
|
|
217
|
+
raise ValueError("Either app_client or algorand and app_id must be provided")
|
|
218
|
+
|
|
219
|
+
self.params = HackathonContractParams(self.app_client)
|
|
220
|
+
self.create_transaction = HackathonContractCreateTransactionParams(self.app_client)
|
|
221
|
+
self.send = HackathonContractSend(self.app_client)
|
|
222
|
+
self.state = HackathonContractState(self.app_client)
|
|
223
|
+
|
|
224
|
+
@staticmethod
|
|
225
|
+
def from_creator_and_name(
|
|
226
|
+
creator_address: str,
|
|
227
|
+
app_name: str,
|
|
228
|
+
algorand: _AlgoKitAlgorandClient,
|
|
229
|
+
default_sender: str | None = None,
|
|
230
|
+
default_signer: TransactionSigner | None = None,
|
|
231
|
+
approval_source_map: SourceMap | None = None,
|
|
232
|
+
clear_source_map: SourceMap | None = None,
|
|
233
|
+
ignore_cache: bool | None = None,
|
|
234
|
+
app_lookup_cache: algokit_utils.ApplicationLookup | None = None,
|
|
235
|
+
) -> "HackathonContractClient":
|
|
236
|
+
return HackathonContractClient(
|
|
237
|
+
algokit_utils.AppClient.from_creator_and_name(
|
|
238
|
+
creator_address=creator_address,
|
|
239
|
+
app_name=app_name,
|
|
240
|
+
app_spec=APP_SPEC,
|
|
241
|
+
algorand=algorand,
|
|
242
|
+
default_sender=default_sender,
|
|
243
|
+
default_signer=default_signer,
|
|
244
|
+
approval_source_map=approval_source_map,
|
|
245
|
+
clear_source_map=clear_source_map,
|
|
246
|
+
ignore_cache=ignore_cache,
|
|
247
|
+
app_lookup_cache=app_lookup_cache,
|
|
248
|
+
)
|
|
249
|
+
)
|
|
250
|
+
|
|
251
|
+
@staticmethod
|
|
252
|
+
def from_network(
|
|
253
|
+
algorand: _AlgoKitAlgorandClient,
|
|
254
|
+
app_name: str | None = None,
|
|
255
|
+
default_sender: str | None = None,
|
|
256
|
+
default_signer: TransactionSigner | None = None,
|
|
257
|
+
approval_source_map: SourceMap | None = None,
|
|
258
|
+
clear_source_map: SourceMap | None = None,
|
|
259
|
+
) -> "HackathonContractClient":
|
|
260
|
+
return HackathonContractClient(
|
|
261
|
+
algokit_utils.AppClient.from_network(
|
|
262
|
+
app_spec=APP_SPEC,
|
|
263
|
+
algorand=algorand,
|
|
264
|
+
app_name=app_name,
|
|
265
|
+
default_sender=default_sender,
|
|
266
|
+
default_signer=default_signer,
|
|
267
|
+
approval_source_map=approval_source_map,
|
|
268
|
+
clear_source_map=clear_source_map,
|
|
269
|
+
)
|
|
270
|
+
)
|
|
271
|
+
|
|
272
|
+
@property
|
|
273
|
+
def app_id(self) -> int:
|
|
274
|
+
return self.app_client.app_id
|
|
275
|
+
|
|
276
|
+
@property
|
|
277
|
+
def app_address(self) -> str:
|
|
278
|
+
return self.app_client.app_address
|
|
279
|
+
|
|
280
|
+
@property
|
|
281
|
+
def app_name(self) -> str:
|
|
282
|
+
return self.app_client.app_name
|
|
283
|
+
|
|
284
|
+
@property
|
|
285
|
+
def app_spec(self) -> algokit_utils.Arc56Contract:
|
|
286
|
+
return self.app_client.app_spec
|
|
287
|
+
|
|
288
|
+
@property
|
|
289
|
+
def algorand(self) -> _AlgoKitAlgorandClient:
|
|
290
|
+
return self.app_client.algorand
|
|
291
|
+
|
|
292
|
+
def clone(
|
|
293
|
+
self,
|
|
294
|
+
app_name: str | None = None,
|
|
295
|
+
default_sender: str | None = None,
|
|
296
|
+
default_signer: TransactionSigner | None = None,
|
|
297
|
+
approval_source_map: SourceMap | None = None,
|
|
298
|
+
clear_source_map: SourceMap | None = None,
|
|
299
|
+
) -> "HackathonContractClient":
|
|
300
|
+
return HackathonContractClient(
|
|
301
|
+
self.app_client.clone(
|
|
302
|
+
app_name=app_name,
|
|
303
|
+
default_sender=default_sender,
|
|
304
|
+
default_signer=default_signer,
|
|
305
|
+
approval_source_map=approval_source_map,
|
|
306
|
+
clear_source_map=clear_source_map,
|
|
307
|
+
)
|
|
308
|
+
)
|
|
309
|
+
|
|
310
|
+
def new_group(self) -> "HackathonContractComposer":
|
|
311
|
+
return HackathonContractComposer(self)
|
|
312
|
+
|
|
313
|
+
@typing.overload
|
|
314
|
+
def decode_return_value(
|
|
315
|
+
self,
|
|
316
|
+
method: typing.Literal["hello(string)string"],
|
|
317
|
+
return_value: algokit_utils.ABIReturn | None
|
|
318
|
+
) -> str | None: ...
|
|
319
|
+
@typing.overload
|
|
320
|
+
def decode_return_value(
|
|
321
|
+
self,
|
|
322
|
+
method: str,
|
|
323
|
+
return_value: algokit_utils.ABIReturn | None
|
|
324
|
+
) -> algokit_utils.ABIValue | algokit_utils.ABIStruct | None: ...
|
|
325
|
+
|
|
326
|
+
def decode_return_value(
|
|
327
|
+
self,
|
|
328
|
+
method: str,
|
|
329
|
+
return_value: algokit_utils.ABIReturn | None
|
|
330
|
+
) -> algokit_utils.ABIValue | algokit_utils.ABIStruct | None | str:
|
|
331
|
+
"""Decode ABI return value for the given method."""
|
|
332
|
+
if return_value is None:
|
|
333
|
+
return None
|
|
334
|
+
|
|
335
|
+
arc56_method = self.app_spec.get_arc56_method(method)
|
|
336
|
+
decoded = return_value.get_arc56_value(arc56_method, self.app_spec.structs)
|
|
337
|
+
|
|
338
|
+
# If method returns a struct, convert the dict to appropriate dataclass
|
|
339
|
+
if (arc56_method and
|
|
340
|
+
arc56_method.returns and
|
|
341
|
+
arc56_method.returns.struct and
|
|
342
|
+
isinstance(decoded, dict)):
|
|
343
|
+
struct_class = globals().get(arc56_method.returns.struct)
|
|
344
|
+
if struct_class:
|
|
345
|
+
return struct_class(**typing.cast(dict, decoded))
|
|
346
|
+
return decoded
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
class HackathonContractComposer:
|
|
350
|
+
"""Composer for creating transaction groups for HackathonContract contract calls"""
|
|
351
|
+
|
|
352
|
+
def __init__(self, client: "HackathonContractClient"):
|
|
353
|
+
self.client = client
|
|
354
|
+
self._composer = client.algorand.new_group()
|
|
355
|
+
self._result_mappers: list[typing.Callable[[algokit_utils.ABIReturn | None], object] | None] = []
|
|
356
|
+
|
|
357
|
+
def hello(
|
|
358
|
+
self,
|
|
359
|
+
args: tuple[str] | HelloArgs,
|
|
360
|
+
params: algokit_utils.CommonAppCallParams | None = None
|
|
361
|
+
) -> "HackathonContractComposer":
|
|
362
|
+
self._composer.add_app_call_method_call(
|
|
363
|
+
self.client.params.hello(
|
|
364
|
+
args=args,
|
|
365
|
+
params=params,
|
|
366
|
+
)
|
|
367
|
+
)
|
|
368
|
+
self._result_mappers.append(
|
|
369
|
+
lambda v: self.client.decode_return_value(
|
|
370
|
+
"hello(string)string", v
|
|
371
|
+
)
|
|
372
|
+
)
|
|
373
|
+
return self
|
|
374
|
+
|
|
375
|
+
def clear_state(
|
|
376
|
+
self,
|
|
377
|
+
*,
|
|
378
|
+
args: list[bytes] | None = None,
|
|
379
|
+
params: algokit_utils.CommonAppCallParams | None = None,
|
|
380
|
+
) -> "HackathonContractComposer":
|
|
381
|
+
params=params or algokit_utils.CommonAppCallParams()
|
|
382
|
+
self._composer.add_app_call(
|
|
383
|
+
self.client.params.clear_state(
|
|
384
|
+
algokit_utils.AppClientBareCallParams(
|
|
385
|
+
**{
|
|
386
|
+
**dataclasses.asdict(params),
|
|
387
|
+
"args": args
|
|
388
|
+
}
|
|
389
|
+
)
|
|
390
|
+
)
|
|
391
|
+
)
|
|
392
|
+
return self
|
|
393
|
+
|
|
394
|
+
def add_transaction(
|
|
395
|
+
self, txn: Transaction, signer: TransactionSigner | None = None
|
|
396
|
+
) -> "HackathonContractComposer":
|
|
397
|
+
self._composer.add_transaction(txn, signer)
|
|
398
|
+
return self
|
|
399
|
+
|
|
400
|
+
def composer(self) -> algokit_utils.TransactionComposer:
|
|
401
|
+
return self._composer
|
|
402
|
+
|
|
403
|
+
def simulate(
|
|
404
|
+
self,
|
|
405
|
+
allow_more_logs: bool | None = None,
|
|
406
|
+
allow_empty_signatures: bool | None = None,
|
|
407
|
+
allow_unnamed_resources: bool | None = None,
|
|
408
|
+
extra_opcode_budget: int | None = None,
|
|
409
|
+
exec_trace_config: SimulateTraceConfig | None = None,
|
|
410
|
+
simulation_round: int | None = None,
|
|
411
|
+
skip_signatures: bool | None = None,
|
|
412
|
+
) -> algokit_utils.SendAtomicTransactionComposerResults:
|
|
413
|
+
return self._composer.simulate(
|
|
414
|
+
allow_more_logs=allow_more_logs,
|
|
415
|
+
allow_empty_signatures=allow_empty_signatures,
|
|
416
|
+
allow_unnamed_resources=allow_unnamed_resources,
|
|
417
|
+
extra_opcode_budget=extra_opcode_budget,
|
|
418
|
+
exec_trace_config=exec_trace_config,
|
|
419
|
+
simulation_round=simulation_round,
|
|
420
|
+
skip_signatures=skip_signatures,
|
|
421
|
+
)
|
|
422
|
+
|
|
423
|
+
def send(
|
|
424
|
+
self,
|
|
425
|
+
send_params: algokit_utils.SendParams | None = None
|
|
426
|
+
) -> algokit_utils.SendAtomicTransactionComposerResults:
|
|
427
|
+
return self._composer.send(send_params)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from . import HackathonContract_6b34a24a as HackathonContract_6b34a24a
|
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
# flake8: noqa
|
|
2
|
+
# fmt: off
|
|
3
|
+
# mypy: ignore-errors
|
|
4
|
+
# This file was automatically generated by algokit-client-generator.
|
|
5
|
+
# DO NOT MODIFY IT BY HAND.
|
|
6
|
+
# requires: algokit-utils@^3.0.0
|
|
7
|
+
|
|
8
|
+
# common
|
|
9
|
+
import dataclasses
|
|
10
|
+
import typing
|
|
11
|
+
# core algosdk
|
|
12
|
+
import algosdk
|
|
13
|
+
from algosdk.transaction import OnComplete
|
|
14
|
+
from algosdk.atomic_transaction_composer import TransactionSigner
|
|
15
|
+
from algosdk.source_map import SourceMap
|
|
16
|
+
from algosdk.transaction import Transaction
|
|
17
|
+
from algosdk.v2client.models import SimulateTraceConfig
|
|
18
|
+
# utils
|
|
19
|
+
import algokit_utils
|
|
20
|
+
from algokit_utils import AlgorandClient as _AlgoKitAlgorandClient
|
|
21
|
+
|
|
22
|
+
_APP_SPEC_JSON = r"""{"arcs": [22, 28], "bareActions": {"call": [], "create": ["NoOp"]}, "methods": [{"actions": {"call": ["NoOp"], "create": []}, "args": [{"type": "string", "name": "name"}], "name": "hello", "returns": {"type": "string"}, "events": [], "readonly": false, "recommendations": {}}], "name": "HackathonContract", "state": {"keys": {"box": {}, "global": {}, "local": {}}, "maps": {"box": {}, "global": {}, "local": {}}, "schema": {"global": {"bytes": 0, "ints": 0}, "local": {"bytes": 0, "ints": 0}}}, "structs": {}, "events": [], "networks": {}, "sourceInfo": {"approval": {"pcOffsetMethod": "none", "sourceInfo": [{"pc": [25], "errorMessage": "OnCompletion is not NoOp"}, {"pc": [66], "errorMessage": "can only call when creating"}, {"pc": [28], "errorMessage": "can only call when not creating"}]}, "clear": {"pcOffsetMethod": "none", "sourceInfo": []}}}"""
|
|
23
|
+
APP_SPEC = algokit_utils.Arc56Contract.from_json(_APP_SPEC_JSON)
|
|
24
|
+
|
|
25
|
+
def _parse_abi_args(args: object | None = None) -> list[object] | None:
|
|
26
|
+
"""Helper to parse ABI args into the format expected by underlying client"""
|
|
27
|
+
if args is None:
|
|
28
|
+
return None
|
|
29
|
+
|
|
30
|
+
def convert_dataclass(value: object) -> object:
|
|
31
|
+
if dataclasses.is_dataclass(value):
|
|
32
|
+
return tuple(convert_dataclass(getattr(value, field.name)) for field in dataclasses.fields(value))
|
|
33
|
+
elif isinstance(value, (list, tuple)):
|
|
34
|
+
return type(value)(convert_dataclass(item) for item in value)
|
|
35
|
+
return value
|
|
36
|
+
|
|
37
|
+
match args:
|
|
38
|
+
case tuple():
|
|
39
|
+
method_args = list(args)
|
|
40
|
+
case _ if dataclasses.is_dataclass(args):
|
|
41
|
+
method_args = [getattr(args, field.name) for field in dataclasses.fields(args)]
|
|
42
|
+
case _:
|
|
43
|
+
raise ValueError("Invalid 'args' type. Expected 'tuple' or 'TypedDict' for respective typed arguments.")
|
|
44
|
+
|
|
45
|
+
return [
|
|
46
|
+
convert_dataclass(arg) if not isinstance(arg, algokit_utils.AppMethodCallTransactionArgument) else arg
|
|
47
|
+
for arg in method_args
|
|
48
|
+
] if method_args else None
|
|
49
|
+
|
|
50
|
+
def _init_dataclass(cls: type, data: dict) -> object:
|
|
51
|
+
"""
|
|
52
|
+
Recursively instantiate a dataclass of type `cls` from `data`.
|
|
53
|
+
|
|
54
|
+
For each field on the dataclass, if the field type is also a dataclass
|
|
55
|
+
and the corresponding data is a dict, instantiate that field recursively.
|
|
56
|
+
"""
|
|
57
|
+
field_values = {}
|
|
58
|
+
for field in dataclasses.fields(cls):
|
|
59
|
+
field_value = data.get(field.name)
|
|
60
|
+
# Check if the field expects another dataclass and the value is a dict.
|
|
61
|
+
if dataclasses.is_dataclass(field.type) and isinstance(field_value, dict):
|
|
62
|
+
field_values[field.name] = _init_dataclass(typing.cast(type, field.type), field_value)
|
|
63
|
+
else:
|
|
64
|
+
field_values[field.name] = field_value
|
|
65
|
+
return cls(**field_values)
|
|
66
|
+
|
|
67
|
+
@dataclasses.dataclass(frozen=True, kw_only=True)
|
|
68
|
+
class HelloArgs:
|
|
69
|
+
"""Dataclass for hello arguments"""
|
|
70
|
+
name: str
|
|
71
|
+
|
|
72
|
+
@property
|
|
73
|
+
def abi_method_signature(self) -> str:
|
|
74
|
+
return "hello(string)string"
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class HackathonContractParams:
|
|
78
|
+
def __init__(self, app_client: algokit_utils.AppClient):
|
|
79
|
+
self.app_client = app_client
|
|
80
|
+
|
|
81
|
+
def hello(
|
|
82
|
+
self,
|
|
83
|
+
args: tuple[str] | HelloArgs,
|
|
84
|
+
params: algokit_utils.CommonAppCallParams | None = None
|
|
85
|
+
) -> algokit_utils.AppCallMethodCallParams:
|
|
86
|
+
method_args = _parse_abi_args(args)
|
|
87
|
+
params = params or algokit_utils.CommonAppCallParams()
|
|
88
|
+
return self.app_client.params.call(algokit_utils.AppClientMethodCallParams(**{
|
|
89
|
+
**dataclasses.asdict(params),
|
|
90
|
+
"method": "hello(string)string",
|
|
91
|
+
"args": method_args,
|
|
92
|
+
}))
|
|
93
|
+
|
|
94
|
+
def clear_state(
|
|
95
|
+
self,
|
|
96
|
+
params: algokit_utils.AppClientBareCallParams | None = None,
|
|
97
|
+
|
|
98
|
+
) -> algokit_utils.AppCallParams:
|
|
99
|
+
return self.app_client.params.bare.clear_state(
|
|
100
|
+
params,
|
|
101
|
+
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
class HackathonContractCreateTransactionParams:
|
|
106
|
+
def __init__(self, app_client: algokit_utils.AppClient):
|
|
107
|
+
self.app_client = app_client
|
|
108
|
+
|
|
109
|
+
def hello(
|
|
110
|
+
self,
|
|
111
|
+
args: tuple[str] | HelloArgs,
|
|
112
|
+
params: algokit_utils.CommonAppCallParams | None = None
|
|
113
|
+
) -> algokit_utils.BuiltTransactions:
|
|
114
|
+
method_args = _parse_abi_args(args)
|
|
115
|
+
params = params or algokit_utils.CommonAppCallParams()
|
|
116
|
+
return self.app_client.create_transaction.call(algokit_utils.AppClientMethodCallParams(**{
|
|
117
|
+
**dataclasses.asdict(params),
|
|
118
|
+
"method": "hello(string)string",
|
|
119
|
+
"args": method_args,
|
|
120
|
+
}))
|
|
121
|
+
|
|
122
|
+
def clear_state(
|
|
123
|
+
self,
|
|
124
|
+
params: algokit_utils.AppClientBareCallParams | None = None,
|
|
125
|
+
|
|
126
|
+
) -> Transaction:
|
|
127
|
+
return self.app_client.create_transaction.bare.clear_state(
|
|
128
|
+
params,
|
|
129
|
+
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
class HackathonContractSend:
|
|
134
|
+
def __init__(self, app_client: algokit_utils.AppClient):
|
|
135
|
+
self.app_client = app_client
|
|
136
|
+
|
|
137
|
+
def hello(
|
|
138
|
+
self,
|
|
139
|
+
args: tuple[str] | HelloArgs,
|
|
140
|
+
params: algokit_utils.CommonAppCallParams | None = None,
|
|
141
|
+
send_params: algokit_utils.SendParams | None = None
|
|
142
|
+
) -> algokit_utils.SendAppTransactionResult[str]:
|
|
143
|
+
method_args = _parse_abi_args(args)
|
|
144
|
+
params = params or algokit_utils.CommonAppCallParams()
|
|
145
|
+
response = self.app_client.send.call(algokit_utils.AppClientMethodCallParams(**{
|
|
146
|
+
**dataclasses.asdict(params),
|
|
147
|
+
"method": "hello(string)string",
|
|
148
|
+
"args": method_args,
|
|
149
|
+
}), send_params=send_params)
|
|
150
|
+
parsed_response = response
|
|
151
|
+
return typing.cast(algokit_utils.SendAppTransactionResult[str], parsed_response)
|
|
152
|
+
|
|
153
|
+
def clear_state(
|
|
154
|
+
self,
|
|
155
|
+
params: algokit_utils.AppClientBareCallParams | None = None,
|
|
156
|
+
send_params: algokit_utils.SendParams | None = None
|
|
157
|
+
) -> algokit_utils.SendAppTransactionResult[algokit_utils.ABIReturn]:
|
|
158
|
+
return self.app_client.send.bare.clear_state(
|
|
159
|
+
params,
|
|
160
|
+
send_params=send_params,
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
class HackathonContractState:
|
|
165
|
+
"""Methods to access state for the current HackathonContract app"""
|
|
166
|
+
|
|
167
|
+
def __init__(self, app_client: algokit_utils.AppClient):
|
|
168
|
+
self.app_client = app_client
|
|
169
|
+
|
|
170
|
+
class HackathonContractClient:
|
|
171
|
+
"""Client for interacting with HackathonContract smart contract"""
|
|
172
|
+
|
|
173
|
+
@typing.overload
|
|
174
|
+
def __init__(self, app_client: algokit_utils.AppClient) -> None: ...
|
|
175
|
+
|
|
176
|
+
@typing.overload
|
|
177
|
+
def __init__(
|
|
178
|
+
self,
|
|
179
|
+
*,
|
|
180
|
+
algorand: _AlgoKitAlgorandClient,
|
|
181
|
+
app_id: int,
|
|
182
|
+
app_name: str | None = None,
|
|
183
|
+
default_sender: str | None = None,
|
|
184
|
+
default_signer: TransactionSigner | None = None,
|
|
185
|
+
approval_source_map: SourceMap | None = None,
|
|
186
|
+
clear_source_map: SourceMap | None = None,
|
|
187
|
+
) -> None: ...
|
|
188
|
+
|
|
189
|
+
def __init__(
|
|
190
|
+
self,
|
|
191
|
+
app_client: algokit_utils.AppClient | None = None,
|
|
192
|
+
*,
|
|
193
|
+
algorand: _AlgoKitAlgorandClient | None = None,
|
|
194
|
+
app_id: int | None = None,
|
|
195
|
+
app_name: str | None = None,
|
|
196
|
+
default_sender: str | None = None,
|
|
197
|
+
default_signer: TransactionSigner | None = None,
|
|
198
|
+
approval_source_map: SourceMap | None = None,
|
|
199
|
+
clear_source_map: SourceMap | None = None,
|
|
200
|
+
) -> None:
|
|
201
|
+
if app_client:
|
|
202
|
+
self.app_client = app_client
|
|
203
|
+
elif algorand and app_id:
|
|
204
|
+
self.app_client = algokit_utils.AppClient(
|
|
205
|
+
algokit_utils.AppClientParams(
|
|
206
|
+
algorand=algorand,
|
|
207
|
+
app_spec=APP_SPEC,
|
|
208
|
+
app_id=app_id,
|
|
209
|
+
app_name=app_name,
|
|
210
|
+
default_sender=default_sender,
|
|
211
|
+
default_signer=default_signer,
|
|
212
|
+
approval_source_map=approval_source_map,
|
|
213
|
+
clear_source_map=clear_source_map,
|
|
214
|
+
)
|
|
215
|
+
)
|
|
216
|
+
else:
|
|
217
|
+
raise ValueError("Either app_client or algorand and app_id must be provided")
|
|
218
|
+
|
|
219
|
+
self.params = HackathonContractParams(self.app_client)
|
|
220
|
+
self.create_transaction = HackathonContractCreateTransactionParams(self.app_client)
|
|
221
|
+
self.send = HackathonContractSend(self.app_client)
|
|
222
|
+
self.state = HackathonContractState(self.app_client)
|
|
223
|
+
|
|
224
|
+
@staticmethod
|
|
225
|
+
def from_creator_and_name(
|
|
226
|
+
creator_address: str,
|
|
227
|
+
app_name: str,
|
|
228
|
+
algorand: _AlgoKitAlgorandClient,
|
|
229
|
+
default_sender: str | None = None,
|
|
230
|
+
default_signer: TransactionSigner | None = None,
|
|
231
|
+
approval_source_map: SourceMap | None = None,
|
|
232
|
+
clear_source_map: SourceMap | None = None,
|
|
233
|
+
ignore_cache: bool | None = None,
|
|
234
|
+
app_lookup_cache: algokit_utils.ApplicationLookup | None = None,
|
|
235
|
+
) -> "HackathonContractClient":
|
|
236
|
+
return HackathonContractClient(
|
|
237
|
+
algokit_utils.AppClient.from_creator_and_name(
|
|
238
|
+
creator_address=creator_address,
|
|
239
|
+
app_name=app_name,
|
|
240
|
+
app_spec=APP_SPEC,
|
|
241
|
+
algorand=algorand,
|
|
242
|
+
default_sender=default_sender,
|
|
243
|
+
default_signer=default_signer,
|
|
244
|
+
approval_source_map=approval_source_map,
|
|
245
|
+
clear_source_map=clear_source_map,
|
|
246
|
+
ignore_cache=ignore_cache,
|
|
247
|
+
app_lookup_cache=app_lookup_cache,
|
|
248
|
+
)
|
|
249
|
+
)
|
|
250
|
+
|
|
251
|
+
@staticmethod
|
|
252
|
+
def from_network(
|
|
253
|
+
algorand: _AlgoKitAlgorandClient,
|
|
254
|
+
app_name: str | None = None,
|
|
255
|
+
default_sender: str | None = None,
|
|
256
|
+
default_signer: TransactionSigner | None = None,
|
|
257
|
+
approval_source_map: SourceMap | None = None,
|
|
258
|
+
clear_source_map: SourceMap | None = None,
|
|
259
|
+
) -> "HackathonContractClient":
|
|
260
|
+
return HackathonContractClient(
|
|
261
|
+
algokit_utils.AppClient.from_network(
|
|
262
|
+
app_spec=APP_SPEC,
|
|
263
|
+
algorand=algorand,
|
|
264
|
+
app_name=app_name,
|
|
265
|
+
default_sender=default_sender,
|
|
266
|
+
default_signer=default_signer,
|
|
267
|
+
approval_source_map=approval_source_map,
|
|
268
|
+
clear_source_map=clear_source_map,
|
|
269
|
+
)
|
|
270
|
+
)
|
|
271
|
+
|
|
272
|
+
@property
|
|
273
|
+
def app_id(self) -> int:
|
|
274
|
+
return self.app_client.app_id
|
|
275
|
+
|
|
276
|
+
@property
|
|
277
|
+
def app_address(self) -> str:
|
|
278
|
+
return self.app_client.app_address
|
|
279
|
+
|
|
280
|
+
@property
|
|
281
|
+
def app_name(self) -> str:
|
|
282
|
+
return self.app_client.app_name
|
|
283
|
+
|
|
284
|
+
@property
|
|
285
|
+
def app_spec(self) -> algokit_utils.Arc56Contract:
|
|
286
|
+
return self.app_client.app_spec
|
|
287
|
+
|
|
288
|
+
@property
|
|
289
|
+
def algorand(self) -> _AlgoKitAlgorandClient:
|
|
290
|
+
return self.app_client.algorand
|
|
291
|
+
|
|
292
|
+
def clone(
|
|
293
|
+
self,
|
|
294
|
+
app_name: str | None = None,
|
|
295
|
+
default_sender: str | None = None,
|
|
296
|
+
default_signer: TransactionSigner | None = None,
|
|
297
|
+
approval_source_map: SourceMap | None = None,
|
|
298
|
+
clear_source_map: SourceMap | None = None,
|
|
299
|
+
) -> "HackathonContractClient":
|
|
300
|
+
return HackathonContractClient(
|
|
301
|
+
self.app_client.clone(
|
|
302
|
+
app_name=app_name,
|
|
303
|
+
default_sender=default_sender,
|
|
304
|
+
default_signer=default_signer,
|
|
305
|
+
approval_source_map=approval_source_map,
|
|
306
|
+
clear_source_map=clear_source_map,
|
|
307
|
+
)
|
|
308
|
+
)
|
|
309
|
+
|
|
310
|
+
def new_group(self) -> "HackathonContractComposer":
|
|
311
|
+
return HackathonContractComposer(self)
|
|
312
|
+
|
|
313
|
+
@typing.overload
|
|
314
|
+
def decode_return_value(
|
|
315
|
+
self,
|
|
316
|
+
method: typing.Literal["hello(string)string"],
|
|
317
|
+
return_value: algokit_utils.ABIReturn | None
|
|
318
|
+
) -> str | None: ...
|
|
319
|
+
@typing.overload
|
|
320
|
+
def decode_return_value(
|
|
321
|
+
self,
|
|
322
|
+
method: str,
|
|
323
|
+
return_value: algokit_utils.ABIReturn | None
|
|
324
|
+
) -> algokit_utils.ABIValue | algokit_utils.ABIStruct | None: ...
|
|
325
|
+
|
|
326
|
+
def decode_return_value(
|
|
327
|
+
self,
|
|
328
|
+
method: str,
|
|
329
|
+
return_value: algokit_utils.ABIReturn | None
|
|
330
|
+
) -> algokit_utils.ABIValue | algokit_utils.ABIStruct | None | str:
|
|
331
|
+
"""Decode ABI return value for the given method."""
|
|
332
|
+
if return_value is None:
|
|
333
|
+
return None
|
|
334
|
+
|
|
335
|
+
arc56_method = self.app_spec.get_arc56_method(method)
|
|
336
|
+
decoded = return_value.get_arc56_value(arc56_method, self.app_spec.structs)
|
|
337
|
+
|
|
338
|
+
# If method returns a struct, convert the dict to appropriate dataclass
|
|
339
|
+
if (arc56_method and
|
|
340
|
+
arc56_method.returns and
|
|
341
|
+
arc56_method.returns.struct and
|
|
342
|
+
isinstance(decoded, dict)):
|
|
343
|
+
struct_class = globals().get(arc56_method.returns.struct)
|
|
344
|
+
if struct_class:
|
|
345
|
+
return struct_class(**typing.cast(dict, decoded))
|
|
346
|
+
return decoded
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
class HackathonContractComposer:
|
|
350
|
+
"""Composer for creating transaction groups for HackathonContract contract calls"""
|
|
351
|
+
|
|
352
|
+
def __init__(self, client: "HackathonContractClient"):
|
|
353
|
+
self.client = client
|
|
354
|
+
self._composer = client.algorand.new_group()
|
|
355
|
+
self._result_mappers: list[typing.Callable[[algokit_utils.ABIReturn | None], object] | None] = []
|
|
356
|
+
|
|
357
|
+
def hello(
|
|
358
|
+
self,
|
|
359
|
+
args: tuple[str] | HelloArgs,
|
|
360
|
+
params: algokit_utils.CommonAppCallParams | None = None
|
|
361
|
+
) -> "HackathonContractComposer":
|
|
362
|
+
self._composer.add_app_call_method_call(
|
|
363
|
+
self.client.params.hello(
|
|
364
|
+
args=args,
|
|
365
|
+
params=params,
|
|
366
|
+
)
|
|
367
|
+
)
|
|
368
|
+
self._result_mappers.append(
|
|
369
|
+
lambda v: self.client.decode_return_value(
|
|
370
|
+
"hello(string)string", v
|
|
371
|
+
)
|
|
372
|
+
)
|
|
373
|
+
return self
|
|
374
|
+
|
|
375
|
+
def clear_state(
|
|
376
|
+
self,
|
|
377
|
+
*,
|
|
378
|
+
args: list[bytes] | None = None,
|
|
379
|
+
params: algokit_utils.CommonAppCallParams | None = None,
|
|
380
|
+
) -> "HackathonContractComposer":
|
|
381
|
+
params=params or algokit_utils.CommonAppCallParams()
|
|
382
|
+
self._composer.add_app_call(
|
|
383
|
+
self.client.params.clear_state(
|
|
384
|
+
algokit_utils.AppClientBareCallParams(
|
|
385
|
+
**{
|
|
386
|
+
**dataclasses.asdict(params),
|
|
387
|
+
"args": args
|
|
388
|
+
}
|
|
389
|
+
)
|
|
390
|
+
)
|
|
391
|
+
)
|
|
392
|
+
return self
|
|
393
|
+
|
|
394
|
+
def add_transaction(
|
|
395
|
+
self, txn: Transaction, signer: TransactionSigner | None = None
|
|
396
|
+
) -> "HackathonContractComposer":
|
|
397
|
+
self._composer.add_transaction(txn, signer)
|
|
398
|
+
return self
|
|
399
|
+
|
|
400
|
+
def composer(self) -> algokit_utils.TransactionComposer:
|
|
401
|
+
return self._composer
|
|
402
|
+
|
|
403
|
+
def simulate(
|
|
404
|
+
self,
|
|
405
|
+
allow_more_logs: bool | None = None,
|
|
406
|
+
allow_empty_signatures: bool | None = None,
|
|
407
|
+
allow_unnamed_resources: bool | None = None,
|
|
408
|
+
extra_opcode_budget: int | None = None,
|
|
409
|
+
exec_trace_config: SimulateTraceConfig | None = None,
|
|
410
|
+
simulation_round: int | None = None,
|
|
411
|
+
skip_signatures: bool | None = None,
|
|
412
|
+
) -> algokit_utils.SendAtomicTransactionComposerResults:
|
|
413
|
+
return self._composer.simulate(
|
|
414
|
+
allow_more_logs=allow_more_logs,
|
|
415
|
+
allow_empty_signatures=allow_empty_signatures,
|
|
416
|
+
allow_unnamed_resources=allow_unnamed_resources,
|
|
417
|
+
extra_opcode_budget=extra_opcode_budget,
|
|
418
|
+
exec_trace_config=exec_trace_config,
|
|
419
|
+
simulation_round=simulation_round,
|
|
420
|
+
skip_signatures=skip_signatures,
|
|
421
|
+
)
|
|
422
|
+
|
|
423
|
+
def send(
|
|
424
|
+
self,
|
|
425
|
+
send_params: algokit_utils.SendParams | None = None
|
|
426
|
+
) -> algokit_utils.SendAtomicTransactionComposerResults:
|
|
427
|
+
return self._composer.send(send_params)
|
arc56_generated_ansar_e2fd235e-1.2.2026072010/src/arc56_generated_ansaria11_hackathon/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from . import HackathonContract_6b34a24a as HackathonContract_6b34a24a
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"contracts": {
|
|
3
|
+
"https://raw.githubusercontent.com/ansaria11/Hackathon/HEAD/projects/Hackathon-contracts/smart_contracts/artifacts/hackathon_contract/HackathonContract.arc56.json": {
|
|
4
|
+
"class_name": "HackathonContractClient",
|
|
5
|
+
"content_sha256": "0783df5dc5b8ccd42c872d1eb1467fe5bb4dce29f019151afb86885362eb04dc",
|
|
6
|
+
"file_slug": "HackathonContract",
|
|
7
|
+
"generated_at": "2026-07-18T15:56:43.391946+00:00",
|
|
8
|
+
"hash8": "6b34a24a",
|
|
9
|
+
"py_sha256": "0fb81b2112692d406772fdf0628bec23153e750582b2aaa9b50a6ed129ea4195"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"dist_name": "arc56-generated-ansar_e2fd235e",
|
|
13
|
+
"generator_version": "2.2.0",
|
|
14
|
+
"increment": 2,
|
|
15
|
+
"template_hash": "e7cb5fa2fecdfde3f4cdfff941ff9299032493e9bd016b9cfc7c4a6c889246d5",
|
|
16
|
+
"version": "1.2.2026072010"
|
|
17
|
+
}
|