Skip to content

Beaker & PyTeal deprecation #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 46 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
f831395
chore: remove beaker from the dependencies in favor of algorand python.
CiottiGiorgio Jan 16, 2025
f9ec745
feat: rewrote all contracts other than voting in algopy.
CiottiGiorgio Jan 22, 2025
3c40190
feat: voting contract.
CiottiGiorgio Jan 24, 2025
9ae6b9f
feat: linting & rebuilding.
CiottiGiorgio Jan 24, 2025
9eec2b5
Merge branch 'main' into feature/beaker-deprecation
CiottiGiorgio Jan 31, 2025
0c27d71
fix: ran "poetry lock"
CiottiGiorgio Jan 31, 2025
d1ca02e
fix: rebuilt clients
CiottiGiorgio Jan 31, 2025
75a5cab
fix: rebuilt specs and clients
CiottiGiorgio Jan 31, 2025
a0790f2
Merge branch 'main' into feature/beaker-deprecation
CiottiGiorgio Feb 4, 2025
cc75486
fix: ran "poetry lock"
CiottiGiorgio Feb 4, 2025
b0a1373
fix: rebuilt specs and clients
CiottiGiorgio Feb 4, 2025
b0192d7
fix: added structs contract
CiottiGiorgio Feb 4, 2025
0c90833
fix: added zero coupon bond contract
CiottiGiorgio Feb 4, 2025
5fd671a
fix: added reti contract
CiottiGiorgio Feb 4, 2025
76ffa72
fix: added arc56_test contract
CiottiGiorgio Feb 4, 2025
51d1d48
fix: added nfd contract
CiottiGiorgio Feb 4, 2025
a850aaf
fix: added nested contract
CiottiGiorgio Feb 4, 2025
675bab7
fix: added duplicate structs contract
CiottiGiorgio Feb 5, 2025
8ca5efc
fix: fixed most app tests
CiottiGiorgio Feb 5, 2025
5509e8f
fix: formatting and simplifying build pipeline
CiottiGiorgio Feb 5, 2025
a8be469
fix: simplifying update_approvals.py
CiottiGiorgio Feb 5, 2025
7cf8527
fix: linting and formatting
CiottiGiorgio Feb 5, 2025
57ce5f9
fix: adding client generation for missed apps
CiottiGiorgio Feb 5, 2025
b964f76
fix: stability test
CiottiGiorgio Feb 5, 2025
76d1cc0
fix: linting and formatting.
CiottiGiorgio Feb 5, 2025
d76a0b9
fix: poetry update.
CiottiGiorgio Feb 5, 2025
a28601a
fix: state contract testing.
CiottiGiorgio Feb 5, 2025
4f93854
fix: voting contract according to tests.
CiottiGiorgio Feb 5, 2025
57fa381
fix: porting new testing from main.
CiottiGiorgio Feb 5, 2025
86da87b
fix: rebuild artifacts.
CiottiGiorgio Feb 5, 2025
136c8bc
fix: fixed typing issue.
CiottiGiorgio Feb 5, 2025
8fd8fe3
Merge branch 'main' into feature/beaker-deprecation
CiottiGiorgio Feb 6, 2025
1980e80
fix: poetry lock --no-update.
CiottiGiorgio Feb 6, 2025
6845db0
fix: rebuilt artifacts.
CiottiGiorgio Feb 6, 2025
83d79b2
fix: python 3.12 only required when in installed with the dev group.
CiottiGiorgio Feb 6, 2025
5802d01
fix: using external package to convert to camel case.
CiottiGiorgio Feb 6, 2025
e5eae6d
fix: linting.
CiottiGiorgio Feb 6, 2025
bc1c8a2
fix: capitalize app names.
CiottiGiorgio Feb 6, 2025
d3ecdf4
fix: harmonize lifecycle contract names.
CiottiGiorgio Feb 6, 2025
92bfd5c
fix: harmonize nfd and arc56Test contract names.
CiottiGiorgio Feb 6, 2025
c998bfa
fix: update README.md.
CiottiGiorgio Feb 6, 2025
3818d10
fix: state contract correctly hints default arg from local state beca…
CiottiGiorgio Feb 7, 2025
3314d84
fix: poetry update & rebuild all artifacts
CiottiGiorgio Feb 7, 2025
f06d346
fix: remove inflection
CiottiGiorgio Feb 7, 2025
c9b9ba5
fix: harmonize contracts that have acronyms in the name
CiottiGiorgio Feb 7, 2025
0718728
fix: import arc56_test client in related test
CiottiGiorgio Feb 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,4 @@ node_modules

smart_contracts/coverage/

examples/*/client_generated.py
examples/smart_contracts/artifacts/*/client_generated.py
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ algokit generate client path/to/application.json --output path/to/output/client_

## Examples

There are a range of [examples](./examples) that you can look at to see a source smart contract (e.g. `{contract.py}`), the generated client (`client_generated.py`) and some tests that demonstrate how you can use the client (`test_client.py`).
There are a range of [examples](./examples) that you can look at to see a source smart contract (e.g. `{app_name}/contract.py`), the generated client (`artifacts/{app_name}/{app_name}_client.py`) and some tests that demonstrate how you can use the client (`tests/{app_name}_test_client.py`).

## Contributing

Expand Down Expand Up @@ -72,9 +72,11 @@ If you want to contribute to this project the following information will be help

### Building examples

In the `examples` folder there is a series of example contracts along with their generated client. These contracts are written in various languages including [Algorand Python](https://github.com/algorandfoundation/puya), [TealScript](https://github.com/algorandfoundation/TEALScript) and [Beaker](https://github.com/algorandfoundation/beaker) (for backwards compatibility with ARC-32 and previous versions of the generator).
In the `examples` folder there is a series of example contracts along with their generated client. These contracts are originally written in various languages including [Algorand Python](https://github.com/algorandfoundation/puya), [Algorand TypeScript](https://github.com/algorandfoundation/puya-ts), and [TealScript](https://github.com/algorandfoundation/TEALScript).

If you want to make changes to any of the smart contract examples and re-generate the ARC-32/56 application.json files then change the corresponding `examples/{contract}/{contract}.py` file and then run:
Some contracts are directly imported through the ARC-32/56 app spec and not through contract source code.

If you want to make changes to any of the smart contract examples and re-generate the ARC-32/56 JSON specs files then change the corresponding `examples/smart_contracts/{app_name}/contract.py` file and then run:

```
poetry run python -m examples
Expand All @@ -84,6 +86,8 @@ Or in Visual Studio Code you can use the default build task (Ctrl+Shift+B).

To regenerate the generated clients run `poetry run poe update-approvals`.

This package currently depends on Python 3.10, however the development depends on Python 3.12. This is represented by the `pyproject.toml` file which requires 3.10 with additional requirements on dev dependencies.

### Continuous Integration / Continuous Deployment (CI/CD)

This project uses [GitHub Actions](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions) to define CI/CD workflows, which are located in the [`.github/workflows`](./.github/workflows) folder.
Expand Down
94 changes: 45 additions & 49 deletions examples/__main__.py
Original file line number Diff line number Diff line change
@@ -1,63 +1,59 @@
import importlib
import json
import logging
import os
from collections.abc import Generator
from contextlib import contextmanager
import pathlib
import subprocess
from itertools import chain, product
from pathlib import Path

import algokit_utils

logging.basicConfig(
level=logging.DEBUG, format="%(asctime)s %(levelname)-10s: %(message)s"
)
logging.basicConfig(level=logging.DEBUG, format="%(asctime)s %(levelname)-10s: %(message)s")
logger = logging.getLogger(__name__)
root_path = Path(__file__).parent


@contextmanager
def cwd(path: Path) -> Generator[None, None, None]:
old_pwd = Path.cwd()
os.chdir(path)
try:
yield
finally:
os.chdir(old_pwd)


def to_json(app_spec: algokit_utils.ApplicationSpecification) -> str:
app_spec_dict = app_spec.dictify()
# beaker always outputs an empty string by default for the schema "descr" field, however this field is optional
# so remove these keys if they are an empty string so optional descr fields are covered
for scope in ("global", "local"):
for reservation in ("declared", "reserved"):
state_dict = app_spec_dict["schema"][scope][reservation]
for _field, field_spec in state_dict.items():
if not field_spec.get("descr"):
del field_spec["descr"]
return json.dumps(app_spec_dict, indent=4)


def main() -> None:
example_dirs = filter(
lambda file: file.is_dir() and "__" not in file.name, root_path.glob("*")
)
for example in example_dirs:
smart_contracts = pathlib.Path(__file__).parent / "smart_contracts"
artifacts = smart_contracts / "artifacts"
output_options = {
"arc32": ["--output-arc32", "--no-output-arc56"],
"arc56": ["--output-arc56", "--no-output-arc32"],
}
arc32_apps = [
"duplicate_structs",
"hello_world",
"life_cycle",
"minimal",
"state",
"voting_round",
]
arc56_apps = [
"structs",
"nested",
]

for app, options in chain(
product(arc32_apps, [output_options["arc32"]]), product(arc56_apps, [output_options["arc56"]])
):
app_path = smart_contracts / app / "contract.py"
app_artifacts = artifacts / app
try:
logger.info(f"Building example {example.name}")
with cwd(root_path):
evaluated_file = importlib.import_module(
f"examples.{example.name}.{example.name}"
)
app = evaluated_file.app
logger.info(f" Building app {app.name}")
app_spec = app.build()
logger.info(f" Writing {example.name}/application.json")
(example / "application.json").write_text(
to_json(app_spec), encoding="utf-8"
subprocess.run(
[
"algokit",
"--no-color",
"compile",
"python",
app_path.absolute(),
f"--out-dir={app_artifacts}",
"--no-output-teal",
"--no-output-source-map",
]
+ options,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
text=True,
check=True,
)
except Exception as e:
logger.warning(f"Skipping example {example.name} due to error: {e}")
print(f"Error compiling contract for app {app}: {e}")


if __name__ == "__main__":
Expand Down
3 changes: 0 additions & 3 deletions examples/arc56_test/__init__.py

This file was deleted.

21 changes: 0 additions & 21 deletions examples/deployment_standard.py

This file was deleted.

3 changes: 0 additions & 3 deletions examples/duplicate_structs/__init__.py

This file was deleted.

92 changes: 0 additions & 92 deletions examples/duplicate_structs/application.json

This file was deleted.

3 changes: 0 additions & 3 deletions examples/helloworld/__init__.py

This file was deleted.

75 changes: 0 additions & 75 deletions examples/helloworld/application.json

This file was deleted.

25 changes: 0 additions & 25 deletions examples/helloworld/helloworld.py

This file was deleted.

3 changes: 0 additions & 3 deletions examples/lifecycle/__init__.py

This file was deleted.

Loading