Skip to content

Commit

Permalink
docs: regenerate examples
Browse files Browse the repository at this point in the history
  • Loading branch information
aorumbayev committed Mar 28, 2024
1 parent 7e88548 commit 98bbdd5
Show file tree
Hide file tree
Showing 22 changed files with 87 additions and 76 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,4 @@ examples/**/contracts/artifacts
examples/**/.algokit/sources

# playground folder for previewing templates
.playground/*
!.playground/.gitkeep
playground
8 changes: 4 additions & 4 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"-v",
"init",
"--name",
".playground",
"playground",
"--no-git",
"--UNSAFE-SECURITY-accept-template-url",
"--template-url",
Expand All @@ -18,13 +18,13 @@
"--no-bootstrap"
],
"type": "shell",
"dependsOn": ["Cleanup .playground folder"],
"dependsOn": ["Cleanup playground folder"],
"problemMatcher": []
},
{
"label": "Cleanup .playground folder",
"label": "Cleanup playground folder",
"command": "rm",
"args": ["-rf", ".playground"],
"args": ["-rf", "playground"],
"type": "shell",
"windows": {
"command": "./.vscode/clear.ps1"
Expand Down
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ This will regenerate the tests for default `starter` and `production` presets av
### Manual

```bash
poetry run copier copy . .playground --vcs-ref=HEAD --trust
poetry run copier copy . playground --vcs-ref=HEAD --trust
```

To generate a dummy project into the `.playground` folder. This is useful for testing the template to quickly preview the output of the template before testing via `pytest`.
To generate a dummy project into the `playground` folder. This is useful for testing the template to quickly preview the output of the template before testing via `pytest`.

### Using VSCode Tasks

In VSCode IDE, you can find the tasks in the `.vscode/tasks.json` file. To run them:

1. Open the command palette (`Cmd+Shift+P` on macOS, `Ctrl+Shift+P` on Windows/Linux) and type `> Run Task`
2. Select the task you want to run
3. It will be generated for you under the .playground folder
3. It will be generated for you under the playground folder

To cleanup the .playground folder run dedicated cleanup task.
To cleanup the playground folder run dedicated cleanup task.

## Contributing

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import beaker
import pyteal as pt
{% if preset_name == 'starter' %}
{%- if preset_name == 'starter' %}

app = beaker.Application("{{ contract_name }}")
{% elif preset_name == 'production' -%}
{%- elif preset_name == 'production' %}
from algokit_utils import DELETABLE_TEMPLATE_NAME, UPDATABLE_TEMPLATE_NAME

app = beaker.Application("{{ contract_name }}")
Expand All @@ -23,7 +23,8 @@ def delete() -> pt.Expr:
pt.Tmpl.Int(DELETABLE_TEMPLATE_NAME),
comment="Check app is deletable",
)
{% endif %}
{%- endif %}


@app.external
def hello(name: pt.abi.String, *, output: pt.abi.String) -> pt.Expr:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: 2.0.0
_commit: 2.0.1
_src_path: gh:algorandfoundation/algokit-beaker-default-template
author_email: None
author_name: None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,30 @@ This project has been generated using AlgoKit. See below for default getting sta

# Setup

For an interactive guided walkthrough of the project install [CodeTour](https://marketplace.visualstudio.com/items?itemName=vsls-contrib.codetour) in VS Code and run the `Getting Started with Your AlgoKit Project` tour in the `CodeTour` in Explorer panel in your VSCode instance.
### Pre-requisites

- [Python 3.10+](https://www.python.org/downloads/) (we recommended 3.12+)
- [Docker](https://www.docker.com/) (for LocalNet only)

> For interactive tour over the codebase, download [vsls-contrib.codetour](https://marketplace.visualstudio.com/items?itemName=vsls-contrib.codetour) extension for VS Code, then open the [`.codetour.json`](./.tours/getting-started-with-your-algokit-project.tour) file in code tour extension.
### Initial setup

1. Clone this repository locally
2. Install pre-requisites:
- Make sure to have [Docker](https://www.docker.com/) installed and running on your machine.
- Install `AlgoKit` - [Link](https://github.com/algorandfoundation/algokit-cli#install): The minimum required version is `1.1`. Ensure you can execute `algokit --version` and get `1.1` or later.
- Install `AlgoKit` - [Link](https://github.com/algorandfoundation/algokit-cli#install): The recommended version is the latest available. Ensure you can execute `algokit --version` and get `2.0.0` or later.
- Bootstrap your local environment; run `algokit bootstrap all` within this folder, which will:
- Install `Poetry` - [Link](https://python-poetry.org/docs/#installation): The minimum required version is `1.2`. Ensure you can execute `poetry -V` and get `1.2`+
- Install `Poetry` - [Link](https://python-poetry.org/docs/#installation): The minimum required version is `^1.7`. Ensure you can execute `poetry -V` and get `1.2`+
- Run `poetry install` in the root directory, which will set up a `.venv` folder with a Python virtual environment and also install all Python dependencies
- Copy `.env.template` to `.env`
- Run `algokit localnet start` to start a local Algorand network in Docker. If you are using VS Code launch configurations provided by the template, this will be done automatically for you.
- Run `algokit project bootstrap all` to install all project dependencies (unless executed during `algokit init`).
3. Open the project and start debugging / developing via:
- VS Code
- Terminal
1. Run `algokit project run build` to build all contracts in the project
2. Run `algokit project deploy localnet` to deploy all contracts to the local Algorand network.
- VS Code (Launch Configurations)
1. Open the repository root in VS Code
2. Install recommended extensions
3. Hit F5 (or whatever you have debug mapped to) and it should start running with breakpoint debugging.
Expand All @@ -31,10 +40,6 @@ For an interactive guided walkthrough of the project install [CodeTour](https://
1. Open the repository root in the IDE
2. It should automatically detect it's a Poetry project and set up a Python interpreter and virtual environment.
3. Hit Shift+F10|Ctrl+R (or whatever you have debug mapped to) and it should start running with breakpoint debugging. Please note, JetBrains IDEs on Windows have a known bug that in some cases may prevent executing shell scripts as pre-launch tasks, for workarounds refer to [JetBrains forums](https://youtrack.jetbrains.com/issue/IDEA-277486/Shell-script-configuration-cannot-run-as-before-launch-task).
- Other
1. Open the repository root in your text editor of choice
2. In a terminal run `poetry shell`
3. Run `python -m smart_contracts` through your debugger of choice

### Subsequently

Expand All @@ -47,6 +52,10 @@ This project uses [GitHub Actions](https://docs.github.com/en/actions/learn-gith

> Please note, if you instantiated the project with --workspace flag in `algokit init` it will automatically attempt to move the contents of the `.github` folder to the root of the workspace.
### AlgoKit Workspaces

To define custom `algokit project run` commands refer to [documentation](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/project/run.md). This allows orchestration of commands spanning across multiple projects within an algokit workspace based project (monorepo).

### Debugging Smart Contracts

This project is optimized to work with AlgoKit AVM Debugger extension. To activate it:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
logger = logging.getLogger(__name__)
logger.info("Loading .env")
load_dotenv()
load_dotenv(".env.localnet")
root_path = Path(__file__).parent


Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# pyright: reportMissingModuleSource=false
from algopy import ARC4Contract, arc4


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: 1.0.0
_commit: 1.0.1
_src_path: gh:algorandfoundation/algokit-python-template
author_email: None
author_name: None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
"line": 9
},
{
"file": "smart_contracts/__main__.py",
"description": "This is the main entry point for building your smart contracts. The default template includes a starter 'Hello World' contract that is deployed via the `algokit-utils` package (either `ts` or `py`, depending on your choice). To create a new smart contract, you can use the [`algokit generate`](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/generate.md) command and invoke a pre-bundled generator template by running `algokit generate smart-contract`. This action will create a new folder in the `smart_contracts` directory, named after your project. Each folder contains a `contract.py` file, which is the entry point for your contract implementation, and `deploy_config.py` | `deployConfig.ts` files (depending on the language chosen for the template), that perform the deployment of the contract.",
"line": 26
"file": ".algokit.toml",
"description": "This is the main configuration file used by algokit-cli to manage the project. The default template includes a starter 'Hello World' contract that is deployed via the `algokit-utils` package (either `ts` or `py`, depending on your choice). To create a new smart contract, you can use the [`algokit generate`](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/generate.md) command and invoke a pre-bundled generator template by running `algokit generate smart-contract` (see how it is defined in the `.algokit.toml`, you can create your own generators if needed). This action will create a new folder in the `smart_contracts` directory, named after your project. Each folder contains a `contract.py` file, which is the entry point for your contract implementation, and `deploy_config.py` | `deployConfig.ts` files (depending on the language chosen for the template), that perform the deployment of the contract. Additionally you can define custom commands to run (similar to `npm` scripts), see definitions under `[project]` section in `.algokit.toml`.",
"line": 1
},
{
"file": "smart_contracts/hello_world/deploy_config.py",
"description": "The default deployment scripts invoke a sample method on the starter contract that demonstrates how to interact with your deployed Algorand on-chain applications using the [`AlgoKit Typed Clients`](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/generate.md#1-typed-clients) feature.",
"description": "The default deployment scripts invoke a sample method on the starter contract that demonstrates how to interact with your deployed Algorand on-chain applications using the [`AlgoKit Typed Clients`](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/generate.md#1-typed-clients) feature. The invocation if deploy is aliased in `.algokit.toml` file, allowing simple deployments via `algokit project deploy` command.",
"line": 32
},
{
Expand All @@ -32,14 +32,9 @@
"description": "Environment files are a crucial mechanism that allows you to set up the [`algokit deploy`](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/deploy.md) feature to simplify deploying your contracts in CI/CD environments (please note we still recommend careful evaluation when it comes to deployment to MainNet). Clone the file and remove the `.template` suffix to apply the changes to deployment scripts and launch configurations. The network prefix `localnet|testnet|mainnet` is primarily optimized for `algokit deploy`. The order of loading the variables is `.env.{network}` < `.env`.",
"line": 2
},
{
"file": ".algokit.toml",
"description": "This is the configuration file used by AlgoKit to determine version requirements, `algokit deploy` settings, and references to custom generators.",
"line": 5
},
{
"file": ".vscode/launch.json",
"description": "Refer to the pre-bundled Visual Studio launch configurations, offering various options on how to execute the build and deployment of your smart contracts.",
"description": "Refer to the pre-bundled Visual Studio launch configurations, offering various options on how to execute the build and deployment of your smart contracts. Alternatively execute `algokit project run` to see list of available custom commands.",
"line": 5
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,25 @@ This project has been generated using AlgoKit. See below for default getting sta
- [Python 3.12](https://www.python.org/downloads/) or later
- [Docker](https://www.docker.com/) (only required for LocalNet)

> For interactive tour over the codebase, download [vsls-contrib.codetour](https://marketplace.visualstudio.com/items?itemName=vsls-contrib.codetour) extension for VS Code, then open the [`.codetour.json`](./.tours/getting-started-with-your-algokit-project.tour) file in code tour extension.
### Initial setup

1. Clone this repository locally
2. Install pre-requisites:
- Make sure to have [Docker](https://www.docker.com/) installed and running on your machine.
- Install `AlgoKit` - [Link](https://github.com/algorandfoundation/algokit-cli#install): The recommended version is `1.7.3`. Ensure you can execute `algokit --version` and get `1.7.1` or later.
- Install `AlgoKit` - [Link](https://github.com/algorandfoundation/algokit-cli#install): The recommended version is the latest available. Ensure you can execute `algokit --version` and get `2.0.0` or later.
- Bootstrap your local environment; run `algokit bootstrap all` within this folder, which will:
- Install `Poetry` - [Link](https://python-poetry.org/docs/#installation): The minimum required version is `^1.7`. Ensure you can execute `poetry -V` and get `1.2`+
- Run `poetry install` in the root directory, which will set up a `.venv` folder with a Python virtual environment and also install all Python dependencies
- Copy `.env.template` to `.env`
- Run `algokit localnet start` to start a local Algorand network in Docker. If you are using VS Code launch configurations provided by the template, this will be done automatically for you.
- Run `algokit project bootstrap all` to install all project dependencies (unless executed during `algokit init`).
3. Open the project and start debugging / developing via:
- VS Code
- Terminal
1. Run `algokit project run build` to build all contracts in the project
2. Run `algokit project deploy localnet` to deploy all contracts to the local Algorand network.
- VS Code (Launch Configurations)
1. Open the repository root in VS Code
2. Install recommended extensions
3. Hit F5 (or whatever you have debug mapped to) and it should start running with breakpoint debugging.
Expand All @@ -34,10 +40,6 @@ This project has been generated using AlgoKit. See below for default getting sta
1. Open the repository root in the IDE
2. It should automatically detect it's a Poetry project and set up a Python interpreter and virtual environment.
3. Hit Shift+F10|Ctrl+R (or whatever you have debug mapped to) and it should start running with breakpoint debugging. Please note, JetBrains IDEs on Windows have a known bug that in some cases may prevent executing shell scripts as pre-launch tasks, for workarounds refer to [JetBrains forums](https://youtrack.jetbrains.com/issue/IDEA-277486/Shell-script-configuration-cannot-run-as-before-launch-task).
- Other
1. Open the repository root in your text editor of choice
2. In a terminal run `poetry shell`
3. Run `python -m smart_contracts` through your debugger of choice

### Subsequently

Expand All @@ -50,6 +52,10 @@ This project uses [GitHub Actions](https://docs.github.com/en/actions/learn-gith

> Please note, if you instantiated the project with --workspace flag in `algokit init` it will automatically attempt to move the contents of the `.github` folder to the root of the workspace.
### AlgoKit Workspaces

To define custom `algokit project run` commands refer to [documentation](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/project/run.md). This allows orchestration of commands spanning across multiple projects within an algokit workspace based project (monorepo).

### Debugging Smart Contracts

This project is optimized to work with AlgoKit AVM Debugger extension. To activate it:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
logger = logging.getLogger(__name__)
logger.info("Loading .env")
load_dotenv()
load_dotenv(".env.localnet")
root_path = Path(__file__).parent


Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import beaker
import pyteal as pt
{% if preset_name == 'starter' %}
{%- if preset_name == 'starter' %}

app = beaker.Application("{{ contract_name }}")
{% elif preset_name == 'production' -%}
{%- elif preset_name == 'production' %}
from algokit_utils import DELETABLE_TEMPLATE_NAME, UPDATABLE_TEMPLATE_NAME

app = beaker.Application("{{ contract_name }}")
Expand All @@ -23,7 +23,8 @@ def delete() -> pt.Expr:
pt.Tmpl.Int(DELETABLE_TEMPLATE_NAME),
comment="Check app is deletable",
)
{% endif %}
{%- endif %}


@app.external
def hello(name: pt.abi.String, *, output: pt.abi.String) -> pt.Expr:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: 2.0.0
_commit: 2.0.1
_src_path: gh:algorandfoundation/algokit-beaker-default-template
author_email: None
author_name: None
Expand Down
Loading

0 comments on commit 98bbdd5

Please sign in to comment.