From 54bb16cf6472f492c130f4eb5d06bc4206207412 Mon Sep 17 00:00:00 2001 From: Altynbek Orumbayev Date: Fri, 8 Mar 2024 22:29:01 +0100 Subject: [PATCH 01/29] feat: refining pipelines to rely on orchestration; defining run commands --- copier.yaml | 43 ++++---- includes/project_name_kebab.jinja | 1 + template_content/.algokit.toml.jinja | 67 ++++++++++-- .../workflows/checks.yaml.jinja | 102 ------------------ .../workflows/pr.yaml | 8 -- ...oject_name_kebab.jinja') %}-cd.yaml.jinja} | 33 +++--- ...roject_name_kebab.jinja') %}-ci.yaml.jinja | 63 +++++++++++ 7 files changed, 165 insertions(+), 152 deletions(-) create mode 100644 includes/project_name_kebab.jinja delete mode 100644 template_content/{% if use_github_actions %}.github{% endif %}/workflows/checks.yaml.jinja delete mode 100644 template_content/{% if use_github_actions %}.github{% endif %}/workflows/pr.yaml rename template_content/{% if use_github_actions %}.github{% endif %}/workflows/{cd.yaml.jinja => {% include pathjoin('includes', 'project_name_kebab.jinja') %}-cd.yaml.jinja} (65%) create mode 100644 template_content/{% if use_github_actions %}.github{% endif %}/workflows/{% include pathjoin('includes', 'project_name_kebab.jinja') %}-ci.yaml.jinja diff --git a/copier.yaml b/copier.yaml index 134017a..683c810 100644 --- a/copier.yaml +++ b/copier.yaml @@ -1,23 +1,18 @@ _subdirectory: template_content _templates_suffix: ".jinja" +use_workspace: + type: bool + when: false # never prompted to user explicitly, instead expect cli to auto fill (supported cli versions > v1.13.x) + help: Automatically filled by AlgoKit CLI (>1.13.x) - passes the --workspace/--no-workspace flag's value, can be used to reason whether this template is currently being instantiated as part of a workspace or not. + default: no + # questions -# project_name should never get prompted, AlgoKit should always pass it by convention project_name: type: str help: Name for this project. placeholder: "algorand-app" -contract_name: - type: str - help: Name of the default smart contract app. - placeholder: "hello_world" - default: "hello_world" - validator: >- - {% if not (contract_name | regex_search('^[a-z]+(?:_[a-z]+)*$')) %} - contract_name must be formatted in snake case. - {% endif %} - author_name: type: str help: Package author name @@ -30,6 +25,16 @@ author_email: placeholder: "your@email.tld" default: "your@email.tld" +contract_name: + type: str + help: Name of the default smart contract app. + placeholder: "hello_world" + default: "hello_world" + validator: >- + {% if not (contract_name | regex_search('^[a-z]+(?:_[a-z]+)*$')) %} + contract_name must be formatted in snake case. + {% endif %} + preset_name: type: str help: Name of the template preset to use. @@ -57,7 +62,7 @@ ide_jetbrains: type: bool help: Do you want to add JetBrains configuration (primarily optimized for PyCharm CE)? when: "{{ preset_name == 'custom' }}" - default: no + default: "{{ 'yes' if preset_name == 'production' else 'no' }}" use_python_pytest: type: bool @@ -79,40 +84,40 @@ python_linter: Ruff: "ruff" Flake8: "flake8" No thanks: "none" - default: "ruff" + default: "{{ 'ruff' if preset_name == 'production' else 'none' }}" use_python_black: type: bool help: Do you want to use a Python formatter (via Black)? when: "{{ preset_name == 'custom' }}" - default: yes + default: "{{ 'yes' if preset_name == 'production' else 'no' }}" use_python_mypy: type: bool when: "{{ preset_name == 'custom' }}" help: Do you want to use a Python type checker (via mypy)? - default: yes + default: "{{ 'yes' if preset_name == 'production' else 'no' }}" use_python_pip_audit: type: bool when: "{{ preset_name == 'custom' }}" help: Do you want to include Python dependency vulnerability scanning (via pip-audit)? - default: yes + default: "{{ 'yes' if preset_name == 'production' else 'no' }}" use_github_actions: type: bool when: "{{ preset_name == 'custom' }}" help: Do you want to include Github Actions workflows for build and testnet deployment? - default: yes + default: "{{ 'yes' if preset_name == 'production' else 'no' }}" use_pre_commit: type: bool when: "{{ preset_name == 'custom' }}" help: Do you want to include pre-commit for linting, type checking and formatting? - default: yes + default: "{{ 'yes' if preset_name == 'production' else 'no' }}" use_dispenser: type: bool when: "{{ preset_name == 'custom' }}" help: Do you want to fund your deployment account using an optional dispenser account? - default: no + default: "{{ 'yes' if preset_name == 'production' else 'no' }}" diff --git a/includes/project_name_kebab.jinja b/includes/project_name_kebab.jinja new file mode 100644 index 0000000..9bd9740 --- /dev/null +++ b/includes/project_name_kebab.jinja @@ -0,0 +1 @@ +{{- project_name | trim | replace("_", "-") | replace(" ", "-") | lower() | regex_replace('[-]+', '-') | regex_replace('[^a-z0-9.-]', '') -}} diff --git a/template_content/.algokit.toml.jinja b/template_content/.algokit.toml.jinja index 8f41d0f..bb8cbec 100644 --- a/template_content/.algokit.toml.jinja +++ b/template_content/.algokit.toml.jinja @@ -1,7 +1,16 @@ [algokit] min_version = "v1.8.0" -[deploy] +[generate.smart_contract] +description = "Adds new smart contract to existing project" +path = ".algokit/generators/create_contract" + +[project] +type = 'contract' +name = '{{ project_name }}' +artifacts = 'smart_contracts/artifacts' + +[project.deploy] {%- if deployment_language == 'python' %} command = "poetry run python -m smart_contracts deploy" {%- elif deployment_language == 'typescript' %} @@ -14,13 +23,55 @@ environment_secrets = [ {%- endif %} ] -[deploy.localnet] +[project.deploy.localnet] environment_secrets = [] -[generate.smart_contract] -description = "Adds new smart contract to existing project" -path = ".algokit/generators/create_contract" +[project.run] +# Commands intented for use locally and in CI +{%- if deployment_language == 'python' %} +build = { commands = [ + 'poetry run python -m smart_contracts build', +], description = 'Build all smart contracts in the project' } +{%- elif deployment_language == 'typescript' %} +build = { commands = [ + 'npm run build', +], description = 'Build all smart contracts in the project' } +{%- endif %} +{%- if deployment_language == 'python' and use_python_pytest %} +test = { commands = [ + 'poetry run pytest', +], description = 'Run smart contract tests' } +{%- elif deployment_language == 'typescript' and use_typescript_jest %} +test = { commands = [ + 'npm run test', +], description = 'Run smart contract tests using Jest' } +{%- endif %} +{%- if use_python_pip_audit %} +audit = { commands = [ + 'poetry export --without=dev -o requirements.txt', + 'poetry run pip-audit -r requirements.txt', +], description = 'Audit with pip-audit' } +{%- endif %} +lint = { commands = [ +{%- if use_python_black %} + 'poetry run black --check .', +{%- endif %} +{%- if python_linter == 'ruff' %} + 'poetry run ruff .', +{%- elif python_linter == 'flake8' %} + 'poetry run flake8 .', +{%- endif %} +{%- if use_python_mypy %} + 'poetry run mypy', +{%- endif %} +], description = 'Perform linting' } +audit-teal = { commands = [ + # 🚨 IMPORTANT 🚨: For strict TEAL validation, remove --exclude statements. The default starter contract is not for production. Ensure thorough testing and adherence to best practices in smart contract development. This is not a replacement for a professional audit. + 'algokit task analyze smart_contracts/artifacts --recursive --force --exclude rekey-to --exclude is-updatable --exclude missing-fee-check --exclude is-deletable --exclude can-close-asset --exclude can-close-account --exclude unprotected-deletable --exclude unprotected-updatable', +], description = 'Audit TEAL files' } -[project] -type = 'contract' -name = '{{ project_name }}' +# Commands indented for CI only, prefixed with `ci-` by convention +ci-teal-diff = { commands = [ + 'git add -N ./smart_contracts/artifacts', + 'git diff --exit-code --minimal ./smart_contracts/artifacts', +], description = 'Check TEAL files for differences' } diff --git a/template_content/{% if use_github_actions %}.github{% endif %}/workflows/checks.yaml.jinja b/template_content/{% if use_github_actions %}.github{% endif %}/workflows/checks.yaml.jinja deleted file mode 100644 index b5022f5..0000000 --- a/template_content/{% if use_github_actions %}.github{% endif %}/workflows/checks.yaml.jinja +++ /dev/null @@ -1,102 +0,0 @@ -name: Check code base - -on: - workflow_call: - -jobs: - checks: - runs-on: 'ubuntu-latest' - steps: - - name: Checkout source code - uses: actions/checkout@v4 - - - name: Install poetry - run: pipx install poetry - - - name: Set up Python 3.12 - uses: actions/setup-python@v5 - with: - python-version: '3.12' - cache: 'poetry' - - - name: Install algokit - run: pipx install algokit - - - name: Start LocalNet - run: algokit localnet start - - - name: Bootstrap dependencies - run: algokit bootstrap all - - - name: Configure git - shell: bash - run: | - # set git user and email as test invoke git - git config --global user.email "actions@github.com" && git config --global user.name "github-actions" -{%- if use_python_pip_audit %} - - - name: Audit with pip-audit - run: | - # audit non dev dependencies, no exclusions - poetry export --without=dev > requirements.txt && poetry run pip-audit -r requirements.txt - - # audit all dependencies, with exclusions. - # If a vulnerability is found in a dev dependency without an available fix, - # it can be temporarily ignored by adding --ignore-vuln e.g. - # --ignore-vuln "GHSA-hcpj-qp55-gfph" # GitPython vulnerability, dev only dependency - poetry run pip-audit -{%- endif %} -{%- if use_python_black %} - - - name: Check formatting with Black - run: | - # stop the build if there are files that don't meet formatting requirements - poetry run black --check . -{%- endif %} -{%- if python_linter == 'ruff' %} - - - name: Check linting with Ruff - run: | - # stop the build if there are Python syntax errors or undefined names - poetry run ruff . -{%- elif python_linter == 'flake8' %} - - - name: Check linting with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - poetry run flake8 . -{%- endif %} -{%- if use_python_mypy %} - - - name: Check types with mypy - run: poetry run mypy -{%- endif %} -{%- if use_python_pytest %} - - - name: Run tests - shell: bash - run: | - set -o pipefail - poetry run pytest --junitxml=pytest-junit.xml -{%- endif %} - - - name: Build smart contracts - run: poetry run python -m smart_contracts build - - - name: Scan TEAL files for issues - run: algokit task analyze .algokit --recursive --force # add --diff flag if you want output stability checks instead - - - name: Check output stability of the smart contracts - shell: bash - run: | - # Add untracked files as empty so they come up in diff - git add -N ./smart_contracts/artifacts - # Error out if there are any changes in teal after generating output - git diff --exit-code --minimal ./smart_contracts/artifacts || (echo "::error ::Smart contract artifacts have changed, ensure committed artifacts are up to date" && exit 1); - - - name: Run deployer against LocalNet -{%- if deployment_language == 'typescript' %} - run: npm run --prefix smart_contracts deploy:ci -{%- elif deployment_language == 'python' %} - run: poetry run python -m smart_contracts deploy -{%- endif %} diff --git a/template_content/{% if use_github_actions %}.github{% endif %}/workflows/pr.yaml b/template_content/{% if use_github_actions %}.github{% endif %}/workflows/pr.yaml deleted file mode 100644 index a80f784..0000000 --- a/template_content/{% if use_github_actions %}.github{% endif %}/workflows/pr.yaml +++ /dev/null @@ -1,8 +0,0 @@ -name: Pull Request validation - -on: [pull_request] - -jobs: - pr-check: - name: Perform Checks - uses: ./.github/workflows/checks.yaml diff --git a/template_content/{% if use_github_actions %}.github{% endif %}/workflows/cd.yaml.jinja b/template_content/{% if use_github_actions %}.github{% endif %}/workflows/{% include pathjoin('includes', 'project_name_kebab.jinja') %}-cd.yaml.jinja similarity index 65% rename from template_content/{% if use_github_actions %}.github{% endif %}/workflows/cd.yaml.jinja rename to template_content/{% if use_github_actions %}.github{% endif %}/workflows/{% include pathjoin('includes', 'project_name_kebab.jinja') %}-cd.yaml.jinja index 5a8e0fe..b7a2bbd 100644 --- a/template_content/{% if use_github_actions %}.github{% endif %}/workflows/cd.yaml.jinja +++ b/template_content/{% if use_github_actions %}.github{% endif %}/workflows/{% include pathjoin('includes', 'project_name_kebab.jinja') %}-cd.yaml.jinja @@ -1,21 +1,24 @@ -name: Continuous Delivery of Smart Contract +name: Release {{ project_name }} on: + workflow_call: + + {%- if not use_workspace %} push: branches: - main - -concurrency: release + {%- endif %} jobs: - ci-check: - name: Perform Checks - uses: ./.github/workflows/checks.yaml - + {%- if not use_workspace %} + validate: + name: Validate {{ project_name }} + uses: ./.github/workflows/{% include pathjoin('includes', 'project_name_kebab.jinja') %}-ci.yaml + {%- endif %} deploy-testnet: - runs-on: 'ubuntu-latest' - needs: ci-check - environment: Test + runs-on: "ubuntu-latest" + {% if not use_workspace %}needs: validate{% endif %} + environment: contract-testnet steps: - name: Checkout source code uses: actions/checkout@v4 @@ -26,14 +29,14 @@ jobs: - name: Set up Python 3.12 uses: actions/setup-python@v5 with: - python-version: '3.12' - cache: 'poetry' + python-version: "3.12" + cache: "poetry" - name: Install algokit - run: pipx install algokit + run: pipx install git+https://github.com/algorandfoundation/algokit-cli@feat/orchestration-linking - name: Bootstrap dependencies - run: algokit bootstrap all + run: algokit bootstrap all --project-name '{{ project_name }}' - name: Configure git shell: bash @@ -42,7 +45,7 @@ jobs: git config --global user.email "actions@github.com" && git config --global user.name "github-actions" - name: Deploy to testnet - run: algokit deploy testnet + run: algokit deploy testnet --project-name '{{ project_name }}' env: {%- if use_dispenser %} # This is the account that becomes the creator of the contract diff --git a/template_content/{% if use_github_actions %}.github{% endif %}/workflows/{% include pathjoin('includes', 'project_name_kebab.jinja') %}-ci.yaml.jinja b/template_content/{% if use_github_actions %}.github{% endif %}/workflows/{% include pathjoin('includes', 'project_name_kebab.jinja') %}-ci.yaml.jinja new file mode 100644 index 0000000..80197f7 --- /dev/null +++ b/template_content/{% if use_github_actions %}.github{% endif %}/workflows/{% include pathjoin('includes', 'project_name_kebab.jinja') %}-ci.yaml.jinja @@ -0,0 +1,63 @@ +name: Validate {{ project_name }} + +on: + workflow_call: + + {%- if not use_workspace %} + pull_request: + {%- endif %} + +jobs: + validate: + runs-on: "ubuntu-latest" + steps: + - name: Checkout source code + uses: actions/checkout@v4 + + - name: Install poetry + run: pipx install poetry + + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: "3.12" + cache: "poetry" + + - name: Install algokit + run: pipx install git+https://github.com/algorandfoundation/algokit-cli@feat/orchestration-linking + + - name: Start LocalNet + run: algokit localnet start + + - name: Bootstrap dependencies + run: algokit bootstrap all --project-name '{{ project_name }}' + + - name: Configure git + shell: bash + run: | + # set git user and email as test invoke git + git config --global user.email "actions@github.com" && git config --global user.name "github-actions" + + - name: Audit python dependencies + run: algokit project run audit --project-name '{{ project_name }}' + + - name: Lint and format python dependencies + run: algokit project run lint --project-name '{{ project_name }}' + + - name: Run tests + shell: bash + run: | + set -o pipefail + algokit project run test --project-name '{{ project_name }}' + + - name: Build smart contracts + run: algokit project run build --project-name '{{ project_name }}' + + - name: Scan TEAL files for issues + run: algokit project run audit-teal --project-name '{{ project_name }}' + + - name: Check output stability of the smart contracts + run: algokit project run ci-teal-diff --project-name '{{ project_name }}' + + - name: Run deployer against LocalNet + run: algokit project deploy localnet --project-name '{{ project_name }}' From 3b2d772d87460dc6d547de278007723652619156 Mon Sep 17 00:00:00 2001 From: Altynbek Orumbayev Date: Fri, 8 Mar 2024 22:33:43 +0100 Subject: [PATCH 02/29] chore: regen examples --- examples/generators/.gitkeep | 0 .../.algokit.toml | 46 +++++++++-- .../.github/workflows/cd.yaml | 50 ----------- .../.github/workflows/checks.yaml | 82 ------------------- .../.github/workflows/pr.yaml | 8 -- ...duction-puya-smart-contract-python-cd.yaml | 48 +++++++++++ ...duction-puya-smart-contract-python-ci.yaml | 60 ++++++++++++++ .../Build_Beaker_application.xml | 35 ++++++++ .../Build_Beaker_application____LocalNet.xml | 37 +++++++++ .../Build___Deploy_Beaker_application.xml | 38 +++++++++ .../Deploy_Built_Beaker_application.xml | 36 ++++++++ .../Reset_AlgoKit_LocalNet.xml | 17 ++++ .../Start_AlgoKit_LocalNet.xml | 17 ++++ .../Stop_AlgoKit_LocalNet.xml | 17 ++++ .../.algokit.toml | 46 +++++++++-- .../.github/workflows/checks.yaml | 76 ----------------- .../.github/workflows/pr.yaml | 8 -- ...ion-puya-smart-contract-typescript-cd.yaml | 48 +++++++++++ ...ion-puya-smart-contract-typescript-ci.yaml | 60 ++++++++++++++ .../Build_Beaker_application.xml | 35 ++++++++ .../Build_Beaker_application____LocalNet.xml | 37 +++++++++ .../Build___Deploy_Beaker_application.xml | 18 ++++ .../Deploy_Built_Beaker_application.xml | 16 ++++ .../Reset_AlgoKit_LocalNet.xml | 17 ++++ .../Start_AlgoKit_LocalNet.xml | 17 ++++ .../Stop_AlgoKit_LocalNet.xml | 17 ++++ .../.algokit.toml | 35 ++++++-- .../.github/workflows/cd.yaml | 50 ----------- .../.github/workflows/checks.yaml | 76 ----------------- .../.github/workflows/pr.yaml | 8 -- .../.pre-commit-config.yaml | 48 ----------- .../.vscode/extensions.json | 3 - .../.vscode/settings.json | 20 +---- .../README.md | 55 +------------ .../pyproject.toml | 26 ------ .../.algokit.toml | 35 ++++++-- .../.github/workflows/cd.yaml | 50 ----------- .../.github/workflows/checks.yaml | 76 ----------------- .../.github/workflows/pr.yaml | 8 -- .../.pre-commit-config.yaml | 48 ----------- .../.vscode/extensions.json | 3 - .../.vscode/settings.json | 20 +---- .../README.md | 55 +------------ .../pyproject.toml | 26 ------ examples/production_puya/.algokit.toml | 46 +++++++++-- .../production_puya/.github/workflows/cd.yaml | 50 ----------- .../.github/workflows/checks.yaml | 82 ------------------- .../production_puya/.github/workflows/pr.yaml | 8 -- .../workflows/production-puya-cd.yaml} | 34 ++++---- .../.github/workflows/production-puya-ci.yaml | 60 ++++++++++++++ .../Build_Beaker_application.xml | 35 ++++++++ .../Build_Beaker_application____LocalNet.xml | 37 +++++++++ .../Build___Deploy_Beaker_application.xml | 38 +++++++++ .../Deploy_Built_Beaker_application.xml | 36 ++++++++ .../Reset_AlgoKit_LocalNet.xml | 17 ++++ .../Start_AlgoKit_LocalNet.xml | 17 ++++ .../Stop_AlgoKit_LocalNet.xml | 17 ++++ examples/starter_puya/.algokit.toml | 35 ++++++-- .../starter_puya/.github/workflows/cd.yaml | 50 ----------- .../.github/workflows/checks.yaml | 76 ----------------- .../starter_puya/.github/workflows/pr.yaml | 8 -- examples/starter_puya/.pre-commit-config.yaml | 48 ----------- examples/starter_puya/.vscode/extensions.json | 3 - examples/starter_puya/.vscode/settings.json | 20 +---- examples/starter_puya/README.md | 55 +------------ examples/starter_puya/pyproject.toml | 26 ------ 66 files changed, 1047 insertions(+), 1279 deletions(-) delete mode 100644 examples/generators/.gitkeep delete mode 100644 examples/generators/production_puya_smart_contract_python/.github/workflows/cd.yaml delete mode 100644 examples/generators/production_puya_smart_contract_python/.github/workflows/checks.yaml delete mode 100644 examples/generators/production_puya_smart_contract_python/.github/workflows/pr.yaml create mode 100644 examples/generators/production_puya_smart_contract_python/.github/workflows/production-puya-smart-contract-python-cd.yaml create mode 100644 examples/generators/production_puya_smart_contract_python/.github/workflows/production-puya-smart-contract-python-ci.yaml create mode 100644 examples/generators/production_puya_smart_contract_python/.idea/runConfigurations/Build_Beaker_application.xml create mode 100644 examples/generators/production_puya_smart_contract_python/.idea/runConfigurations/Build_Beaker_application____LocalNet.xml create mode 100644 examples/generators/production_puya_smart_contract_python/.idea/runConfigurations/Build___Deploy_Beaker_application.xml create mode 100644 examples/generators/production_puya_smart_contract_python/.idea/runConfigurations/Deploy_Built_Beaker_application.xml create mode 100644 examples/generators/production_puya_smart_contract_python/.idea/runConfigurations/Reset_AlgoKit_LocalNet.xml create mode 100644 examples/generators/production_puya_smart_contract_python/.idea/runConfigurations/Start_AlgoKit_LocalNet.xml create mode 100644 examples/generators/production_puya_smart_contract_python/.idea/runConfigurations/Stop_AlgoKit_LocalNet.xml delete mode 100644 examples/generators/production_puya_smart_contract_typescript/.github/workflows/checks.yaml delete mode 100644 examples/generators/production_puya_smart_contract_typescript/.github/workflows/pr.yaml create mode 100644 examples/generators/production_puya_smart_contract_typescript/.github/workflows/production-puya-smart-contract-typescript-cd.yaml create mode 100644 examples/generators/production_puya_smart_contract_typescript/.github/workflows/production-puya-smart-contract-typescript-ci.yaml create mode 100644 examples/generators/production_puya_smart_contract_typescript/.idea/runConfigurations/Build_Beaker_application.xml create mode 100644 examples/generators/production_puya_smart_contract_typescript/.idea/runConfigurations/Build_Beaker_application____LocalNet.xml create mode 100644 examples/generators/production_puya_smart_contract_typescript/.idea/runConfigurations/Build___Deploy_Beaker_application.xml create mode 100644 examples/generators/production_puya_smart_contract_typescript/.idea/runConfigurations/Deploy_Built_Beaker_application.xml create mode 100644 examples/generators/production_puya_smart_contract_typescript/.idea/runConfigurations/Reset_AlgoKit_LocalNet.xml create mode 100644 examples/generators/production_puya_smart_contract_typescript/.idea/runConfigurations/Start_AlgoKit_LocalNet.xml create mode 100644 examples/generators/production_puya_smart_contract_typescript/.idea/runConfigurations/Stop_AlgoKit_LocalNet.xml delete mode 100644 examples/generators/starter_puya_smart_contract_python/.github/workflows/cd.yaml delete mode 100644 examples/generators/starter_puya_smart_contract_python/.github/workflows/checks.yaml delete mode 100644 examples/generators/starter_puya_smart_contract_python/.github/workflows/pr.yaml delete mode 100644 examples/generators/starter_puya_smart_contract_python/.pre-commit-config.yaml delete mode 100644 examples/generators/starter_puya_smart_contract_typescript/.github/workflows/cd.yaml delete mode 100644 examples/generators/starter_puya_smart_contract_typescript/.github/workflows/checks.yaml delete mode 100644 examples/generators/starter_puya_smart_contract_typescript/.github/workflows/pr.yaml delete mode 100644 examples/generators/starter_puya_smart_contract_typescript/.pre-commit-config.yaml delete mode 100644 examples/production_puya/.github/workflows/cd.yaml delete mode 100644 examples/production_puya/.github/workflows/checks.yaml delete mode 100644 examples/production_puya/.github/workflows/pr.yaml rename examples/{generators/production_puya_smart_contract_typescript/.github/workflows/cd.yaml => production_puya/.github/workflows/production-puya-cd.yaml} (52%) create mode 100644 examples/production_puya/.github/workflows/production-puya-ci.yaml create mode 100644 examples/production_puya/.idea/runConfigurations/Build_Beaker_application.xml create mode 100644 examples/production_puya/.idea/runConfigurations/Build_Beaker_application____LocalNet.xml create mode 100644 examples/production_puya/.idea/runConfigurations/Build___Deploy_Beaker_application.xml create mode 100644 examples/production_puya/.idea/runConfigurations/Deploy_Built_Beaker_application.xml create mode 100644 examples/production_puya/.idea/runConfigurations/Reset_AlgoKit_LocalNet.xml create mode 100644 examples/production_puya/.idea/runConfigurations/Start_AlgoKit_LocalNet.xml create mode 100644 examples/production_puya/.idea/runConfigurations/Stop_AlgoKit_LocalNet.xml delete mode 100644 examples/starter_puya/.github/workflows/cd.yaml delete mode 100644 examples/starter_puya/.github/workflows/checks.yaml delete mode 100644 examples/starter_puya/.github/workflows/pr.yaml delete mode 100644 examples/starter_puya/.pre-commit-config.yaml diff --git a/examples/generators/.gitkeep b/examples/generators/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/examples/generators/production_puya_smart_contract_python/.algokit.toml b/examples/generators/production_puya_smart_contract_python/.algokit.toml index 40742c4..3cf5b6a 100644 --- a/examples/generators/production_puya_smart_contract_python/.algokit.toml +++ b/examples/generators/production_puya_smart_contract_python/.algokit.toml @@ -1,19 +1,49 @@ [algokit] min_version = "v1.8.0" -[deploy] +[generate.smart_contract] +description = "Adds new smart contract to existing project" +path = ".algokit/generators/create_contract" + +[project] +type = 'contract' +name = 'production_puya_smart_contract_python' +artifacts = 'smart_contracts/artifacts' + +[project.deploy] command = "poetry run python -m smart_contracts deploy" environment_secrets = [ "DEPLOYER_MNEMONIC", + "DISPENSER_MNEMONIC", ] -[deploy.localnet] +[project.deploy.localnet] environment_secrets = [] -[generate.smart_contract] -description = "Adds new smart contract to existing project" -path = ".algokit/generators/create_contract" +[project.run] +# Commands intented for use locally and in CI +build = { commands = [ + 'poetry run python -m smart_contracts build', +], description = 'Build all smart contracts in the project' } +test = { commands = [ + 'poetry run pytest', +], description = 'Run smart contract tests' } +audit = { commands = [ + 'poetry export --without=dev -o requirements.txt', + 'poetry run pip-audit -r requirements.txt', +], description = 'Audit with pip-audit' } +lint = { commands = [ + 'poetry run black --check .', + 'poetry run ruff .', + 'poetry run mypy', +], description = 'Perform linting' } +audit-teal = { commands = [ + # 🚨 IMPORTANT 🚨: For strict TEAL validation, remove --exclude statements. The default starter contract is not for production. Ensure thorough testing and adherence to best practices in smart contract development. This is not a replacement for a professional audit. + 'algokit task analyze smart_contracts/artifacts --recursive --force --exclude rekey-to --exclude is-updatable --exclude missing-fee-check --exclude is-deletable --exclude can-close-asset --exclude can-close-account --exclude unprotected-deletable --exclude unprotected-updatable', +], description = 'Audit TEAL files' } -[project] -type = 'contract' -name = 'production_puya_smart_contract_python' +# Commands indented for CI only, prefixed with `ci-` by convention +ci-teal-diff = { commands = [ + 'git add -N ./smart_contracts/artifacts', + 'git diff --exit-code --minimal ./smart_contracts/artifacts', +], description = 'Check TEAL files for differences' } diff --git a/examples/generators/production_puya_smart_contract_python/.github/workflows/cd.yaml b/examples/generators/production_puya_smart_contract_python/.github/workflows/cd.yaml deleted file mode 100644 index 2401bf4..0000000 --- a/examples/generators/production_puya_smart_contract_python/.github/workflows/cd.yaml +++ /dev/null @@ -1,50 +0,0 @@ -name: Continuous Delivery of Smart Contract - -on: - push: - branches: - - main - -concurrency: release - -jobs: - ci-check: - name: Perform Checks - uses: ./.github/workflows/checks.yaml - - deploy-testnet: - runs-on: 'ubuntu-latest' - needs: ci-check - environment: Test - steps: - - name: Checkout source code - uses: actions/checkout@v4 - - - name: Install poetry - run: pipx install poetry - - - name: Set up Python 3.12 - uses: actions/setup-python@v5 - with: - python-version: '3.12' - cache: 'poetry' - - - name: Install algokit - run: pipx install algokit - - - name: Bootstrap dependencies - run: algokit bootstrap all - - - name: Configure git - shell: bash - run: | - # set git user and email as test invoke git - git config --global user.email "actions@github.com" && git config --global user.name "github-actions" - - - name: Deploy to testnet - run: algokit deploy testnet - env: - # This is the account that becomes the creator of the contract. - # Since we are not using the optional dispenser account (via DISPENSER_MNEMONIC), - # it must also be funded with enough Algos to deploy and fund the smart contracts created - DEPLOYER_MNEMONIC: ${{ secrets.DEPLOYER_MNEMONIC }} diff --git a/examples/generators/production_puya_smart_contract_python/.github/workflows/checks.yaml b/examples/generators/production_puya_smart_contract_python/.github/workflows/checks.yaml deleted file mode 100644 index 3415368..0000000 --- a/examples/generators/production_puya_smart_contract_python/.github/workflows/checks.yaml +++ /dev/null @@ -1,82 +0,0 @@ -name: Check code base - -on: - workflow_call: - -jobs: - checks: - runs-on: 'ubuntu-latest' - steps: - - name: Checkout source code - uses: actions/checkout@v4 - - - name: Install poetry - run: pipx install poetry - - - name: Set up Python 3.12 - uses: actions/setup-python@v5 - with: - python-version: '3.12' - cache: 'poetry' - - - name: Install algokit - run: pipx install algokit - - - name: Start LocalNet - run: algokit localnet start - - - name: Bootstrap dependencies - run: algokit bootstrap all - - - name: Configure git - shell: bash - run: | - # set git user and email as test invoke git - git config --global user.email "actions@github.com" && git config --global user.name "github-actions" - - - name: Audit with pip-audit - run: | - # audit non dev dependencies, no exclusions - poetry export --without=dev > requirements.txt && poetry run pip-audit -r requirements.txt - - # audit all dependencies, with exclusions. - # If a vulnerability is found in a dev dependency without an available fix, - # it can be temporarily ignored by adding --ignore-vuln e.g. - # --ignore-vuln "GHSA-hcpj-qp55-gfph" # GitPython vulnerability, dev only dependency - poetry run pip-audit - - - name: Check formatting with Black - run: | - # stop the build if there are files that don't meet formatting requirements - poetry run black --check . - - - name: Check linting with Ruff - run: | - # stop the build if there are Python syntax errors or undefined names - poetry run ruff . - - - name: Check types with mypy - run: poetry run mypy - - - name: Run tests - shell: bash - run: | - set -o pipefail - poetry run pytest --junitxml=pytest-junit.xml - - - name: Build smart contracts - run: poetry run python -m smart_contracts build - - - name: Scan TEAL files for issues - run: algokit task analyze .algokit --recursive --force # add --diff flag if you want output stability checks instead - - - name: Check output stability of the smart contracts - shell: bash - run: | - # Add untracked files as empty so they come up in diff - git add -N ./smart_contracts/artifacts - # Error out if there are any changes in teal after generating output - git diff --exit-code --minimal ./smart_contracts/artifacts || (echo "::error ::Smart contract artifacts have changed, ensure committed artifacts are up to date" && exit 1); - - - name: Run deployer against LocalNet - run: poetry run python -m smart_contracts deploy diff --git a/examples/generators/production_puya_smart_contract_python/.github/workflows/pr.yaml b/examples/generators/production_puya_smart_contract_python/.github/workflows/pr.yaml deleted file mode 100644 index a80f784..0000000 --- a/examples/generators/production_puya_smart_contract_python/.github/workflows/pr.yaml +++ /dev/null @@ -1,8 +0,0 @@ -name: Pull Request validation - -on: [pull_request] - -jobs: - pr-check: - name: Perform Checks - uses: ./.github/workflows/checks.yaml diff --git a/examples/generators/production_puya_smart_contract_python/.github/workflows/production-puya-smart-contract-python-cd.yaml b/examples/generators/production_puya_smart_contract_python/.github/workflows/production-puya-smart-contract-python-cd.yaml new file mode 100644 index 0000000..274433c --- /dev/null +++ b/examples/generators/production_puya_smart_contract_python/.github/workflows/production-puya-smart-contract-python-cd.yaml @@ -0,0 +1,48 @@ +name: Release production_puya_smart_contract_python + +on: + workflow_call: + push: + branches: + - main + +jobs: + validate: + name: Validate production_puya_smart_contract_python + uses: ./.github/workflows/production-puya-smart-contract-python-ci.yaml + deploy-testnet: + runs-on: "ubuntu-latest" + needs: validate + environment: contract-testnet + steps: + - name: Checkout source code + uses: actions/checkout@v4 + + - name: Install poetry + run: pipx install poetry + + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: "3.12" + cache: "poetry" + + - name: Install algokit + run: pipx install git+https://github.com/algorandfoundation/algokit-cli@feat/orchestration-linking + + - name: Bootstrap dependencies + run: algokit bootstrap all --project-name 'production_puya_smart_contract_python' + + - name: Configure git + shell: bash + run: | + # set git user and email as test invoke git + git config --global user.email "actions@github.com" && git config --global user.name "github-actions" + + - name: Deploy to testnet + run: algokit deploy testnet --project-name 'production_puya_smart_contract_python' + env: + # This is the account that becomes the creator of the contract + DEPLOYER_MNEMONIC: ${{ secrets.DEPLOYER_MNEMONIC }} + # The dispenser account is used to ensure the deployer account is funded + DISPENSER_MNEMONIC: ${{ secrets.DISPENSER_MNEMONIC }} diff --git a/examples/generators/production_puya_smart_contract_python/.github/workflows/production-puya-smart-contract-python-ci.yaml b/examples/generators/production_puya_smart_contract_python/.github/workflows/production-puya-smart-contract-python-ci.yaml new file mode 100644 index 0000000..9088486 --- /dev/null +++ b/examples/generators/production_puya_smart_contract_python/.github/workflows/production-puya-smart-contract-python-ci.yaml @@ -0,0 +1,60 @@ +name: Validate production_puya_smart_contract_python + +on: + workflow_call: + pull_request: + +jobs: + validate: + runs-on: "ubuntu-latest" + steps: + - name: Checkout source code + uses: actions/checkout@v4 + + - name: Install poetry + run: pipx install poetry + + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: "3.12" + cache: "poetry" + + - name: Install algokit + run: pipx install git+https://github.com/algorandfoundation/algokit-cli@feat/orchestration-linking + + - name: Start LocalNet + run: algokit localnet start + + - name: Bootstrap dependencies + run: algokit bootstrap all --project-name 'production_puya_smart_contract_python' + + - name: Configure git + shell: bash + run: | + # set git user and email as test invoke git + git config --global user.email "actions@github.com" && git config --global user.name "github-actions" + + - name: Audit python dependencies + run: algokit project run audit --project-name 'production_puya_smart_contract_python' + + - name: Lint and format python dependencies + run: algokit project run lint --project-name 'production_puya_smart_contract_python' + + - name: Run tests + shell: bash + run: | + set -o pipefail + algokit project run test --project-name 'production_puya_smart_contract_python' + + - name: Build smart contracts + run: algokit project run build --project-name 'production_puya_smart_contract_python' + + - name: Scan TEAL files for issues + run: algokit project run audit-teal --project-name 'production_puya_smart_contract_python' + + - name: Check output stability of the smart contracts + run: algokit project run ci-teal-diff --project-name 'production_puya_smart_contract_python' + + - name: Run deployer against LocalNet + run: algokit project deploy localnet --project-name 'production_puya_smart_contract_python' diff --git a/examples/generators/production_puya_smart_contract_python/.idea/runConfigurations/Build_Beaker_application.xml b/examples/generators/production_puya_smart_contract_python/.idea/runConfigurations/Build_Beaker_application.xml new file mode 100644 index 0000000..e804ef0 --- /dev/null +++ b/examples/generators/production_puya_smart_contract_python/.idea/runConfigurations/Build_Beaker_application.xml @@ -0,0 +1,35 @@ + + + + + diff --git a/examples/generators/production_puya_smart_contract_python/.idea/runConfigurations/Build_Beaker_application____LocalNet.xml b/examples/generators/production_puya_smart_contract_python/.idea/runConfigurations/Build_Beaker_application____LocalNet.xml new file mode 100644 index 0000000..34d077c --- /dev/null +++ b/examples/generators/production_puya_smart_contract_python/.idea/runConfigurations/Build_Beaker_application____LocalNet.xml @@ -0,0 +1,37 @@ + + + + + diff --git a/examples/generators/production_puya_smart_contract_python/.idea/runConfigurations/Build___Deploy_Beaker_application.xml b/examples/generators/production_puya_smart_contract_python/.idea/runConfigurations/Build___Deploy_Beaker_application.xml new file mode 100644 index 0000000..6e595f7 --- /dev/null +++ b/examples/generators/production_puya_smart_contract_python/.idea/runConfigurations/Build___Deploy_Beaker_application.xml @@ -0,0 +1,38 @@ + + + + + diff --git a/examples/generators/production_puya_smart_contract_python/.idea/runConfigurations/Deploy_Built_Beaker_application.xml b/examples/generators/production_puya_smart_contract_python/.idea/runConfigurations/Deploy_Built_Beaker_application.xml new file mode 100644 index 0000000..5f25adf --- /dev/null +++ b/examples/generators/production_puya_smart_contract_python/.idea/runConfigurations/Deploy_Built_Beaker_application.xml @@ -0,0 +1,36 @@ + + + + + diff --git a/examples/generators/production_puya_smart_contract_python/.idea/runConfigurations/Reset_AlgoKit_LocalNet.xml b/examples/generators/production_puya_smart_contract_python/.idea/runConfigurations/Reset_AlgoKit_LocalNet.xml new file mode 100644 index 0000000..7f1236a --- /dev/null +++ b/examples/generators/production_puya_smart_contract_python/.idea/runConfigurations/Reset_AlgoKit_LocalNet.xml @@ -0,0 +1,17 @@ + + + + diff --git a/examples/generators/production_puya_smart_contract_python/.idea/runConfigurations/Start_AlgoKit_LocalNet.xml b/examples/generators/production_puya_smart_contract_python/.idea/runConfigurations/Start_AlgoKit_LocalNet.xml new file mode 100644 index 0000000..f699a7a --- /dev/null +++ b/examples/generators/production_puya_smart_contract_python/.idea/runConfigurations/Start_AlgoKit_LocalNet.xml @@ -0,0 +1,17 @@ + + + + diff --git a/examples/generators/production_puya_smart_contract_python/.idea/runConfigurations/Stop_AlgoKit_LocalNet.xml b/examples/generators/production_puya_smart_contract_python/.idea/runConfigurations/Stop_AlgoKit_LocalNet.xml new file mode 100644 index 0000000..e510cbc --- /dev/null +++ b/examples/generators/production_puya_smart_contract_python/.idea/runConfigurations/Stop_AlgoKit_LocalNet.xml @@ -0,0 +1,17 @@ + + + + diff --git a/examples/generators/production_puya_smart_contract_typescript/.algokit.toml b/examples/generators/production_puya_smart_contract_typescript/.algokit.toml index 736d491..19ce2e7 100644 --- a/examples/generators/production_puya_smart_contract_typescript/.algokit.toml +++ b/examples/generators/production_puya_smart_contract_typescript/.algokit.toml @@ -1,19 +1,49 @@ [algokit] min_version = "v1.8.0" -[deploy] +[generate.smart_contract] +description = "Adds new smart contract to existing project" +path = ".algokit/generators/create_contract" + +[project] +type = 'contract' +name = 'production_puya_smart_contract_typescript' +artifacts = 'smart_contracts/artifacts' + +[project.deploy] command = "npm run deploy:ci" environment_secrets = [ "DEPLOYER_MNEMONIC", + "DISPENSER_MNEMONIC", ] -[deploy.localnet] +[project.deploy.localnet] environment_secrets = [] -[generate.smart_contract] -description = "Adds new smart contract to existing project" -path = ".algokit/generators/create_contract" +[project.run] +# Commands intented for use locally and in CI +build = { commands = [ + 'npm run build', +], description = 'Build all smart contracts in the project' } +test = { commands = [ + 'npm run test', +], description = 'Run smart contract tests using Jest' } +audit = { commands = [ + 'poetry export --without=dev -o requirements.txt', + 'poetry run pip-audit -r requirements.txt', +], description = 'Audit with pip-audit' } +lint = { commands = [ + 'poetry run black --check .', + 'poetry run ruff .', + 'poetry run mypy', +], description = 'Perform linting' } +audit-teal = { commands = [ + # 🚨 IMPORTANT 🚨: For strict TEAL validation, remove --exclude statements. The default starter contract is not for production. Ensure thorough testing and adherence to best practices in smart contract development. This is not a replacement for a professional audit. + 'algokit task analyze smart_contracts/artifacts --recursive --force --exclude rekey-to --exclude is-updatable --exclude missing-fee-check --exclude is-deletable --exclude can-close-asset --exclude can-close-account --exclude unprotected-deletable --exclude unprotected-updatable', +], description = 'Audit TEAL files' } -[project] -type = 'contract' -name = 'production_puya_smart_contract_typescript' +# Commands indented for CI only, prefixed with `ci-` by convention +ci-teal-diff = { commands = [ + 'git add -N ./smart_contracts/artifacts', + 'git diff --exit-code --minimal ./smart_contracts/artifacts', +], description = 'Check TEAL files for differences' } diff --git a/examples/generators/production_puya_smart_contract_typescript/.github/workflows/checks.yaml b/examples/generators/production_puya_smart_contract_typescript/.github/workflows/checks.yaml deleted file mode 100644 index 3994f5d..0000000 --- a/examples/generators/production_puya_smart_contract_typescript/.github/workflows/checks.yaml +++ /dev/null @@ -1,76 +0,0 @@ -name: Check code base - -on: - workflow_call: - -jobs: - checks: - runs-on: 'ubuntu-latest' - steps: - - name: Checkout source code - uses: actions/checkout@v4 - - - name: Install poetry - run: pipx install poetry - - - name: Set up Python 3.12 - uses: actions/setup-python@v5 - with: - python-version: '3.12' - cache: 'poetry' - - - name: Install algokit - run: pipx install algokit - - - name: Start LocalNet - run: algokit localnet start - - - name: Bootstrap dependencies - run: algokit bootstrap all - - - name: Configure git - shell: bash - run: | - # set git user and email as test invoke git - git config --global user.email "actions@github.com" && git config --global user.name "github-actions" - - - name: Audit with pip-audit - run: | - # audit non dev dependencies, no exclusions - poetry export --without=dev > requirements.txt && poetry run pip-audit -r requirements.txt - - # audit all dependencies, with exclusions. - # If a vulnerability is found in a dev dependency without an available fix, - # it can be temporarily ignored by adding --ignore-vuln e.g. - # --ignore-vuln "GHSA-hcpj-qp55-gfph" # GitPython vulnerability, dev only dependency - poetry run pip-audit - - - name: Check formatting with Black - run: | - # stop the build if there are files that don't meet formatting requirements - poetry run black --check . - - - name: Check linting with Ruff - run: | - # stop the build if there are Python syntax errors or undefined names - poetry run ruff . - - - name: Check types with mypy - run: poetry run mypy - - - name: Build smart contracts - run: poetry run python -m smart_contracts build - - - name: Scan TEAL files for issues - run: algokit task analyze .algokit --recursive --force # add --diff flag if you want output stability checks instead - - - name: Check output stability of the smart contracts - shell: bash - run: | - # Add untracked files as empty so they come up in diff - git add -N ./smart_contracts/artifacts - # Error out if there are any changes in teal after generating output - git diff --exit-code --minimal ./smart_contracts/artifacts || (echo "::error ::Smart contract artifacts have changed, ensure committed artifacts are up to date" && exit 1); - - - name: Run deployer against LocalNet - run: npm run --prefix smart_contracts deploy:ci diff --git a/examples/generators/production_puya_smart_contract_typescript/.github/workflows/pr.yaml b/examples/generators/production_puya_smart_contract_typescript/.github/workflows/pr.yaml deleted file mode 100644 index a80f784..0000000 --- a/examples/generators/production_puya_smart_contract_typescript/.github/workflows/pr.yaml +++ /dev/null @@ -1,8 +0,0 @@ -name: Pull Request validation - -on: [pull_request] - -jobs: - pr-check: - name: Perform Checks - uses: ./.github/workflows/checks.yaml diff --git a/examples/generators/production_puya_smart_contract_typescript/.github/workflows/production-puya-smart-contract-typescript-cd.yaml b/examples/generators/production_puya_smart_contract_typescript/.github/workflows/production-puya-smart-contract-typescript-cd.yaml new file mode 100644 index 0000000..eb10c65 --- /dev/null +++ b/examples/generators/production_puya_smart_contract_typescript/.github/workflows/production-puya-smart-contract-typescript-cd.yaml @@ -0,0 +1,48 @@ +name: Release production_puya_smart_contract_typescript + +on: + workflow_call: + push: + branches: + - main + +jobs: + validate: + name: Validate production_puya_smart_contract_typescript + uses: ./.github/workflows/production-puya-smart-contract-typescript-ci.yaml + deploy-testnet: + runs-on: "ubuntu-latest" + needs: validate + environment: contract-testnet + steps: + - name: Checkout source code + uses: actions/checkout@v4 + + - name: Install poetry + run: pipx install poetry + + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: "3.12" + cache: "poetry" + + - name: Install algokit + run: pipx install git+https://github.com/algorandfoundation/algokit-cli@feat/orchestration-linking + + - name: Bootstrap dependencies + run: algokit bootstrap all --project-name 'production_puya_smart_contract_typescript' + + - name: Configure git + shell: bash + run: | + # set git user and email as test invoke git + git config --global user.email "actions@github.com" && git config --global user.name "github-actions" + + - name: Deploy to testnet + run: algokit deploy testnet --project-name 'production_puya_smart_contract_typescript' + env: + # This is the account that becomes the creator of the contract + DEPLOYER_MNEMONIC: ${{ secrets.DEPLOYER_MNEMONIC }} + # The dispenser account is used to ensure the deployer account is funded + DISPENSER_MNEMONIC: ${{ secrets.DISPENSER_MNEMONIC }} diff --git a/examples/generators/production_puya_smart_contract_typescript/.github/workflows/production-puya-smart-contract-typescript-ci.yaml b/examples/generators/production_puya_smart_contract_typescript/.github/workflows/production-puya-smart-contract-typescript-ci.yaml new file mode 100644 index 0000000..7671147 --- /dev/null +++ b/examples/generators/production_puya_smart_contract_typescript/.github/workflows/production-puya-smart-contract-typescript-ci.yaml @@ -0,0 +1,60 @@ +name: Validate production_puya_smart_contract_typescript + +on: + workflow_call: + pull_request: + +jobs: + validate: + runs-on: "ubuntu-latest" + steps: + - name: Checkout source code + uses: actions/checkout@v4 + + - name: Install poetry + run: pipx install poetry + + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: "3.12" + cache: "poetry" + + - name: Install algokit + run: pipx install git+https://github.com/algorandfoundation/algokit-cli@feat/orchestration-linking + + - name: Start LocalNet + run: algokit localnet start + + - name: Bootstrap dependencies + run: algokit bootstrap all --project-name 'production_puya_smart_contract_typescript' + + - name: Configure git + shell: bash + run: | + # set git user and email as test invoke git + git config --global user.email "actions@github.com" && git config --global user.name "github-actions" + + - name: Audit python dependencies + run: algokit project run audit --project-name 'production_puya_smart_contract_typescript' + + - name: Lint and format python dependencies + run: algokit project run lint --project-name 'production_puya_smart_contract_typescript' + + - name: Run tests + shell: bash + run: | + set -o pipefail + algokit project run test --project-name 'production_puya_smart_contract_typescript' + + - name: Build smart contracts + run: algokit project run build --project-name 'production_puya_smart_contract_typescript' + + - name: Scan TEAL files for issues + run: algokit project run audit-teal --project-name 'production_puya_smart_contract_typescript' + + - name: Check output stability of the smart contracts + run: algokit project run ci-teal-diff --project-name 'production_puya_smart_contract_typescript' + + - name: Run deployer against LocalNet + run: algokit project deploy localnet --project-name 'production_puya_smart_contract_typescript' diff --git a/examples/generators/production_puya_smart_contract_typescript/.idea/runConfigurations/Build_Beaker_application.xml b/examples/generators/production_puya_smart_contract_typescript/.idea/runConfigurations/Build_Beaker_application.xml new file mode 100644 index 0000000..e114a2c --- /dev/null +++ b/examples/generators/production_puya_smart_contract_typescript/.idea/runConfigurations/Build_Beaker_application.xml @@ -0,0 +1,35 @@ + + + + + diff --git a/examples/generators/production_puya_smart_contract_typescript/.idea/runConfigurations/Build_Beaker_application____LocalNet.xml b/examples/generators/production_puya_smart_contract_typescript/.idea/runConfigurations/Build_Beaker_application____LocalNet.xml new file mode 100644 index 0000000..41df675 --- /dev/null +++ b/examples/generators/production_puya_smart_contract_typescript/.idea/runConfigurations/Build_Beaker_application____LocalNet.xml @@ -0,0 +1,37 @@ + + + + + diff --git a/examples/generators/production_puya_smart_contract_typescript/.idea/runConfigurations/Build___Deploy_Beaker_application.xml b/examples/generators/production_puya_smart_contract_typescript/.idea/runConfigurations/Build___Deploy_Beaker_application.xml new file mode 100644 index 0000000..0091510 --- /dev/null +++ b/examples/generators/production_puya_smart_contract_typescript/.idea/runConfigurations/Build___Deploy_Beaker_application.xml @@ -0,0 +1,18 @@ + + + + diff --git a/examples/generators/production_puya_smart_contract_typescript/.idea/runConfigurations/Deploy_Built_Beaker_application.xml b/examples/generators/production_puya_smart_contract_typescript/.idea/runConfigurations/Deploy_Built_Beaker_application.xml new file mode 100644 index 0000000..17b8154 --- /dev/null +++ b/examples/generators/production_puya_smart_contract_typescript/.idea/runConfigurations/Deploy_Built_Beaker_application.xml @@ -0,0 +1,16 @@ + + + + diff --git a/examples/generators/production_puya_smart_contract_typescript/.idea/runConfigurations/Reset_AlgoKit_LocalNet.xml b/examples/generators/production_puya_smart_contract_typescript/.idea/runConfigurations/Reset_AlgoKit_LocalNet.xml new file mode 100644 index 0000000..7f1236a --- /dev/null +++ b/examples/generators/production_puya_smart_contract_typescript/.idea/runConfigurations/Reset_AlgoKit_LocalNet.xml @@ -0,0 +1,17 @@ + + + + diff --git a/examples/generators/production_puya_smart_contract_typescript/.idea/runConfigurations/Start_AlgoKit_LocalNet.xml b/examples/generators/production_puya_smart_contract_typescript/.idea/runConfigurations/Start_AlgoKit_LocalNet.xml new file mode 100644 index 0000000..f699a7a --- /dev/null +++ b/examples/generators/production_puya_smart_contract_typescript/.idea/runConfigurations/Start_AlgoKit_LocalNet.xml @@ -0,0 +1,17 @@ + + + + diff --git a/examples/generators/production_puya_smart_contract_typescript/.idea/runConfigurations/Stop_AlgoKit_LocalNet.xml b/examples/generators/production_puya_smart_contract_typescript/.idea/runConfigurations/Stop_AlgoKit_LocalNet.xml new file mode 100644 index 0000000..e510cbc --- /dev/null +++ b/examples/generators/production_puya_smart_contract_typescript/.idea/runConfigurations/Stop_AlgoKit_LocalNet.xml @@ -0,0 +1,17 @@ + + + + diff --git a/examples/generators/starter_puya_smart_contract_python/.algokit.toml b/examples/generators/starter_puya_smart_contract_python/.algokit.toml index cdcf495..e63b725 100644 --- a/examples/generators/starter_puya_smart_contract_python/.algokit.toml +++ b/examples/generators/starter_puya_smart_contract_python/.algokit.toml @@ -1,19 +1,38 @@ [algokit] min_version = "v1.8.0" -[deploy] +[generate.smart_contract] +description = "Adds new smart contract to existing project" +path = ".algokit/generators/create_contract" + +[project] +type = 'contract' +name = 'starter_puya_smart_contract_python' +artifacts = 'smart_contracts/artifacts' + +[project.deploy] command = "poetry run python -m smart_contracts deploy" environment_secrets = [ "DEPLOYER_MNEMONIC", ] -[deploy.localnet] +[project.deploy.localnet] environment_secrets = [] -[generate.smart_contract] -description = "Adds new smart contract to existing project" -path = ".algokit/generators/create_contract" +[project.run] +# Commands intented for use locally and in CI +build = { commands = [ + 'poetry run python -m smart_contracts build', +], description = 'Build all smart contracts in the project' } +lint = { commands = [ +], description = 'Perform linting' } +audit-teal = { commands = [ + # 🚨 IMPORTANT 🚨: For strict TEAL validation, remove --exclude statements. The default starter contract is not for production. Ensure thorough testing and adherence to best practices in smart contract development. This is not a replacement for a professional audit. + 'algokit task analyze smart_contracts/artifacts --recursive --force --exclude rekey-to --exclude is-updatable --exclude missing-fee-check --exclude is-deletable --exclude can-close-asset --exclude can-close-account --exclude unprotected-deletable --exclude unprotected-updatable', +], description = 'Audit TEAL files' } -[project] -type = 'contract' -name = 'starter_puya_smart_contract_python' +# Commands indented for CI only, prefixed with `ci-` by convention +ci-teal-diff = { commands = [ + 'git add -N ./smart_contracts/artifacts', + 'git diff --exit-code --minimal ./smart_contracts/artifacts', +], description = 'Check TEAL files for differences' } diff --git a/examples/generators/starter_puya_smart_contract_python/.github/workflows/cd.yaml b/examples/generators/starter_puya_smart_contract_python/.github/workflows/cd.yaml deleted file mode 100644 index 2401bf4..0000000 --- a/examples/generators/starter_puya_smart_contract_python/.github/workflows/cd.yaml +++ /dev/null @@ -1,50 +0,0 @@ -name: Continuous Delivery of Smart Contract - -on: - push: - branches: - - main - -concurrency: release - -jobs: - ci-check: - name: Perform Checks - uses: ./.github/workflows/checks.yaml - - deploy-testnet: - runs-on: 'ubuntu-latest' - needs: ci-check - environment: Test - steps: - - name: Checkout source code - uses: actions/checkout@v4 - - - name: Install poetry - run: pipx install poetry - - - name: Set up Python 3.12 - uses: actions/setup-python@v5 - with: - python-version: '3.12' - cache: 'poetry' - - - name: Install algokit - run: pipx install algokit - - - name: Bootstrap dependencies - run: algokit bootstrap all - - - name: Configure git - shell: bash - run: | - # set git user and email as test invoke git - git config --global user.email "actions@github.com" && git config --global user.name "github-actions" - - - name: Deploy to testnet - run: algokit deploy testnet - env: - # This is the account that becomes the creator of the contract. - # Since we are not using the optional dispenser account (via DISPENSER_MNEMONIC), - # it must also be funded with enough Algos to deploy and fund the smart contracts created - DEPLOYER_MNEMONIC: ${{ secrets.DEPLOYER_MNEMONIC }} diff --git a/examples/generators/starter_puya_smart_contract_python/.github/workflows/checks.yaml b/examples/generators/starter_puya_smart_contract_python/.github/workflows/checks.yaml deleted file mode 100644 index 2c75ab4..0000000 --- a/examples/generators/starter_puya_smart_contract_python/.github/workflows/checks.yaml +++ /dev/null @@ -1,76 +0,0 @@ -name: Check code base - -on: - workflow_call: - -jobs: - checks: - runs-on: 'ubuntu-latest' - steps: - - name: Checkout source code - uses: actions/checkout@v4 - - - name: Install poetry - run: pipx install poetry - - - name: Set up Python 3.12 - uses: actions/setup-python@v5 - with: - python-version: '3.12' - cache: 'poetry' - - - name: Install algokit - run: pipx install algokit - - - name: Start LocalNet - run: algokit localnet start - - - name: Bootstrap dependencies - run: algokit bootstrap all - - - name: Configure git - shell: bash - run: | - # set git user and email as test invoke git - git config --global user.email "actions@github.com" && git config --global user.name "github-actions" - - - name: Audit with pip-audit - run: | - # audit non dev dependencies, no exclusions - poetry export --without=dev > requirements.txt && poetry run pip-audit -r requirements.txt - - # audit all dependencies, with exclusions. - # If a vulnerability is found in a dev dependency without an available fix, - # it can be temporarily ignored by adding --ignore-vuln e.g. - # --ignore-vuln "GHSA-hcpj-qp55-gfph" # GitPython vulnerability, dev only dependency - poetry run pip-audit - - - name: Check formatting with Black - run: | - # stop the build if there are files that don't meet formatting requirements - poetry run black --check . - - - name: Check linting with Ruff - run: | - # stop the build if there are Python syntax errors or undefined names - poetry run ruff . - - - name: Check types with mypy - run: poetry run mypy - - - name: Build smart contracts - run: poetry run python -m smart_contracts build - - - name: Scan TEAL files for issues - run: algokit task analyze .algokit --recursive --force # add --diff flag if you want output stability checks instead - - - name: Check output stability of the smart contracts - shell: bash - run: | - # Add untracked files as empty so they come up in diff - git add -N ./smart_contracts/artifacts - # Error out if there are any changes in teal after generating output - git diff --exit-code --minimal ./smart_contracts/artifacts || (echo "::error ::Smart contract artifacts have changed, ensure committed artifacts are up to date" && exit 1); - - - name: Run deployer against LocalNet - run: poetry run python -m smart_contracts deploy diff --git a/examples/generators/starter_puya_smart_contract_python/.github/workflows/pr.yaml b/examples/generators/starter_puya_smart_contract_python/.github/workflows/pr.yaml deleted file mode 100644 index a80f784..0000000 --- a/examples/generators/starter_puya_smart_contract_python/.github/workflows/pr.yaml +++ /dev/null @@ -1,8 +0,0 @@ -name: Pull Request validation - -on: [pull_request] - -jobs: - pr-check: - name: Perform Checks - uses: ./.github/workflows/checks.yaml diff --git a/examples/generators/starter_puya_smart_contract_python/.pre-commit-config.yaml b/examples/generators/starter_puya_smart_contract_python/.pre-commit-config.yaml deleted file mode 100644 index 8862f86..0000000 --- a/examples/generators/starter_puya_smart_contract_python/.pre-commit-config.yaml +++ /dev/null @@ -1,48 +0,0 @@ -repos: - - repo: local - hooks: - - - id: black - name: black - description: "Black: The uncompromising Python code formatter" - entry: poetry run black - language: system - minimum_pre_commit_version: 2.9.2 - require_serial: true - types_or: [ python, pyi ] - - - - id: ruff - name: ruff - description: "Run 'ruff' for extremely fast Python linting" - entry: poetry run ruff - language: system - types: [ python ] - args: [ --fix ] - require_serial: false - additional_dependencies: [ ] - minimum_pre_commit_version: '0' - files: '^(src|tests)/' - - - - id: mypy - name: mypy - description: '`mypy` will check Python types for correctness' - entry: poetry run mypy - language: system - types_or: [ python, pyi ] - require_serial: true - additional_dependencies: [ ] - minimum_pre_commit_version: '2.9.2' - files: '^(src|tests)/' - - - id: tealer - name: tealer - description: "Run AlgoKit `Tealer` for TEAL static analysis" - entry: algokit - language: system - args: [task, analyze, ".algokit", "--recursive", "--force"] - require_serial: false - additional_dependencies: [] - minimum_pre_commit_version: "0" - files: '^.*\.teal$' diff --git a/examples/generators/starter_puya_smart_contract_python/.vscode/extensions.json b/examples/generators/starter_puya_smart_contract_python/.vscode/extensions.json index 1d2e7cf..e16b76b 100644 --- a/examples/generators/starter_puya_smart_contract_python/.vscode/extensions.json +++ b/examples/generators/starter_puya_smart_contract_python/.vscode/extensions.json @@ -1,9 +1,6 @@ { "recommendations": [ "ms-python.python", - "charliermarsh.ruff", - "matangover.mypy", - "ms-python.black-formatter", "tamasfe.even-better-toml", "editorconfig.editorconfig", "vsls-contrib.codetour", diff --git a/examples/generators/starter_puya_smart_contract_python/.vscode/settings.json b/examples/generators/starter_puya_smart_contract_python/.vscode/settings.json index a7b97d0..4cf6525 100644 --- a/examples/generators/starter_puya_smart_contract_python/.vscode/settings.json +++ b/examples/generators/starter_puya_smart_contract_python/.vscode/settings.json @@ -21,26 +21,8 @@ // Prevent default import sorting from running; Ruff will sort imports for us anyway "source.organizeImports": false }, - "editor.defaultFormatter": "ms-python.black-formatter", + "editor.defaultFormatter": null, }, - "black-formatter.args": ["--config=pyproject.toml"], - "ruff.enable": true, - "ruff.lint.run": "onSave", - "ruff.lint.args": ["--config=pyproject.toml"], - "ruff.importStrategy": "fromEnvironment", - "ruff.fixAll": true, //lint and fix all files in workspace - "ruff.organizeImports": true, //organize imports on save - "ruff.codeAction.disableRuleComment": { - "enable": true - }, - "ruff.codeAction.fixViolation": { - "enable": true - }, - "python.analysis.typeCheckingMode": "off", - "mypy.configFile": "pyproject.toml", - // set to empty array to use config from project - "mypy.targets": [], - "mypy.runUsingActiveInterpreter": true, // On Windows, if execution policy is set to Signed (default) then it won't be able to activate the venv // so instead let's set it to RemoteSigned for VS Code terminal diff --git a/examples/generators/starter_puya_smart_contract_python/README.md b/examples/generators/starter_puya_smart_contract_python/README.md index 0763fa5..289e400 100644 --- a/examples/generators/starter_puya_smart_contract_python/README.md +++ b/examples/generators/starter_puya_smart_contract_python/README.md @@ -46,54 +46,7 @@ This project has been generated using AlgoKit. See below for default getting sta 1. If you update to the latest source code and there are new dependencies you will need to run `algokit bootstrap all` again 2. Follow step 3 above -> For guidance on `smart_contracts` folder and adding new contracts to the project please see [README](smart_contracts/README.md) on the respective folder.### 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. - -### Debugging Smart Contracts - -This project is optimized to work with AlgoKit AVM Debugger extension. To activate it: -Refer to the commented header in the `__main__.py` file in the `smart_contracts` folder. - -If you have opted in to include VSCode launch configurations in your project, you can also use the `Debug TEAL via AlgoKit AVM Debugger` launch configuration to interactively select an available trace file and launch the debug session for your smart contract. - -For information on using and setting up the `AlgoKit AVM Debugger` VSCode extension refer [here](https://github.com/algorandfoundation/algokit-avm-vscode-debugger). To install the extension from the VSCode Marketplace, use the following link: [AlgoKit AVM Debugger extension](https://marketplace.visualstudio.com/items?itemName=algorandfoundation.algokit-avm-vscode-debugger). - -#### Setting up GitHub for CI/CD workflow and TestNet deployment - - 1. Every time you have a change to your smart contract, and when you first initialize the project you need to [build the contract](#initial-setup) and then commit the `smart_contracts/artifacts` folder so the [output stability](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/articles/output_stability.md) tests pass - 2. Decide what values you want to use for the `allow_update`, `allow_delete` and the `on_schema_break`, `on_update` parameters specified in [`contract.py`](./smart_contracts/hello_world/contract.py). - When deploying to LocalNet these values are both set to allow update and replacement of the app for convenience. But for non-LocalNet networks - the defaults are more conservative. - These default values will allow the smart contract to be deployed initially, but will not allow the app to be updated or deleted if is changed and the build will instead fail. - To help you decide it may be helpful to read the [AlgoKit Utils app deployment documentation](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/docs/capabilities/app-deploy.md) or the [AlgoKit smart contract deployment architecture](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/architecture-decisions/2023-01-12_smart-contract-deployment.md#upgradeable-and-deletable-contracts). - 3. Create a [Github Environment](https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#creating-an-environment) named `Test`. - Note: If you have a private repository and don't have GitHub Enterprise then Environments won't work and you'll need to convert the GitHub Action to use a different approach. Ignore this step if you picked `Starter` preset. - 4. Create or obtain a mnemonic for an Algorand account for use on TestNet to deploy apps, referred to as the `DEPLOYER` account. - 5. Store the mnemonic as a [secret](https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#environment-secrets) `DEPLOYER_MNEMONIC` - in the Test environment created in step 3. - 6. The account used to deploy the smart contract will require enough funds to create the app, and also fund it. There are two approaches available here: - * Either, ensure the account is funded outside of CI/CD. - In Testnet, funds can be obtained by using the [Algorand TestNet dispenser](https://bank.testnet.algorand.network/) and we recommend provisioning 50 ALGOs. - * Or, fund the account as part of the CI/CD process by using a `DISPENSER_MNEMONIC` GitHub Environment secret to point to a separate `DISPENSER` account that you maintain ALGOs in (similarly, you need to provision ALGOs into this account using the [TestNet dispenser](https://bank.testnet.algorand.network/)). - -#### Continuous Integration - -For pull requests and pushes to `main` branch against this repository the following checks are automatically performed by GitHub Actions: - - Python dependencies are audited using [pip-audit](https://pypi.org/project/pip-audit/) - - Code formatting is checked using [Black](https://github.com/psf/black) - - Linting is checked using [Ruff](https://github.com/charliermarsh/ruff) - - Types are checked using [mypy](https://mypy-lang.org/) - - Smart contract artifacts are built - - Smart contract artifacts are checked for [output stability](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/articles/output_stability.md) - - Smart contract is deployed to a AlgoKit LocalNet instance - -#### Continuous Deployment - -For pushes to `main` branch, after the above checks pass, the following deployment actions are performed: - - The smart contract(s) are deployed to TestNet using [AlgoNode](https://algonode.io). - -> Please note deployment is also performed via `algokit deploy` command which can be invoked both via CI as seen on this project, or locally. For more information on how to use `algokit deploy` please see [AlgoKit documentation](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/deploy.md). +> For guidance on `smart_contracts` folder and adding new contracts to the project please see [README](smart_contracts/README.md) on the respective folder. # Tools @@ -104,10 +57,6 @@ This project makes use of Python to build Algorand smart contracts. The followin - [Puya](https://github.com/algorand-foundation/puya) - Smart contract development framework for developing Algorand smart contracts in pure Python; [docs](https://github.com/algorandfoundation/puya), [examples](https://github.com/algorandfoundation/puya/tree/main/examples) - [PyTEAL](https://github.com/algorand/pyteal) - Python language binding for Algorand smart contracts; [docs](https://pyteal.readthedocs.io/en/stable/) - [AlgoKit Utils](https://github.com/algorandfoundation/algokit-utils-py) - A set of core Algorand utilities that make it easier to build solutions on Algorand. -- [Poetry](https://python-poetry.org/): Python packaging and dependency management.- [Black](https://github.com/psf/black): A Python code formatter.- [Ruff](https://github.com/charliermarsh/ruff): An extremely fast Python linter. - -- [mypy](https://mypy-lang.org/): Static type checker. -- [pip-audit](https://pypi.org/project/pip-audit/): Tool for scanning Python environments for packages with known vulnerabilities. - - [pre-commit](https://pre-commit.com/): A framework for managing and maintaining multi-language pre-commit hooks, to enable pre-commit you need to run `pre-commit install` in the root of the repository. This will install the pre-commit hooks and run them against modified files when committing. If any of the hooks fail, the commit will be aborted. To run the hooks on all files, use `pre-commit run --all-files`. +- [Poetry](https://python-poetry.org/): Python packaging and dependency management. It has also been configured to have a productive dev experience out of the box in [VS Code](https://code.visualstudio.com/), see the [.vscode](./.vscode) folder. diff --git a/examples/generators/starter_puya_smart_contract_python/pyproject.toml b/examples/generators/starter_puya_smart_contract_python/pyproject.toml index 99c1707..f9fa94b 100644 --- a/examples/generators/starter_puya_smart_contract_python/pyproject.toml +++ b/examples/generators/starter_puya_smart_contract_python/pyproject.toml @@ -12,34 +12,8 @@ python-dotenv = "^1.0.0" puya = "^0" [tool.poetry.group.dev.dependencies] -black = {extras = ["d"], version = "*"} -ruff = "^0.1.6" -mypy = "*" -pip-audit = "*" -pre-commit = "*" [build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" -[tool.ruff] -line-length = 120 -select = ["E", "F", "ANN", "UP", "N", "C4", "B", "A", "YTT", "W", "FBT", "Q", "RUF", "I"] -ignore = [ - "ANN101", # no type for self - "ANN102", # no type for cls -] -unfixable = ["B", "RUF"] - -[tool.ruff.flake8-annotations] -allow-star-arg-any = true -suppress-none-returning = true - -[tool.mypy] -files = "smart_contracts/" -python_version = "3.12" -check_untyped_defs = true -warn_redundant_casts = true -warn_unused_ignores = true -allow_untyped_defs = false -strict_equality = true diff --git a/examples/generators/starter_puya_smart_contract_typescript/.algokit.toml b/examples/generators/starter_puya_smart_contract_typescript/.algokit.toml index 9ef71d2..8e601ad 100644 --- a/examples/generators/starter_puya_smart_contract_typescript/.algokit.toml +++ b/examples/generators/starter_puya_smart_contract_typescript/.algokit.toml @@ -1,19 +1,38 @@ [algokit] min_version = "v1.8.0" -[deploy] +[generate.smart_contract] +description = "Adds new smart contract to existing project" +path = ".algokit/generators/create_contract" + +[project] +type = 'contract' +name = 'starter_puya_smart_contract_typescript' +artifacts = 'smart_contracts/artifacts' + +[project.deploy] command = "npm run deploy:ci" environment_secrets = [ "DEPLOYER_MNEMONIC", ] -[deploy.localnet] +[project.deploy.localnet] environment_secrets = [] -[generate.smart_contract] -description = "Adds new smart contract to existing project" -path = ".algokit/generators/create_contract" +[project.run] +# Commands intented for use locally and in CI +build = { commands = [ + 'npm run build', +], description = 'Build all smart contracts in the project' } +lint = { commands = [ +], description = 'Perform linting' } +audit-teal = { commands = [ + # 🚨 IMPORTANT 🚨: For strict TEAL validation, remove --exclude statements. The default starter contract is not for production. Ensure thorough testing and adherence to best practices in smart contract development. This is not a replacement for a professional audit. + 'algokit task analyze smart_contracts/artifacts --recursive --force --exclude rekey-to --exclude is-updatable --exclude missing-fee-check --exclude is-deletable --exclude can-close-asset --exclude can-close-account --exclude unprotected-deletable --exclude unprotected-updatable', +], description = 'Audit TEAL files' } -[project] -type = 'contract' -name = 'starter_puya_smart_contract_typescript' +# Commands indented for CI only, prefixed with `ci-` by convention +ci-teal-diff = { commands = [ + 'git add -N ./smart_contracts/artifacts', + 'git diff --exit-code --minimal ./smart_contracts/artifacts', +], description = 'Check TEAL files for differences' } diff --git a/examples/generators/starter_puya_smart_contract_typescript/.github/workflows/cd.yaml b/examples/generators/starter_puya_smart_contract_typescript/.github/workflows/cd.yaml deleted file mode 100644 index 2401bf4..0000000 --- a/examples/generators/starter_puya_smart_contract_typescript/.github/workflows/cd.yaml +++ /dev/null @@ -1,50 +0,0 @@ -name: Continuous Delivery of Smart Contract - -on: - push: - branches: - - main - -concurrency: release - -jobs: - ci-check: - name: Perform Checks - uses: ./.github/workflows/checks.yaml - - deploy-testnet: - runs-on: 'ubuntu-latest' - needs: ci-check - environment: Test - steps: - - name: Checkout source code - uses: actions/checkout@v4 - - - name: Install poetry - run: pipx install poetry - - - name: Set up Python 3.12 - uses: actions/setup-python@v5 - with: - python-version: '3.12' - cache: 'poetry' - - - name: Install algokit - run: pipx install algokit - - - name: Bootstrap dependencies - run: algokit bootstrap all - - - name: Configure git - shell: bash - run: | - # set git user and email as test invoke git - git config --global user.email "actions@github.com" && git config --global user.name "github-actions" - - - name: Deploy to testnet - run: algokit deploy testnet - env: - # This is the account that becomes the creator of the contract. - # Since we are not using the optional dispenser account (via DISPENSER_MNEMONIC), - # it must also be funded with enough Algos to deploy and fund the smart contracts created - DEPLOYER_MNEMONIC: ${{ secrets.DEPLOYER_MNEMONIC }} diff --git a/examples/generators/starter_puya_smart_contract_typescript/.github/workflows/checks.yaml b/examples/generators/starter_puya_smart_contract_typescript/.github/workflows/checks.yaml deleted file mode 100644 index 3994f5d..0000000 --- a/examples/generators/starter_puya_smart_contract_typescript/.github/workflows/checks.yaml +++ /dev/null @@ -1,76 +0,0 @@ -name: Check code base - -on: - workflow_call: - -jobs: - checks: - runs-on: 'ubuntu-latest' - steps: - - name: Checkout source code - uses: actions/checkout@v4 - - - name: Install poetry - run: pipx install poetry - - - name: Set up Python 3.12 - uses: actions/setup-python@v5 - with: - python-version: '3.12' - cache: 'poetry' - - - name: Install algokit - run: pipx install algokit - - - name: Start LocalNet - run: algokit localnet start - - - name: Bootstrap dependencies - run: algokit bootstrap all - - - name: Configure git - shell: bash - run: | - # set git user and email as test invoke git - git config --global user.email "actions@github.com" && git config --global user.name "github-actions" - - - name: Audit with pip-audit - run: | - # audit non dev dependencies, no exclusions - poetry export --without=dev > requirements.txt && poetry run pip-audit -r requirements.txt - - # audit all dependencies, with exclusions. - # If a vulnerability is found in a dev dependency without an available fix, - # it can be temporarily ignored by adding --ignore-vuln e.g. - # --ignore-vuln "GHSA-hcpj-qp55-gfph" # GitPython vulnerability, dev only dependency - poetry run pip-audit - - - name: Check formatting with Black - run: | - # stop the build if there are files that don't meet formatting requirements - poetry run black --check . - - - name: Check linting with Ruff - run: | - # stop the build if there are Python syntax errors or undefined names - poetry run ruff . - - - name: Check types with mypy - run: poetry run mypy - - - name: Build smart contracts - run: poetry run python -m smart_contracts build - - - name: Scan TEAL files for issues - run: algokit task analyze .algokit --recursive --force # add --diff flag if you want output stability checks instead - - - name: Check output stability of the smart contracts - shell: bash - run: | - # Add untracked files as empty so they come up in diff - git add -N ./smart_contracts/artifacts - # Error out if there are any changes in teal after generating output - git diff --exit-code --minimal ./smart_contracts/artifacts || (echo "::error ::Smart contract artifacts have changed, ensure committed artifacts are up to date" && exit 1); - - - name: Run deployer against LocalNet - run: npm run --prefix smart_contracts deploy:ci diff --git a/examples/generators/starter_puya_smart_contract_typescript/.github/workflows/pr.yaml b/examples/generators/starter_puya_smart_contract_typescript/.github/workflows/pr.yaml deleted file mode 100644 index a80f784..0000000 --- a/examples/generators/starter_puya_smart_contract_typescript/.github/workflows/pr.yaml +++ /dev/null @@ -1,8 +0,0 @@ -name: Pull Request validation - -on: [pull_request] - -jobs: - pr-check: - name: Perform Checks - uses: ./.github/workflows/checks.yaml diff --git a/examples/generators/starter_puya_smart_contract_typescript/.pre-commit-config.yaml b/examples/generators/starter_puya_smart_contract_typescript/.pre-commit-config.yaml deleted file mode 100644 index 8862f86..0000000 --- a/examples/generators/starter_puya_smart_contract_typescript/.pre-commit-config.yaml +++ /dev/null @@ -1,48 +0,0 @@ -repos: - - repo: local - hooks: - - - id: black - name: black - description: "Black: The uncompromising Python code formatter" - entry: poetry run black - language: system - minimum_pre_commit_version: 2.9.2 - require_serial: true - types_or: [ python, pyi ] - - - - id: ruff - name: ruff - description: "Run 'ruff' for extremely fast Python linting" - entry: poetry run ruff - language: system - types: [ python ] - args: [ --fix ] - require_serial: false - additional_dependencies: [ ] - minimum_pre_commit_version: '0' - files: '^(src|tests)/' - - - - id: mypy - name: mypy - description: '`mypy` will check Python types for correctness' - entry: poetry run mypy - language: system - types_or: [ python, pyi ] - require_serial: true - additional_dependencies: [ ] - minimum_pre_commit_version: '2.9.2' - files: '^(src|tests)/' - - - id: tealer - name: tealer - description: "Run AlgoKit `Tealer` for TEAL static analysis" - entry: algokit - language: system - args: [task, analyze, ".algokit", "--recursive", "--force"] - require_serial: false - additional_dependencies: [] - minimum_pre_commit_version: "0" - files: '^.*\.teal$' diff --git a/examples/generators/starter_puya_smart_contract_typescript/.vscode/extensions.json b/examples/generators/starter_puya_smart_contract_typescript/.vscode/extensions.json index 684e4dd..e5ca4ca 100644 --- a/examples/generators/starter_puya_smart_contract_typescript/.vscode/extensions.json +++ b/examples/generators/starter_puya_smart_contract_typescript/.vscode/extensions.json @@ -1,9 +1,6 @@ { "recommendations": [ "ms-python.python", - "charliermarsh.ruff", - "matangover.mypy", - "ms-python.black-formatter", "esbenp.prettier-vscode", "tamasfe.even-better-toml", "editorconfig.editorconfig", diff --git a/examples/generators/starter_puya_smart_contract_typescript/.vscode/settings.json b/examples/generators/starter_puya_smart_contract_typescript/.vscode/settings.json index af8031f..dfae20d 100644 --- a/examples/generators/starter_puya_smart_contract_typescript/.vscode/settings.json +++ b/examples/generators/starter_puya_smart_contract_typescript/.vscode/settings.json @@ -24,26 +24,8 @@ // Prevent default import sorting from running; Ruff will sort imports for us anyway "source.organizeImports": false }, - "editor.defaultFormatter": "ms-python.black-formatter", + "editor.defaultFormatter": null, }, - "black-formatter.args": ["--config=pyproject.toml"], - "ruff.enable": true, - "ruff.lint.run": "onSave", - "ruff.lint.args": ["--config=pyproject.toml"], - "ruff.importStrategy": "fromEnvironment", - "ruff.fixAll": true, //lint and fix all files in workspace - "ruff.organizeImports": true, //organize imports on save - "ruff.codeAction.disableRuleComment": { - "enable": true - }, - "ruff.codeAction.fixViolation": { - "enable": true - }, - "python.analysis.typeCheckingMode": "off", - "mypy.configFile": "pyproject.toml", - // set to empty array to use config from project - "mypy.targets": [], - "mypy.runUsingActiveInterpreter": true, // On Windows, if execution policy is set to Signed (default) then it won't be able to activate the venv // so instead let's set it to RemoteSigned for VS Code terminal diff --git a/examples/generators/starter_puya_smart_contract_typescript/README.md b/examples/generators/starter_puya_smart_contract_typescript/README.md index 85af394..fa64c54 100644 --- a/examples/generators/starter_puya_smart_contract_typescript/README.md +++ b/examples/generators/starter_puya_smart_contract_typescript/README.md @@ -47,54 +47,7 @@ This project has been generated using AlgoKit. See below for default getting sta 1. If you update to the latest source code and there are new dependencies you will need to run `algokit bootstrap all` again 2. Follow step 3 above -> For guidance on `smart_contracts` folder and adding new contracts to the project please see [README](smart_contracts/README.md) on the respective folder.### 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. - -### Debugging Smart Contracts - -This project is optimized to work with AlgoKit AVM Debugger extension. To activate it: -Refer to the commented header in the `index.ts` file in the `smart_contracts` folder. - -If you have opted in to include VSCode launch configurations in your project, you can also use the `Debug TEAL via AlgoKit AVM Debugger` launch configuration to interactively select an available trace file and launch the debug session for your smart contract. - -For information on using and setting up the `AlgoKit AVM Debugger` VSCode extension refer [here](https://github.com/algorandfoundation/algokit-avm-vscode-debugger). To install the extension from the VSCode Marketplace, use the following link: [AlgoKit AVM Debugger extension](https://marketplace.visualstudio.com/items?itemName=algorandfoundation.algokit-avm-vscode-debugger). - -#### Setting up GitHub for CI/CD workflow and TestNet deployment - - 1. Every time you have a change to your smart contract, and when you first initialize the project you need to [build the contract](#initial-setup) and then commit the `smart_contracts/artifacts` folder so the [output stability](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/articles/output_stability.md) tests pass - 2. Decide what values you want to use for the `allowUpdate` and `allowDelete` parameters specified in [`deploy-config.ts`](./smart_contracts/hello_world/deploy-config.ts). - When deploying to LocalNet these values are both set to `true` for convenience. But for non-LocalNet networks - they are more conservative and use `false` - These default values will allow the smart contract to be deployed initially, but will not allow the app to be updated or deleted if is changed and the build will instead fail. - To help you decide it may be helpful to read the [AlgoKit Utils app deployment documentation](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/docs/capabilities/app-deploy.md) or the [AlgoKit smart contract deployment architecture](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/architecture-decisions/2023-01-12_smart-contract-deployment.md#upgradeable-and-deletable-contracts). - 3. Create a [Github Environment](https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#creating-an-environment) named `Test`. - Note: If you have a private repository and don't have GitHub Enterprise then Environments won't work and you'll need to convert the GitHub Action to use a different approach. Ignore this step if you picked `Starter` preset. - 4. Create or obtain a mnemonic for an Algorand account for use on TestNet to deploy apps, referred to as the `DEPLOYER` account. - 5. Store the mnemonic as a [secret](https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#environment-secrets) `DEPLOYER_MNEMONIC` - in the Test environment created in step 3. - 6. The account used to deploy the smart contract will require enough funds to create the app, and also fund it. There are two approaches available here: - * Either, ensure the account is funded outside of CI/CD. - In Testnet, funds can be obtained by using the [Algorand TestNet dispenser](https://bank.testnet.algorand.network/) and we recommend provisioning 50 ALGOs. - * Or, fund the account as part of the CI/CD process by using a `DISPENSER_MNEMONIC` GitHub Environment secret to point to a separate `DISPENSER` account that you maintain ALGOs in (similarly, you need to provision ALGOs into this account using the [TestNet dispenser](https://bank.testnet.algorand.network/)). - -#### Continuous Integration - -For pull requests and pushes to `main` branch against this repository the following checks are automatically performed by GitHub Actions: - - Python dependencies are audited using [pip-audit](https://pypi.org/project/pip-audit/) - - Code formatting is checked using [Black](https://github.com/psf/black) - - Linting is checked using [Ruff](https://github.com/charliermarsh/ruff) - - Types are checked using [mypy](https://mypy-lang.org/) - - Smart contract artifacts are built - - Smart contract artifacts are checked for [output stability](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/articles/output_stability.md) - - Smart contract is deployed to a AlgoKit LocalNet instance - -#### Continuous Deployment - -For pushes to `main` branch, after the above checks pass, the following deployment actions are performed: - - The smart contract(s) are deployed to TestNet using [AlgoNode](https://algonode.io). - -> Please note deployment is also performed via `algokit deploy` command which can be invoked both via CI as seen on this project, or locally. For more information on how to use `algokit deploy` please see [AlgoKit documentation](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/deploy.md). +> For guidance on `smart_contracts` folder and adding new contracts to the project please see [README](smart_contracts/README.md) on the respective folder. # Tools @@ -105,11 +58,7 @@ This project makes use of Python to build Algorand smart contracts. The followin - [Puya](https://github.com/algorand-foundation/puya) - Smart contract development framework for developing Algorand smart contracts in pure Python; [docs](https://github.com/algorandfoundation/puya), [examples](https://github.com/algorandfoundation/puya/tree/main/examples) - [PyTEAL](https://github.com/algorand/pyteal) - Python language binding for Algorand smart contracts; [docs](https://pyteal.readthedocs.io/en/stable/) - [AlgoKit Utils](https://github.com/algorandfoundation/algokit-utils-ts) - A set of core Algorand utilities that make it easier to build solutions on Algorand. -- [Poetry](https://python-poetry.org/): Python packaging and dependency management.- [Black](https://github.com/psf/black): A Python code formatter.- [Ruff](https://github.com/charliermarsh/ruff): An extremely fast Python linter. - -- [mypy](https://mypy-lang.org/): Static type checker. -- [pip-audit](https://pypi.org/project/pip-audit/): Tool for scanning Python environments for packages with known vulnerabilities. - - [pre-commit](https://pre-commit.com/): A framework for managing and maintaining multi-language pre-commit hooks, to enable pre-commit you need to run `pre-commit install` in the root of the repository. This will install the pre-commit hooks and run them against modified files when committing. If any of the hooks fail, the commit will be aborted. To run the hooks on all files, use `pre-commit run --all-files`. +- [Poetry](https://python-poetry.org/): Python packaging and dependency management. - [npm](https://www.npmjs.com/): Node.js package manager - [TypeScript](https://www.typescriptlang.org/): Strongly typed programming language that builds on JavaScript - [ts-node-dev](https://github.com/wclr/ts-node-dev): TypeScript development execution environment diff --git a/examples/generators/starter_puya_smart_contract_typescript/pyproject.toml b/examples/generators/starter_puya_smart_contract_typescript/pyproject.toml index 8068b87..4367309 100644 --- a/examples/generators/starter_puya_smart_contract_typescript/pyproject.toml +++ b/examples/generators/starter_puya_smart_contract_typescript/pyproject.toml @@ -12,34 +12,8 @@ python-dotenv = "^1.0.0" puya = "^0" [tool.poetry.group.dev.dependencies] -black = {extras = ["d"], version = "*"} -ruff = "^0.1.6" -mypy = "*" -pip-audit = "*" -pre-commit = "*" [build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" -[tool.ruff] -line-length = 120 -select = ["E", "F", "ANN", "UP", "N", "C4", "B", "A", "YTT", "W", "FBT", "Q", "RUF", "I"] -ignore = [ - "ANN101", # no type for self - "ANN102", # no type for cls -] -unfixable = ["B", "RUF"] - -[tool.ruff.flake8-annotations] -allow-star-arg-any = true -suppress-none-returning = true - -[tool.mypy] -files = "smart_contracts/" -python_version = "3.12" -check_untyped_defs = true -warn_redundant_casts = true -warn_unused_ignores = true -allow_untyped_defs = false -strict_equality = true diff --git a/examples/production_puya/.algokit.toml b/examples/production_puya/.algokit.toml index 3965d2d..d3d76d9 100644 --- a/examples/production_puya/.algokit.toml +++ b/examples/production_puya/.algokit.toml @@ -1,19 +1,49 @@ [algokit] min_version = "v1.8.0" -[deploy] +[generate.smart_contract] +description = "Adds new smart contract to existing project" +path = ".algokit/generators/create_contract" + +[project] +type = 'contract' +name = 'production_puya' +artifacts = 'smart_contracts/artifacts' + +[project.deploy] command = "poetry run python -m smart_contracts deploy" environment_secrets = [ "DEPLOYER_MNEMONIC", + "DISPENSER_MNEMONIC", ] -[deploy.localnet] +[project.deploy.localnet] environment_secrets = [] -[generate.smart_contract] -description = "Adds new smart contract to existing project" -path = ".algokit/generators/create_contract" +[project.run] +# Commands intented for use locally and in CI +build = { commands = [ + 'poetry run python -m smart_contracts build', +], description = 'Build all smart contracts in the project' } +test = { commands = [ + 'poetry run pytest', +], description = 'Run smart contract tests' } +audit = { commands = [ + 'poetry export --without=dev -o requirements.txt', + 'poetry run pip-audit -r requirements.txt', +], description = 'Audit with pip-audit' } +lint = { commands = [ + 'poetry run black --check .', + 'poetry run ruff .', + 'poetry run mypy', +], description = 'Perform linting' } +audit-teal = { commands = [ + # 🚨 IMPORTANT 🚨: For strict TEAL validation, remove --exclude statements. The default starter contract is not for production. Ensure thorough testing and adherence to best practices in smart contract development. This is not a replacement for a professional audit. + 'algokit task analyze smart_contracts/artifacts --recursive --force --exclude rekey-to --exclude is-updatable --exclude missing-fee-check --exclude is-deletable --exclude can-close-asset --exclude can-close-account --exclude unprotected-deletable --exclude unprotected-updatable', +], description = 'Audit TEAL files' } -[project] -type = 'contract' -name = 'production_puya' +# Commands indented for CI only, prefixed with `ci-` by convention +ci-teal-diff = { commands = [ + 'git add -N ./smart_contracts/artifacts', + 'git diff --exit-code --minimal ./smart_contracts/artifacts', +], description = 'Check TEAL files for differences' } diff --git a/examples/production_puya/.github/workflows/cd.yaml b/examples/production_puya/.github/workflows/cd.yaml deleted file mode 100644 index 2401bf4..0000000 --- a/examples/production_puya/.github/workflows/cd.yaml +++ /dev/null @@ -1,50 +0,0 @@ -name: Continuous Delivery of Smart Contract - -on: - push: - branches: - - main - -concurrency: release - -jobs: - ci-check: - name: Perform Checks - uses: ./.github/workflows/checks.yaml - - deploy-testnet: - runs-on: 'ubuntu-latest' - needs: ci-check - environment: Test - steps: - - name: Checkout source code - uses: actions/checkout@v4 - - - name: Install poetry - run: pipx install poetry - - - name: Set up Python 3.12 - uses: actions/setup-python@v5 - with: - python-version: '3.12' - cache: 'poetry' - - - name: Install algokit - run: pipx install algokit - - - name: Bootstrap dependencies - run: algokit bootstrap all - - - name: Configure git - shell: bash - run: | - # set git user and email as test invoke git - git config --global user.email "actions@github.com" && git config --global user.name "github-actions" - - - name: Deploy to testnet - run: algokit deploy testnet - env: - # This is the account that becomes the creator of the contract. - # Since we are not using the optional dispenser account (via DISPENSER_MNEMONIC), - # it must also be funded with enough Algos to deploy and fund the smart contracts created - DEPLOYER_MNEMONIC: ${{ secrets.DEPLOYER_MNEMONIC }} diff --git a/examples/production_puya/.github/workflows/checks.yaml b/examples/production_puya/.github/workflows/checks.yaml deleted file mode 100644 index 3415368..0000000 --- a/examples/production_puya/.github/workflows/checks.yaml +++ /dev/null @@ -1,82 +0,0 @@ -name: Check code base - -on: - workflow_call: - -jobs: - checks: - runs-on: 'ubuntu-latest' - steps: - - name: Checkout source code - uses: actions/checkout@v4 - - - name: Install poetry - run: pipx install poetry - - - name: Set up Python 3.12 - uses: actions/setup-python@v5 - with: - python-version: '3.12' - cache: 'poetry' - - - name: Install algokit - run: pipx install algokit - - - name: Start LocalNet - run: algokit localnet start - - - name: Bootstrap dependencies - run: algokit bootstrap all - - - name: Configure git - shell: bash - run: | - # set git user and email as test invoke git - git config --global user.email "actions@github.com" && git config --global user.name "github-actions" - - - name: Audit with pip-audit - run: | - # audit non dev dependencies, no exclusions - poetry export --without=dev > requirements.txt && poetry run pip-audit -r requirements.txt - - # audit all dependencies, with exclusions. - # If a vulnerability is found in a dev dependency without an available fix, - # it can be temporarily ignored by adding --ignore-vuln e.g. - # --ignore-vuln "GHSA-hcpj-qp55-gfph" # GitPython vulnerability, dev only dependency - poetry run pip-audit - - - name: Check formatting with Black - run: | - # stop the build if there are files that don't meet formatting requirements - poetry run black --check . - - - name: Check linting with Ruff - run: | - # stop the build if there are Python syntax errors or undefined names - poetry run ruff . - - - name: Check types with mypy - run: poetry run mypy - - - name: Run tests - shell: bash - run: | - set -o pipefail - poetry run pytest --junitxml=pytest-junit.xml - - - name: Build smart contracts - run: poetry run python -m smart_contracts build - - - name: Scan TEAL files for issues - run: algokit task analyze .algokit --recursive --force # add --diff flag if you want output stability checks instead - - - name: Check output stability of the smart contracts - shell: bash - run: | - # Add untracked files as empty so they come up in diff - git add -N ./smart_contracts/artifacts - # Error out if there are any changes in teal after generating output - git diff --exit-code --minimal ./smart_contracts/artifacts || (echo "::error ::Smart contract artifacts have changed, ensure committed artifacts are up to date" && exit 1); - - - name: Run deployer against LocalNet - run: poetry run python -m smart_contracts deploy diff --git a/examples/production_puya/.github/workflows/pr.yaml b/examples/production_puya/.github/workflows/pr.yaml deleted file mode 100644 index a80f784..0000000 --- a/examples/production_puya/.github/workflows/pr.yaml +++ /dev/null @@ -1,8 +0,0 @@ -name: Pull Request validation - -on: [pull_request] - -jobs: - pr-check: - name: Perform Checks - uses: ./.github/workflows/checks.yaml diff --git a/examples/generators/production_puya_smart_contract_typescript/.github/workflows/cd.yaml b/examples/production_puya/.github/workflows/production-puya-cd.yaml similarity index 52% rename from examples/generators/production_puya_smart_contract_typescript/.github/workflows/cd.yaml rename to examples/production_puya/.github/workflows/production-puya-cd.yaml index 2401bf4..a40f6e8 100644 --- a/examples/generators/production_puya_smart_contract_typescript/.github/workflows/cd.yaml +++ b/examples/production_puya/.github/workflows/production-puya-cd.yaml @@ -1,21 +1,19 @@ -name: Continuous Delivery of Smart Contract +name: Release production_puya on: + workflow_call: push: branches: - main -concurrency: release - jobs: - ci-check: - name: Perform Checks - uses: ./.github/workflows/checks.yaml - + validate: + name: Validate production_puya + uses: ./.github/workflows/production-puya-ci.yaml deploy-testnet: - runs-on: 'ubuntu-latest' - needs: ci-check - environment: Test + runs-on: "ubuntu-latest" + needs: validate + environment: contract-testnet steps: - name: Checkout source code uses: actions/checkout@v4 @@ -26,14 +24,14 @@ jobs: - name: Set up Python 3.12 uses: actions/setup-python@v5 with: - python-version: '3.12' - cache: 'poetry' + python-version: "3.12" + cache: "poetry" - name: Install algokit - run: pipx install algokit + run: pipx install git+https://github.com/algorandfoundation/algokit-cli@feat/orchestration-linking - name: Bootstrap dependencies - run: algokit bootstrap all + run: algokit bootstrap all --project-name 'production_puya' - name: Configure git shell: bash @@ -42,9 +40,9 @@ jobs: git config --global user.email "actions@github.com" && git config --global user.name "github-actions" - name: Deploy to testnet - run: algokit deploy testnet + run: algokit deploy testnet --project-name 'production_puya' env: - # This is the account that becomes the creator of the contract. - # Since we are not using the optional dispenser account (via DISPENSER_MNEMONIC), - # it must also be funded with enough Algos to deploy and fund the smart contracts created + # This is the account that becomes the creator of the contract DEPLOYER_MNEMONIC: ${{ secrets.DEPLOYER_MNEMONIC }} + # The dispenser account is used to ensure the deployer account is funded + DISPENSER_MNEMONIC: ${{ secrets.DISPENSER_MNEMONIC }} diff --git a/examples/production_puya/.github/workflows/production-puya-ci.yaml b/examples/production_puya/.github/workflows/production-puya-ci.yaml new file mode 100644 index 0000000..4dc8da2 --- /dev/null +++ b/examples/production_puya/.github/workflows/production-puya-ci.yaml @@ -0,0 +1,60 @@ +name: Validate production_puya + +on: + workflow_call: + pull_request: + +jobs: + validate: + runs-on: "ubuntu-latest" + steps: + - name: Checkout source code + uses: actions/checkout@v4 + + - name: Install poetry + run: pipx install poetry + + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: "3.12" + cache: "poetry" + + - name: Install algokit + run: pipx install git+https://github.com/algorandfoundation/algokit-cli@feat/orchestration-linking + + - name: Start LocalNet + run: algokit localnet start + + - name: Bootstrap dependencies + run: algokit bootstrap all --project-name 'production_puya' + + - name: Configure git + shell: bash + run: | + # set git user and email as test invoke git + git config --global user.email "actions@github.com" && git config --global user.name "github-actions" + + - name: Audit python dependencies + run: algokit project run audit --project-name 'production_puya' + + - name: Lint and format python dependencies + run: algokit project run lint --project-name 'production_puya' + + - name: Run tests + shell: bash + run: | + set -o pipefail + algokit project run test --project-name 'production_puya' + + - name: Build smart contracts + run: algokit project run build --project-name 'production_puya' + + - name: Scan TEAL files for issues + run: algokit project run audit-teal --project-name 'production_puya' + + - name: Check output stability of the smart contracts + run: algokit project run ci-teal-diff --project-name 'production_puya' + + - name: Run deployer against LocalNet + run: algokit project deploy localnet --project-name 'production_puya' diff --git a/examples/production_puya/.idea/runConfigurations/Build_Beaker_application.xml b/examples/production_puya/.idea/runConfigurations/Build_Beaker_application.xml new file mode 100644 index 0000000..d225def --- /dev/null +++ b/examples/production_puya/.idea/runConfigurations/Build_Beaker_application.xml @@ -0,0 +1,35 @@ + + + + + diff --git a/examples/production_puya/.idea/runConfigurations/Build_Beaker_application____LocalNet.xml b/examples/production_puya/.idea/runConfigurations/Build_Beaker_application____LocalNet.xml new file mode 100644 index 0000000..fc81585 --- /dev/null +++ b/examples/production_puya/.idea/runConfigurations/Build_Beaker_application____LocalNet.xml @@ -0,0 +1,37 @@ + + + + + diff --git a/examples/production_puya/.idea/runConfigurations/Build___Deploy_Beaker_application.xml b/examples/production_puya/.idea/runConfigurations/Build___Deploy_Beaker_application.xml new file mode 100644 index 0000000..31edb94 --- /dev/null +++ b/examples/production_puya/.idea/runConfigurations/Build___Deploy_Beaker_application.xml @@ -0,0 +1,38 @@ + + + + + diff --git a/examples/production_puya/.idea/runConfigurations/Deploy_Built_Beaker_application.xml b/examples/production_puya/.idea/runConfigurations/Deploy_Built_Beaker_application.xml new file mode 100644 index 0000000..27e9126 --- /dev/null +++ b/examples/production_puya/.idea/runConfigurations/Deploy_Built_Beaker_application.xml @@ -0,0 +1,36 @@ + + + + + diff --git a/examples/production_puya/.idea/runConfigurations/Reset_AlgoKit_LocalNet.xml b/examples/production_puya/.idea/runConfigurations/Reset_AlgoKit_LocalNet.xml new file mode 100644 index 0000000..7f1236a --- /dev/null +++ b/examples/production_puya/.idea/runConfigurations/Reset_AlgoKit_LocalNet.xml @@ -0,0 +1,17 @@ + + + + diff --git a/examples/production_puya/.idea/runConfigurations/Start_AlgoKit_LocalNet.xml b/examples/production_puya/.idea/runConfigurations/Start_AlgoKit_LocalNet.xml new file mode 100644 index 0000000..f699a7a --- /dev/null +++ b/examples/production_puya/.idea/runConfigurations/Start_AlgoKit_LocalNet.xml @@ -0,0 +1,17 @@ + + + + diff --git a/examples/production_puya/.idea/runConfigurations/Stop_AlgoKit_LocalNet.xml b/examples/production_puya/.idea/runConfigurations/Stop_AlgoKit_LocalNet.xml new file mode 100644 index 0000000..e510cbc --- /dev/null +++ b/examples/production_puya/.idea/runConfigurations/Stop_AlgoKit_LocalNet.xml @@ -0,0 +1,17 @@ + + + + diff --git a/examples/starter_puya/.algokit.toml b/examples/starter_puya/.algokit.toml index 2cbed35..4eb0f71 100644 --- a/examples/starter_puya/.algokit.toml +++ b/examples/starter_puya/.algokit.toml @@ -1,19 +1,38 @@ [algokit] min_version = "v1.8.0" -[deploy] +[generate.smart_contract] +description = "Adds new smart contract to existing project" +path = ".algokit/generators/create_contract" + +[project] +type = 'contract' +name = 'starter_puya' +artifacts = 'smart_contracts/artifacts' + +[project.deploy] command = "poetry run python -m smart_contracts deploy" environment_secrets = [ "DEPLOYER_MNEMONIC", ] -[deploy.localnet] +[project.deploy.localnet] environment_secrets = [] -[generate.smart_contract] -description = "Adds new smart contract to existing project" -path = ".algokit/generators/create_contract" +[project.run] +# Commands intented for use locally and in CI +build = { commands = [ + 'poetry run python -m smart_contracts build', +], description = 'Build all smart contracts in the project' } +lint = { commands = [ +], description = 'Perform linting' } +audit-teal = { commands = [ + # 🚨 IMPORTANT 🚨: For strict TEAL validation, remove --exclude statements. The default starter contract is not for production. Ensure thorough testing and adherence to best practices in smart contract development. This is not a replacement for a professional audit. + 'algokit task analyze smart_contracts/artifacts --recursive --force --exclude rekey-to --exclude is-updatable --exclude missing-fee-check --exclude is-deletable --exclude can-close-asset --exclude can-close-account --exclude unprotected-deletable --exclude unprotected-updatable', +], description = 'Audit TEAL files' } -[project] -type = 'contract' -name = 'starter_puya' +# Commands indented for CI only, prefixed with `ci-` by convention +ci-teal-diff = { commands = [ + 'git add -N ./smart_contracts/artifacts', + 'git diff --exit-code --minimal ./smart_contracts/artifacts', +], description = 'Check TEAL files for differences' } diff --git a/examples/starter_puya/.github/workflows/cd.yaml b/examples/starter_puya/.github/workflows/cd.yaml deleted file mode 100644 index 2401bf4..0000000 --- a/examples/starter_puya/.github/workflows/cd.yaml +++ /dev/null @@ -1,50 +0,0 @@ -name: Continuous Delivery of Smart Contract - -on: - push: - branches: - - main - -concurrency: release - -jobs: - ci-check: - name: Perform Checks - uses: ./.github/workflows/checks.yaml - - deploy-testnet: - runs-on: 'ubuntu-latest' - needs: ci-check - environment: Test - steps: - - name: Checkout source code - uses: actions/checkout@v4 - - - name: Install poetry - run: pipx install poetry - - - name: Set up Python 3.12 - uses: actions/setup-python@v5 - with: - python-version: '3.12' - cache: 'poetry' - - - name: Install algokit - run: pipx install algokit - - - name: Bootstrap dependencies - run: algokit bootstrap all - - - name: Configure git - shell: bash - run: | - # set git user and email as test invoke git - git config --global user.email "actions@github.com" && git config --global user.name "github-actions" - - - name: Deploy to testnet - run: algokit deploy testnet - env: - # This is the account that becomes the creator of the contract. - # Since we are not using the optional dispenser account (via DISPENSER_MNEMONIC), - # it must also be funded with enough Algos to deploy and fund the smart contracts created - DEPLOYER_MNEMONIC: ${{ secrets.DEPLOYER_MNEMONIC }} diff --git a/examples/starter_puya/.github/workflows/checks.yaml b/examples/starter_puya/.github/workflows/checks.yaml deleted file mode 100644 index 2c75ab4..0000000 --- a/examples/starter_puya/.github/workflows/checks.yaml +++ /dev/null @@ -1,76 +0,0 @@ -name: Check code base - -on: - workflow_call: - -jobs: - checks: - runs-on: 'ubuntu-latest' - steps: - - name: Checkout source code - uses: actions/checkout@v4 - - - name: Install poetry - run: pipx install poetry - - - name: Set up Python 3.12 - uses: actions/setup-python@v5 - with: - python-version: '3.12' - cache: 'poetry' - - - name: Install algokit - run: pipx install algokit - - - name: Start LocalNet - run: algokit localnet start - - - name: Bootstrap dependencies - run: algokit bootstrap all - - - name: Configure git - shell: bash - run: | - # set git user and email as test invoke git - git config --global user.email "actions@github.com" && git config --global user.name "github-actions" - - - name: Audit with pip-audit - run: | - # audit non dev dependencies, no exclusions - poetry export --without=dev > requirements.txt && poetry run pip-audit -r requirements.txt - - # audit all dependencies, with exclusions. - # If a vulnerability is found in a dev dependency without an available fix, - # it can be temporarily ignored by adding --ignore-vuln e.g. - # --ignore-vuln "GHSA-hcpj-qp55-gfph" # GitPython vulnerability, dev only dependency - poetry run pip-audit - - - name: Check formatting with Black - run: | - # stop the build if there are files that don't meet formatting requirements - poetry run black --check . - - - name: Check linting with Ruff - run: | - # stop the build if there are Python syntax errors or undefined names - poetry run ruff . - - - name: Check types with mypy - run: poetry run mypy - - - name: Build smart contracts - run: poetry run python -m smart_contracts build - - - name: Scan TEAL files for issues - run: algokit task analyze .algokit --recursive --force # add --diff flag if you want output stability checks instead - - - name: Check output stability of the smart contracts - shell: bash - run: | - # Add untracked files as empty so they come up in diff - git add -N ./smart_contracts/artifacts - # Error out if there are any changes in teal after generating output - git diff --exit-code --minimal ./smart_contracts/artifacts || (echo "::error ::Smart contract artifacts have changed, ensure committed artifacts are up to date" && exit 1); - - - name: Run deployer against LocalNet - run: poetry run python -m smart_contracts deploy diff --git a/examples/starter_puya/.github/workflows/pr.yaml b/examples/starter_puya/.github/workflows/pr.yaml deleted file mode 100644 index a80f784..0000000 --- a/examples/starter_puya/.github/workflows/pr.yaml +++ /dev/null @@ -1,8 +0,0 @@ -name: Pull Request validation - -on: [pull_request] - -jobs: - pr-check: - name: Perform Checks - uses: ./.github/workflows/checks.yaml diff --git a/examples/starter_puya/.pre-commit-config.yaml b/examples/starter_puya/.pre-commit-config.yaml deleted file mode 100644 index 8862f86..0000000 --- a/examples/starter_puya/.pre-commit-config.yaml +++ /dev/null @@ -1,48 +0,0 @@ -repos: - - repo: local - hooks: - - - id: black - name: black - description: "Black: The uncompromising Python code formatter" - entry: poetry run black - language: system - minimum_pre_commit_version: 2.9.2 - require_serial: true - types_or: [ python, pyi ] - - - - id: ruff - name: ruff - description: "Run 'ruff' for extremely fast Python linting" - entry: poetry run ruff - language: system - types: [ python ] - args: [ --fix ] - require_serial: false - additional_dependencies: [ ] - minimum_pre_commit_version: '0' - files: '^(src|tests)/' - - - - id: mypy - name: mypy - description: '`mypy` will check Python types for correctness' - entry: poetry run mypy - language: system - types_or: [ python, pyi ] - require_serial: true - additional_dependencies: [ ] - minimum_pre_commit_version: '2.9.2' - files: '^(src|tests)/' - - - id: tealer - name: tealer - description: "Run AlgoKit `Tealer` for TEAL static analysis" - entry: algokit - language: system - args: [task, analyze, ".algokit", "--recursive", "--force"] - require_serial: false - additional_dependencies: [] - minimum_pre_commit_version: "0" - files: '^.*\.teal$' diff --git a/examples/starter_puya/.vscode/extensions.json b/examples/starter_puya/.vscode/extensions.json index 1d2e7cf..e16b76b 100644 --- a/examples/starter_puya/.vscode/extensions.json +++ b/examples/starter_puya/.vscode/extensions.json @@ -1,9 +1,6 @@ { "recommendations": [ "ms-python.python", - "charliermarsh.ruff", - "matangover.mypy", - "ms-python.black-formatter", "tamasfe.even-better-toml", "editorconfig.editorconfig", "vsls-contrib.codetour", diff --git a/examples/starter_puya/.vscode/settings.json b/examples/starter_puya/.vscode/settings.json index a7b97d0..4cf6525 100644 --- a/examples/starter_puya/.vscode/settings.json +++ b/examples/starter_puya/.vscode/settings.json @@ -21,26 +21,8 @@ // Prevent default import sorting from running; Ruff will sort imports for us anyway "source.organizeImports": false }, - "editor.defaultFormatter": "ms-python.black-formatter", + "editor.defaultFormatter": null, }, - "black-formatter.args": ["--config=pyproject.toml"], - "ruff.enable": true, - "ruff.lint.run": "onSave", - "ruff.lint.args": ["--config=pyproject.toml"], - "ruff.importStrategy": "fromEnvironment", - "ruff.fixAll": true, //lint and fix all files in workspace - "ruff.organizeImports": true, //organize imports on save - "ruff.codeAction.disableRuleComment": { - "enable": true - }, - "ruff.codeAction.fixViolation": { - "enable": true - }, - "python.analysis.typeCheckingMode": "off", - "mypy.configFile": "pyproject.toml", - // set to empty array to use config from project - "mypy.targets": [], - "mypy.runUsingActiveInterpreter": true, // On Windows, if execution policy is set to Signed (default) then it won't be able to activate the venv // so instead let's set it to RemoteSigned for VS Code terminal diff --git a/examples/starter_puya/README.md b/examples/starter_puya/README.md index c83ee6b..48ee65f 100644 --- a/examples/starter_puya/README.md +++ b/examples/starter_puya/README.md @@ -46,54 +46,7 @@ This project has been generated using AlgoKit. See below for default getting sta 1. If you update to the latest source code and there are new dependencies you will need to run `algokit bootstrap all` again 2. Follow step 3 above -> For guidance on `smart_contracts` folder and adding new contracts to the project please see [README](smart_contracts/README.md) on the respective folder.### 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. - -### Debugging Smart Contracts - -This project is optimized to work with AlgoKit AVM Debugger extension. To activate it: -Refer to the commented header in the `__main__.py` file in the `smart_contracts` folder. - -If you have opted in to include VSCode launch configurations in your project, you can also use the `Debug TEAL via AlgoKit AVM Debugger` launch configuration to interactively select an available trace file and launch the debug session for your smart contract. - -For information on using and setting up the `AlgoKit AVM Debugger` VSCode extension refer [here](https://github.com/algorandfoundation/algokit-avm-vscode-debugger). To install the extension from the VSCode Marketplace, use the following link: [AlgoKit AVM Debugger extension](https://marketplace.visualstudio.com/items?itemName=algorandfoundation.algokit-avm-vscode-debugger). - -#### Setting up GitHub for CI/CD workflow and TestNet deployment - - 1. Every time you have a change to your smart contract, and when you first initialize the project you need to [build the contract](#initial-setup) and then commit the `smart_contracts/artifacts` folder so the [output stability](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/articles/output_stability.md) tests pass - 2. Decide what values you want to use for the `allow_update`, `allow_delete` and the `on_schema_break`, `on_update` parameters specified in [`contract.py`](./smart_contracts/hello_world/contract.py). - When deploying to LocalNet these values are both set to allow update and replacement of the app for convenience. But for non-LocalNet networks - the defaults are more conservative. - These default values will allow the smart contract to be deployed initially, but will not allow the app to be updated or deleted if is changed and the build will instead fail. - To help you decide it may be helpful to read the [AlgoKit Utils app deployment documentation](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/docs/capabilities/app-deploy.md) or the [AlgoKit smart contract deployment architecture](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/architecture-decisions/2023-01-12_smart-contract-deployment.md#upgradeable-and-deletable-contracts). - 3. Create a [Github Environment](https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#creating-an-environment) named `Test`. - Note: If you have a private repository and don't have GitHub Enterprise then Environments won't work and you'll need to convert the GitHub Action to use a different approach. Ignore this step if you picked `Starter` preset. - 4. Create or obtain a mnemonic for an Algorand account for use on TestNet to deploy apps, referred to as the `DEPLOYER` account. - 5. Store the mnemonic as a [secret](https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#environment-secrets) `DEPLOYER_MNEMONIC` - in the Test environment created in step 3. - 6. The account used to deploy the smart contract will require enough funds to create the app, and also fund it. There are two approaches available here: - * Either, ensure the account is funded outside of CI/CD. - In Testnet, funds can be obtained by using the [Algorand TestNet dispenser](https://bank.testnet.algorand.network/) and we recommend provisioning 50 ALGOs. - * Or, fund the account as part of the CI/CD process by using a `DISPENSER_MNEMONIC` GitHub Environment secret to point to a separate `DISPENSER` account that you maintain ALGOs in (similarly, you need to provision ALGOs into this account using the [TestNet dispenser](https://bank.testnet.algorand.network/)). - -#### Continuous Integration - -For pull requests and pushes to `main` branch against this repository the following checks are automatically performed by GitHub Actions: - - Python dependencies are audited using [pip-audit](https://pypi.org/project/pip-audit/) - - Code formatting is checked using [Black](https://github.com/psf/black) - - Linting is checked using [Ruff](https://github.com/charliermarsh/ruff) - - Types are checked using [mypy](https://mypy-lang.org/) - - Smart contract artifacts are built - - Smart contract artifacts are checked for [output stability](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/articles/output_stability.md) - - Smart contract is deployed to a AlgoKit LocalNet instance - -#### Continuous Deployment - -For pushes to `main` branch, after the above checks pass, the following deployment actions are performed: - - The smart contract(s) are deployed to TestNet using [AlgoNode](https://algonode.io). - -> Please note deployment is also performed via `algokit deploy` command which can be invoked both via CI as seen on this project, or locally. For more information on how to use `algokit deploy` please see [AlgoKit documentation](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/deploy.md). +> For guidance on `smart_contracts` folder and adding new contracts to the project please see [README](smart_contracts/README.md) on the respective folder. # Tools @@ -104,10 +57,6 @@ This project makes use of Python to build Algorand smart contracts. The followin - [Puya](https://github.com/algorand-foundation/puya) - Smart contract development framework for developing Algorand smart contracts in pure Python; [docs](https://github.com/algorandfoundation/puya), [examples](https://github.com/algorandfoundation/puya/tree/main/examples) - [PyTEAL](https://github.com/algorand/pyteal) - Python language binding for Algorand smart contracts; [docs](https://pyteal.readthedocs.io/en/stable/) - [AlgoKit Utils](https://github.com/algorandfoundation/algokit-utils-py) - A set of core Algorand utilities that make it easier to build solutions on Algorand. -- [Poetry](https://python-poetry.org/): Python packaging and dependency management.- [Black](https://github.com/psf/black): A Python code formatter.- [Ruff](https://github.com/charliermarsh/ruff): An extremely fast Python linter. - -- [mypy](https://mypy-lang.org/): Static type checker. -- [pip-audit](https://pypi.org/project/pip-audit/): Tool for scanning Python environments for packages with known vulnerabilities. - - [pre-commit](https://pre-commit.com/): A framework for managing and maintaining multi-language pre-commit hooks, to enable pre-commit you need to run `pre-commit install` in the root of the repository. This will install the pre-commit hooks and run them against modified files when committing. If any of the hooks fail, the commit will be aborted. To run the hooks on all files, use `pre-commit run --all-files`. +- [Poetry](https://python-poetry.org/): Python packaging and dependency management. It has also been configured to have a productive dev experience out of the box in [VS Code](https://code.visualstudio.com/), see the [.vscode](./.vscode) folder. diff --git a/examples/starter_puya/pyproject.toml b/examples/starter_puya/pyproject.toml index f364c33..c8511f6 100644 --- a/examples/starter_puya/pyproject.toml +++ b/examples/starter_puya/pyproject.toml @@ -12,34 +12,8 @@ python-dotenv = "^1.0.0" puya = "^0" [tool.poetry.group.dev.dependencies] -black = {extras = ["d"], version = "*"} -ruff = "^0.1.6" -mypy = "*" -pip-audit = "*" -pre-commit = "*" [build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" -[tool.ruff] -line-length = 120 -select = ["E", "F", "ANN", "UP", "N", "C4", "B", "A", "YTT", "W", "FBT", "Q", "RUF", "I"] -ignore = [ - "ANN101", # no type for self - "ANN102", # no type for cls -] -unfixable = ["B", "RUF"] - -[tool.ruff.flake8-annotations] -allow-star-arg-any = true -suppress-none-returning = true - -[tool.mypy] -files = "smart_contracts/" -python_version = "3.12" -check_untyped_defs = true -warn_redundant_casts = true -warn_unused_ignores = true -allow_untyped_defs = false -strict_equality = true From 441e3f8d67e3d513b0df7177fa5cf4969844fd5d Mon Sep 17 00:00:00 2001 From: Altynbek Orumbayev Date: Mon, 11 Mar 2024 18:18:17 +0100 Subject: [PATCH 03/29] docs: refresh readme --- .../production_puya_smart_contract_python/README.md | 4 +++- .../production_puya_smart_contract_typescript/README.md | 4 +++- examples/production_puya/README.md | 4 +++- template_content/README.md.jinja | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/examples/generators/production_puya_smart_contract_python/README.md b/examples/generators/production_puya_smart_contract_python/README.md index 61056c0..be59082 100644 --- a/examples/generators/production_puya_smart_contract_python/README.md +++ b/examples/generators/production_puya_smart_contract_python/README.md @@ -48,7 +48,9 @@ This project has been generated using AlgoKit. See below for default getting sta > For guidance on `smart_contracts` folder and adding new contracts to the project please see [README](smart_contracts/README.md) on the respective folder.### 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. +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. + +> 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. ### Debugging Smart Contracts diff --git a/examples/generators/production_puya_smart_contract_typescript/README.md b/examples/generators/production_puya_smart_contract_typescript/README.md index e85ce05..de8c5f6 100644 --- a/examples/generators/production_puya_smart_contract_typescript/README.md +++ b/examples/generators/production_puya_smart_contract_typescript/README.md @@ -49,7 +49,9 @@ This project has been generated using AlgoKit. See below for default getting sta > For guidance on `smart_contracts` folder and adding new contracts to the project please see [README](smart_contracts/README.md) on the respective folder.### 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. +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. + +> 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. ### Debugging Smart Contracts diff --git a/examples/production_puya/README.md b/examples/production_puya/README.md index 30f1681..748efba 100644 --- a/examples/production_puya/README.md +++ b/examples/production_puya/README.md @@ -48,7 +48,9 @@ This project has been generated using AlgoKit. See below for default getting sta > For guidance on `smart_contracts` folder and adding new contracts to the project please see [README](smart_contracts/README.md) on the respective folder.### 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. +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. + +> 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. ### Debugging Smart Contracts diff --git a/template_content/README.md.jinja b/template_content/README.md.jinja index d8db073..1486e1c 100644 --- a/template_content/README.md.jinja +++ b/template_content/README.md.jinja @@ -54,7 +54,9 @@ This project has been generated using AlgoKit. See below for default getting sta {%- if use_github_actions -%} ### 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. +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](`{% if use_workspace %}../../.github/workflows{% else %}.github/workflows{% endif %}`) folder. + +> 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. ### Debugging Smart Contracts From 1497a7c0251590305c3c173516f32ff0085133a5 Mon Sep 17 00:00:00 2001 From: Altynbek Orumbayev Date: Mon, 11 Mar 2024 18:50:10 +0100 Subject: [PATCH 04/29] chore: bumping min version --- .github/workflows/check-python.yaml | 3 ++- template_content/.algokit.toml.jinja | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check-python.yaml b/.github/workflows/check-python.yaml index 830f03f..91386be 100644 --- a/.github/workflows/check-python.yaml +++ b/.github/workflows/check-python.yaml @@ -14,7 +14,8 @@ jobs: run: pipx install poetry - name: Install algokit - run: pipx install algokit + # TODO: restore to algokit prior to release + run: pipx install git+https://github.com/algorandfoundation/algokit-cli@feat/orchestration-linking - name: Set up Python 3.12 uses: actions/setup-python@v5 diff --git a/template_content/.algokit.toml.jinja b/template_content/.algokit.toml.jinja index bb8cbec..c36b1bb 100644 --- a/template_content/.algokit.toml.jinja +++ b/template_content/.algokit.toml.jinja @@ -1,5 +1,5 @@ [algokit] -min_version = "v1.8.0" +min_version = "v1.12.1" [generate.smart_contract] description = "Adds new smart contract to existing project" From 0c505dbf2cde5d9277e5aa52f2160b08a126c632 Mon Sep 17 00:00:00 2001 From: Altynbek Orumbayev Date: Mon, 11 Mar 2024 19:33:36 +0100 Subject: [PATCH 05/29] chore: bump min version --- .../production_puya_smart_contract_python/.algokit.toml | 2 +- .../production_puya_smart_contract_typescript/.algokit.toml | 2 +- .../generators/starter_puya_smart_contract_python/.algokit.toml | 2 +- .../starter_puya_smart_contract_typescript/.algokit.toml | 2 +- examples/production_puya/.algokit.toml | 2 +- examples/starter_puya/.algokit.toml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/generators/production_puya_smart_contract_python/.algokit.toml b/examples/generators/production_puya_smart_contract_python/.algokit.toml index 3cf5b6a..80544f4 100644 --- a/examples/generators/production_puya_smart_contract_python/.algokit.toml +++ b/examples/generators/production_puya_smart_contract_python/.algokit.toml @@ -1,5 +1,5 @@ [algokit] -min_version = "v1.8.0" +min_version = "v1.12.1" [generate.smart_contract] description = "Adds new smart contract to existing project" diff --git a/examples/generators/production_puya_smart_contract_typescript/.algokit.toml b/examples/generators/production_puya_smart_contract_typescript/.algokit.toml index 19ce2e7..54f2ec0 100644 --- a/examples/generators/production_puya_smart_contract_typescript/.algokit.toml +++ b/examples/generators/production_puya_smart_contract_typescript/.algokit.toml @@ -1,5 +1,5 @@ [algokit] -min_version = "v1.8.0" +min_version = "v1.12.1" [generate.smart_contract] description = "Adds new smart contract to existing project" diff --git a/examples/generators/starter_puya_smart_contract_python/.algokit.toml b/examples/generators/starter_puya_smart_contract_python/.algokit.toml index e63b725..fe75e3e 100644 --- a/examples/generators/starter_puya_smart_contract_python/.algokit.toml +++ b/examples/generators/starter_puya_smart_contract_python/.algokit.toml @@ -1,5 +1,5 @@ [algokit] -min_version = "v1.8.0" +min_version = "v1.12.1" [generate.smart_contract] description = "Adds new smart contract to existing project" diff --git a/examples/generators/starter_puya_smart_contract_typescript/.algokit.toml b/examples/generators/starter_puya_smart_contract_typescript/.algokit.toml index 8e601ad..f382c2d 100644 --- a/examples/generators/starter_puya_smart_contract_typescript/.algokit.toml +++ b/examples/generators/starter_puya_smart_contract_typescript/.algokit.toml @@ -1,5 +1,5 @@ [algokit] -min_version = "v1.8.0" +min_version = "v1.12.1" [generate.smart_contract] description = "Adds new smart contract to existing project" diff --git a/examples/production_puya/.algokit.toml b/examples/production_puya/.algokit.toml index d3d76d9..86892ea 100644 --- a/examples/production_puya/.algokit.toml +++ b/examples/production_puya/.algokit.toml @@ -1,5 +1,5 @@ [algokit] -min_version = "v1.8.0" +min_version = "v1.12.1" [generate.smart_contract] description = "Adds new smart contract to existing project" diff --git a/examples/starter_puya/.algokit.toml b/examples/starter_puya/.algokit.toml index 4eb0f71..53c6922 100644 --- a/examples/starter_puya/.algokit.toml +++ b/examples/starter_puya/.algokit.toml @@ -1,5 +1,5 @@ [algokit] -min_version = "v1.8.0" +min_version = "v1.12.1" [generate.smart_contract] description = "Adds new smart contract to existing project" From 980831ea6706aebab7792946f958f99dfaf243d3 Mon Sep 17 00:00:00 2001 From: Al Date: Fri, 15 Mar 2024 16:51:50 +0100 Subject: [PATCH 06/29] chore: apply suggestions from code review Co-authored-by: Neil Campbell --- .../production_puya_smart_contract_python/.algokit.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/generators/production_puya_smart_contract_python/.algokit.toml b/examples/generators/production_puya_smart_contract_python/.algokit.toml index 80544f4..9988492 100644 --- a/examples/generators/production_puya_smart_contract_python/.algokit.toml +++ b/examples/generators/production_puya_smart_contract_python/.algokit.toml @@ -21,7 +21,7 @@ environment_secrets = [ environment_secrets = [] [project.run] -# Commands intented for use locally and in CI +# Commands intended for use locally and in CI build = { commands = [ 'poetry run python -m smart_contracts build', ], description = 'Build all smart contracts in the project' } @@ -42,7 +42,7 @@ audit-teal = { commands = [ 'algokit task analyze smart_contracts/artifacts --recursive --force --exclude rekey-to --exclude is-updatable --exclude missing-fee-check --exclude is-deletable --exclude can-close-asset --exclude can-close-account --exclude unprotected-deletable --exclude unprotected-updatable', ], description = 'Audit TEAL files' } -# Commands indented for CI only, prefixed with `ci-` by convention +# Commands intended for CI only are prefixed with `ci-` by convention ci-teal-diff = { commands = [ 'git add -N ./smart_contracts/artifacts', 'git diff --exit-code --minimal ./smart_contracts/artifacts', From 4927795fbd1a1289b1a45087811126767dcfc941 Mon Sep 17 00:00:00 2001 From: Altynbek Orumbayev Date: Fri, 15 Mar 2024 16:53:42 +0100 Subject: [PATCH 07/29] chore: regen examples --- .../production_puya_smart_contract_python/.algokit.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/generators/production_puya_smart_contract_python/.algokit.toml b/examples/generators/production_puya_smart_contract_python/.algokit.toml index 9988492..80544f4 100644 --- a/examples/generators/production_puya_smart_contract_python/.algokit.toml +++ b/examples/generators/production_puya_smart_contract_python/.algokit.toml @@ -21,7 +21,7 @@ environment_secrets = [ environment_secrets = [] [project.run] -# Commands intended for use locally and in CI +# Commands intented for use locally and in CI build = { commands = [ 'poetry run python -m smart_contracts build', ], description = 'Build all smart contracts in the project' } @@ -42,7 +42,7 @@ audit-teal = { commands = [ 'algokit task analyze smart_contracts/artifacts --recursive --force --exclude rekey-to --exclude is-updatable --exclude missing-fee-check --exclude is-deletable --exclude can-close-asset --exclude can-close-account --exclude unprotected-deletable --exclude unprotected-updatable', ], description = 'Audit TEAL files' } -# Commands intended for CI only are prefixed with `ci-` by convention +# Commands indented for CI only, prefixed with `ci-` by convention ci-teal-diff = { commands = [ 'git add -N ./smart_contracts/artifacts', 'git diff --exit-code --minimal ./smart_contracts/artifacts', From 2973caf83dfbb8ee0e868655da1cf345570bd335 Mon Sep 17 00:00:00 2001 From: Altynbek Orumbayev Date: Tue, 19 Mar 2024 18:08:14 +0100 Subject: [PATCH 08/29] chore: swapping to final prerelease branch --- .github/workflows/check-python.yaml | 2 +- .../workflows/production-puya-smart-contract-python-cd.yaml | 2 +- .../workflows/production-puya-smart-contract-python-ci.yaml | 2 +- .../workflows/production-puya-smart-contract-typescript-cd.yaml | 2 +- .../workflows/production-puya-smart-contract-typescript-ci.yaml | 2 +- .../production_puya/.github/workflows/production-puya-cd.yaml | 2 +- .../production_puya/.github/workflows/production-puya-ci.yaml | 2 +- ...oin('includes', 'project_name_kebab.jinja') %}-cd.yaml.jinja | 2 +- ...oin('includes', 'project_name_kebab.jinja') %}-ci.yaml.jinja | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/check-python.yaml b/.github/workflows/check-python.yaml index 91386be..dbb83af 100644 --- a/.github/workflows/check-python.yaml +++ b/.github/workflows/check-python.yaml @@ -15,7 +15,7 @@ jobs: - name: Install algokit # TODO: restore to algokit prior to release - run: pipx install git+https://github.com/algorandfoundation/algokit-cli@feat/orchestration-linking + run: pipx install git+https://github.com/algorandfoundation/algokit-cli@feat/command_orchestration - name: Set up Python 3.12 uses: actions/setup-python@v5 diff --git a/examples/generators/production_puya_smart_contract_python/.github/workflows/production-puya-smart-contract-python-cd.yaml b/examples/generators/production_puya_smart_contract_python/.github/workflows/production-puya-smart-contract-python-cd.yaml index 274433c..b342776 100644 --- a/examples/generators/production_puya_smart_contract_python/.github/workflows/production-puya-smart-contract-python-cd.yaml +++ b/examples/generators/production_puya_smart_contract_python/.github/workflows/production-puya-smart-contract-python-cd.yaml @@ -28,7 +28,7 @@ jobs: cache: "poetry" - name: Install algokit - run: pipx install git+https://github.com/algorandfoundation/algokit-cli@feat/orchestration-linking + run: pipx install git+https://github.com/algorandfoundation/algokit-cli@feat/command_orchestration - name: Bootstrap dependencies run: algokit bootstrap all --project-name 'production_puya_smart_contract_python' diff --git a/examples/generators/production_puya_smart_contract_python/.github/workflows/production-puya-smart-contract-python-ci.yaml b/examples/generators/production_puya_smart_contract_python/.github/workflows/production-puya-smart-contract-python-ci.yaml index 9088486..9aff089 100644 --- a/examples/generators/production_puya_smart_contract_python/.github/workflows/production-puya-smart-contract-python-ci.yaml +++ b/examples/generators/production_puya_smart_contract_python/.github/workflows/production-puya-smart-contract-python-ci.yaml @@ -21,7 +21,7 @@ jobs: cache: "poetry" - name: Install algokit - run: pipx install git+https://github.com/algorandfoundation/algokit-cli@feat/orchestration-linking + run: pipx install git+https://github.com/algorandfoundation/algokit-cli@feat/command_orchestration - name: Start LocalNet run: algokit localnet start diff --git a/examples/generators/production_puya_smart_contract_typescript/.github/workflows/production-puya-smart-contract-typescript-cd.yaml b/examples/generators/production_puya_smart_contract_typescript/.github/workflows/production-puya-smart-contract-typescript-cd.yaml index eb10c65..133e288 100644 --- a/examples/generators/production_puya_smart_contract_typescript/.github/workflows/production-puya-smart-contract-typescript-cd.yaml +++ b/examples/generators/production_puya_smart_contract_typescript/.github/workflows/production-puya-smart-contract-typescript-cd.yaml @@ -28,7 +28,7 @@ jobs: cache: "poetry" - name: Install algokit - run: pipx install git+https://github.com/algorandfoundation/algokit-cli@feat/orchestration-linking + run: pipx install git+https://github.com/algorandfoundation/algokit-cli@feat/command_orchestration - name: Bootstrap dependencies run: algokit bootstrap all --project-name 'production_puya_smart_contract_typescript' diff --git a/examples/generators/production_puya_smart_contract_typescript/.github/workflows/production-puya-smart-contract-typescript-ci.yaml b/examples/generators/production_puya_smart_contract_typescript/.github/workflows/production-puya-smart-contract-typescript-ci.yaml index 7671147..acca1ee 100644 --- a/examples/generators/production_puya_smart_contract_typescript/.github/workflows/production-puya-smart-contract-typescript-ci.yaml +++ b/examples/generators/production_puya_smart_contract_typescript/.github/workflows/production-puya-smart-contract-typescript-ci.yaml @@ -21,7 +21,7 @@ jobs: cache: "poetry" - name: Install algokit - run: pipx install git+https://github.com/algorandfoundation/algokit-cli@feat/orchestration-linking + run: pipx install git+https://github.com/algorandfoundation/algokit-cli@feat/command_orchestration - name: Start LocalNet run: algokit localnet start diff --git a/examples/production_puya/.github/workflows/production-puya-cd.yaml b/examples/production_puya/.github/workflows/production-puya-cd.yaml index a40f6e8..124f9b7 100644 --- a/examples/production_puya/.github/workflows/production-puya-cd.yaml +++ b/examples/production_puya/.github/workflows/production-puya-cd.yaml @@ -28,7 +28,7 @@ jobs: cache: "poetry" - name: Install algokit - run: pipx install git+https://github.com/algorandfoundation/algokit-cli@feat/orchestration-linking + run: pipx install git+https://github.com/algorandfoundation/algokit-cli@feat/command_orchestration - name: Bootstrap dependencies run: algokit bootstrap all --project-name 'production_puya' diff --git a/examples/production_puya/.github/workflows/production-puya-ci.yaml b/examples/production_puya/.github/workflows/production-puya-ci.yaml index 4dc8da2..bd5566d 100644 --- a/examples/production_puya/.github/workflows/production-puya-ci.yaml +++ b/examples/production_puya/.github/workflows/production-puya-ci.yaml @@ -21,7 +21,7 @@ jobs: cache: "poetry" - name: Install algokit - run: pipx install git+https://github.com/algorandfoundation/algokit-cli@feat/orchestration-linking + run: pipx install git+https://github.com/algorandfoundation/algokit-cli@feat/command_orchestration - name: Start LocalNet run: algokit localnet start diff --git a/template_content/{% if use_github_actions %}.github{% endif %}/workflows/{% include pathjoin('includes', 'project_name_kebab.jinja') %}-cd.yaml.jinja b/template_content/{% if use_github_actions %}.github{% endif %}/workflows/{% include pathjoin('includes', 'project_name_kebab.jinja') %}-cd.yaml.jinja index b7a2bbd..25f0729 100644 --- a/template_content/{% if use_github_actions %}.github{% endif %}/workflows/{% include pathjoin('includes', 'project_name_kebab.jinja') %}-cd.yaml.jinja +++ b/template_content/{% if use_github_actions %}.github{% endif %}/workflows/{% include pathjoin('includes', 'project_name_kebab.jinja') %}-cd.yaml.jinja @@ -33,7 +33,7 @@ jobs: cache: "poetry" - name: Install algokit - run: pipx install git+https://github.com/algorandfoundation/algokit-cli@feat/orchestration-linking + run: pipx install git+https://github.com/algorandfoundation/algokit-cli@feat/command_orchestration - name: Bootstrap dependencies run: algokit bootstrap all --project-name '{{ project_name }}' diff --git a/template_content/{% if use_github_actions %}.github{% endif %}/workflows/{% include pathjoin('includes', 'project_name_kebab.jinja') %}-ci.yaml.jinja b/template_content/{% if use_github_actions %}.github{% endif %}/workflows/{% include pathjoin('includes', 'project_name_kebab.jinja') %}-ci.yaml.jinja index 80197f7..1279123 100644 --- a/template_content/{% if use_github_actions %}.github{% endif %}/workflows/{% include pathjoin('includes', 'project_name_kebab.jinja') %}-ci.yaml.jinja +++ b/template_content/{% if use_github_actions %}.github{% endif %}/workflows/{% include pathjoin('includes', 'project_name_kebab.jinja') %}-ci.yaml.jinja @@ -24,7 +24,7 @@ jobs: cache: "poetry" - name: Install algokit - run: pipx install git+https://github.com/algorandfoundation/algokit-cli@feat/orchestration-linking + run: pipx install git+https://github.com/algorandfoundation/algokit-cli@feat/command_orchestration - name: Start LocalNet run: algokit localnet start From 4b415ea85059780d34577292d4d0ef8a8247d721 Mon Sep 17 00:00:00 2001 From: Neil Campbell Date: Sat, 23 Mar 2024 00:01:13 +0800 Subject: [PATCH 09/29] chore: change build and deploy to use new .ar32.json app specs --- .../getting-started-with-your-algokit-project.tour | 2 +- .../.vscode/settings.json | 4 ++-- .../pyproject.toml | 2 +- .../smart_contracts/__main__.py | 7 ++++++- .../smart_contracts/helpers/build.py | 10 ++++++++-- .../smart_contracts/helpers/util.py | 8 ++++++++ .../getting-started-with-your-algokit-project.tour | 2 +- .../.vscode/settings.json | 4 ++-- .../pyproject.toml | 2 +- .../smart_contracts/helpers/build.py | 10 ++++++++-- .../smart_contracts/helpers/util.py | 8 ++++++++ .../getting-started-with-your-algokit-project.tour | 2 +- .../.vscode/settings.json | 4 ++-- .../starter_puya_smart_contract_python/pyproject.toml | 2 +- .../smart_contracts/__main__.py | 7 ++++++- .../smart_contracts/helpers/build.py | 10 ++++++++-- .../smart_contracts/helpers/util.py | 8 ++++++++ .../getting-started-with-your-algokit-project.tour | 2 +- .../.vscode/settings.json | 4 ++-- .../pyproject.toml | 2 +- .../smart_contracts/helpers/build.py | 10 ++++++++-- .../smart_contracts/helpers/util.py | 8 ++++++++ .../getting-started-with-your-algokit-project.tour | 2 +- examples/production_puya/.vscode/settings.json | 4 ++-- examples/production_puya/pyproject.toml | 2 +- examples/production_puya/smart_contracts/__main__.py | 7 ++++++- .../production_puya/smart_contracts/helpers/build.py | 10 ++++++++-- .../production_puya/smart_contracts/helpers/util.py | 8 ++++++++ .../getting-started-with-your-algokit-project.tour | 2 +- examples/starter_puya/.vscode/settings.json | 4 ++-- examples/starter_puya/pyproject.toml | 2 +- examples/starter_puya/smart_contracts/__main__.py | 7 ++++++- examples/starter_puya/smart_contracts/helpers/build.py | 10 ++++++++-- examples/starter_puya/smart_contracts/helpers/util.py | 8 ++++++++ template_content/pyproject.toml.jinja | 2 +- template_content/smart_contracts/__main__.py.jinja | 7 ++++++- .../smart_contracts/helpers/build.py.jinja | 10 ++++++++-- template_content/smart_contracts/helpers/util.py | 8 ++++++++ ...etting-started-with-your-algokit-project.tour.jinja | 2 +- .../settings.json.jinja | 4 ++-- 40 files changed, 170 insertions(+), 47 deletions(-) create mode 100644 examples/generators/production_puya_smart_contract_python/smart_contracts/helpers/util.py create mode 100644 examples/generators/production_puya_smart_contract_typescript/smart_contracts/helpers/util.py create mode 100644 examples/generators/starter_puya_smart_contract_python/smart_contracts/helpers/util.py create mode 100644 examples/generators/starter_puya_smart_contract_typescript/smart_contracts/helpers/util.py create mode 100644 examples/production_puya/smart_contracts/helpers/util.py create mode 100644 examples/starter_puya/smart_contracts/helpers/util.py create mode 100644 template_content/smart_contracts/helpers/util.py diff --git a/examples/generators/production_puya_smart_contract_python/.tours/getting-started-with-your-algokit-project.tour b/examples/generators/production_puya_smart_contract_python/.tours/getting-started-with-your-algokit-project.tour index c1309a6..6b593eb 100644 --- a/examples/generators/production_puya_smart_contract_python/.tours/getting-started-with-your-algokit-project.tour +++ b/examples/generators/production_puya_smart_contract_python/.tours/getting-started-with-your-algokit-project.tour @@ -50,7 +50,7 @@ { "file": "smart_contracts/__main__.py", "description": "Uncomment the following lines to enable complementary utilities that will generate artifacts required for the [AlgoKit AVM Debugger](https://github.com/algorandfoundation/algokit-avm-vscode-debugger) VSCode plugin available on the [VSCode Extension Marketplace](https://marketplace.visualstudio.com/items?itemName=algorandfoundation.algokit-avm-vscode-debugger). A new folder will be automatically created in the `.algokit` directory with source maps of all TEAL contracts in this workspace, as well as traces that will appear in a folder at the root of the workspace. You can then use the traces as entry points to trigger the debug extension. Make sure to have the `.algokit.toml` file available at the root of the workspace.", - "line": 13 + "line": 15 } ] } diff --git a/examples/generators/production_puya_smart_contract_python/.vscode/settings.json b/examples/generators/production_puya_smart_contract_python/.vscode/settings.json index 0c2dfec..61681c0 100644 --- a/examples/generators/production_puya_smart_contract_python/.vscode/settings.json +++ b/examples/generators/production_puya_smart_contract_python/.vscode/settings.json @@ -17,9 +17,9 @@ "python.defaultInterpreterPath": "${workspaceFolder}/.venv", "[python]": { "editor.codeActionsOnSave": { - "source.fixAll": true, + "source.fixAll": "explicit", // Prevent default import sorting from running; Ruff will sort imports for us anyway - "source.organizeImports": false + "source.organizeImports": "never" }, "editor.defaultFormatter": "ms-python.black-formatter", }, diff --git a/examples/generators/production_puya_smart_contract_python/pyproject.toml b/examples/generators/production_puya_smart_contract_python/pyproject.toml index b38bae5..259ed90 100644 --- a/examples/generators/production_puya_smart_contract_python/pyproject.toml +++ b/examples/generators/production_puya_smart_contract_python/pyproject.toml @@ -9,7 +9,7 @@ readme = "README.md" python = "^3.12" algokit-utils = "^2.2.0" python-dotenv = "^1.0.0" -puya = "^0" +puya = { git = "https://github.com/algorandfoundation/puya.git" } # TODO: Update this once Puya v1.0.0 is released [tool.poetry.group.dev.dependencies] black = {extras = ["d"], version = "*"} diff --git a/examples/generators/production_puya_smart_contract_python/smart_contracts/__main__.py b/examples/generators/production_puya_smart_contract_python/smart_contracts/__main__.py index 7db8a69..aa936c9 100644 --- a/examples/generators/production_puya_smart_contract_python/smart_contracts/__main__.py +++ b/examples/generators/production_puya_smart_contract_python/smart_contracts/__main__.py @@ -7,6 +7,7 @@ from smart_contracts.config import contracts from smart_contracts.helpers.build import build from smart_contracts.helpers.deploy import deploy +from smart_contracts.helpers.util import find_app_spec_file # Uncomment the following lines to enable auto generation of AVM Debugger compliant sourcemap and simulation trace file. # Learn more about using AlgoKit AVM Debugger to debug your TEAL source codes and inspect various kinds of @@ -32,7 +33,11 @@ def main(action: str) -> None: case "deploy": for contract in contracts: logger.info(f"Deploying app {contract.name}") - app_spec_path = artifact_path / contract.name / "application.json" + output_dir = artifact_path / contract.name + app_spec_file_name = find_app_spec_file(output_dir) + if app_spec_file_name is None: + raise Exception("Could not deploy app, .arc32.json file not found") + app_spec_path = output_dir / app_spec_file_name if contract.deploy: deploy(app_spec_path, contract.deploy) case "all": diff --git a/examples/generators/production_puya_smart_contract_python/smart_contracts/helpers/build.py b/examples/generators/production_puya_smart_contract_python/smart_contracts/helpers/build.py index 0dad0c8..439af55 100644 --- a/examples/generators/production_puya_smart_contract_python/smart_contracts/helpers/build.py +++ b/examples/generators/production_puya_smart_contract_python/smart_contracts/helpers/build.py @@ -3,6 +3,8 @@ from pathlib import Path from shutil import rmtree +from smart_contracts.helpers.util import find_app_spec_file + logger = logging.getLogger(__name__) deployment_extension = "py" @@ -30,12 +32,16 @@ def build(output_dir: Path, contract_path: Path) -> Path: if build_result.returncode: raise Exception(f"Could not build contract:\n{build_result.stdout}") + app_spec_file_name = find_app_spec_file(output_dir) + if app_spec_file_name is None: + raise Exception("Could not generate typed client, .arc32.json file not found") + generate_result = subprocess.run( [ "algokit", "generate", "client", - output_dir / "application.json", + output_dir / app_spec_file_name, "--output", output_dir / f"client.{deployment_extension}", ], @@ -53,4 +59,4 @@ def build(output_dir: Path, contract_path: Path) -> Path: raise Exception( f"Could not generate typed client:\n{generate_result.stdout}" ) - return output_dir / "application.json" + return output_dir / app_spec_file_name diff --git a/examples/generators/production_puya_smart_contract_python/smart_contracts/helpers/util.py b/examples/generators/production_puya_smart_contract_python/smart_contracts/helpers/util.py new file mode 100644 index 0000000..6cf7e5b --- /dev/null +++ b/examples/generators/production_puya_smart_contract_python/smart_contracts/helpers/util.py @@ -0,0 +1,8 @@ +from pathlib import Path + + +def find_app_spec_file(output_dir: Path) -> str | None: + for file in output_dir.iterdir(): + if file.is_file() and file.suffixes == [".arc32", ".json"]: + return file.name + return None diff --git a/examples/generators/production_puya_smart_contract_typescript/.tours/getting-started-with-your-algokit-project.tour b/examples/generators/production_puya_smart_contract_typescript/.tours/getting-started-with-your-algokit-project.tour index 30f150f..bd27ad2 100644 --- a/examples/generators/production_puya_smart_contract_typescript/.tours/getting-started-with-your-algokit-project.tour +++ b/examples/generators/production_puya_smart_contract_typescript/.tours/getting-started-with-your-algokit-project.tour @@ -50,7 +50,7 @@ { "file": "smart_contracts/index.ts", "description": "Uncomment the following lines to enable complementary utilities that will generate artifacts required for the [AlgoKit AVM Debugger](https://github.com/algorandfoundation/algokit-avm-vscode-debugger) VSCode plugin available on the [VSCode Extension Marketplace](https://marketplace.visualstudio.com/items?itemName=algorandfoundation.algokit-avm-vscode-debugger). A new folder will be automatically created in the `.algokit` directory with source maps of all TEAL contracts in this workspace, as well as traces that will appear in a folder at the root of the workspace. You can then use the traces as entry points to trigger the debug extension. Make sure to have the `.algokit.toml` file available at the root of the workspace.", - "line": 13 + "line": 15 } ] } diff --git a/examples/generators/production_puya_smart_contract_typescript/.vscode/settings.json b/examples/generators/production_puya_smart_contract_typescript/.vscode/settings.json index af8031f..dd846d7 100644 --- a/examples/generators/production_puya_smart_contract_typescript/.vscode/settings.json +++ b/examples/generators/production_puya_smart_contract_typescript/.vscode/settings.json @@ -20,9 +20,9 @@ "python.defaultInterpreterPath": "${workspaceFolder}/.venv", "[python]": { "editor.codeActionsOnSave": { - "source.fixAll": true, + "source.fixAll": "explicit", // Prevent default import sorting from running; Ruff will sort imports for us anyway - "source.organizeImports": false + "source.organizeImports": "never" }, "editor.defaultFormatter": "ms-python.black-formatter", }, diff --git a/examples/generators/production_puya_smart_contract_typescript/pyproject.toml b/examples/generators/production_puya_smart_contract_typescript/pyproject.toml index 0c90521..823630e 100644 --- a/examples/generators/production_puya_smart_contract_typescript/pyproject.toml +++ b/examples/generators/production_puya_smart_contract_typescript/pyproject.toml @@ -9,7 +9,7 @@ readme = "README.md" python = "^3.12" algokit-utils = "^2.2.0" python-dotenv = "^1.0.0" -puya = "^0" +puya = { git = "https://github.com/algorandfoundation/puya.git" } # TODO: Update this once Puya v1.0.0 is released [tool.poetry.group.dev.dependencies] black = {extras = ["d"], version = "*"} diff --git a/examples/generators/production_puya_smart_contract_typescript/smart_contracts/helpers/build.py b/examples/generators/production_puya_smart_contract_typescript/smart_contracts/helpers/build.py index 67377d3..8f68b02 100644 --- a/examples/generators/production_puya_smart_contract_typescript/smart_contracts/helpers/build.py +++ b/examples/generators/production_puya_smart_contract_typescript/smart_contracts/helpers/build.py @@ -3,6 +3,8 @@ from pathlib import Path from shutil import rmtree +from smart_contracts.helpers.util import find_app_spec_file + logger = logging.getLogger(__name__) deployment_extension = "ts" @@ -30,12 +32,16 @@ def build(output_dir: Path, contract_path: Path) -> Path: if build_result.returncode: raise Exception(f"Could not build contract:\n{build_result.stdout}") + app_spec_file_name = find_app_spec_file(output_dir) + if app_spec_file_name is None: + raise Exception("Could not generate typed client, .arc32.json file not found") + generate_result = subprocess.run( [ "algokit", "generate", "client", - output_dir / "application.json", + output_dir / app_spec_file_name, "--output", output_dir / f"client.{deployment_extension}", ], @@ -53,4 +59,4 @@ def build(output_dir: Path, contract_path: Path) -> Path: raise Exception( f"Could not generate typed client:\n{generate_result.stdout}" ) - return output_dir / "application.json" + return output_dir / app_spec_file_name diff --git a/examples/generators/production_puya_smart_contract_typescript/smart_contracts/helpers/util.py b/examples/generators/production_puya_smart_contract_typescript/smart_contracts/helpers/util.py new file mode 100644 index 0000000..6cf7e5b --- /dev/null +++ b/examples/generators/production_puya_smart_contract_typescript/smart_contracts/helpers/util.py @@ -0,0 +1,8 @@ +from pathlib import Path + + +def find_app_spec_file(output_dir: Path) -> str | None: + for file in output_dir.iterdir(): + if file.is_file() and file.suffixes == [".arc32", ".json"]: + return file.name + return None diff --git a/examples/generators/starter_puya_smart_contract_python/.tours/getting-started-with-your-algokit-project.tour b/examples/generators/starter_puya_smart_contract_python/.tours/getting-started-with-your-algokit-project.tour index c1309a6..6b593eb 100644 --- a/examples/generators/starter_puya_smart_contract_python/.tours/getting-started-with-your-algokit-project.tour +++ b/examples/generators/starter_puya_smart_contract_python/.tours/getting-started-with-your-algokit-project.tour @@ -50,7 +50,7 @@ { "file": "smart_contracts/__main__.py", "description": "Uncomment the following lines to enable complementary utilities that will generate artifacts required for the [AlgoKit AVM Debugger](https://github.com/algorandfoundation/algokit-avm-vscode-debugger) VSCode plugin available on the [VSCode Extension Marketplace](https://marketplace.visualstudio.com/items?itemName=algorandfoundation.algokit-avm-vscode-debugger). A new folder will be automatically created in the `.algokit` directory with source maps of all TEAL contracts in this workspace, as well as traces that will appear in a folder at the root of the workspace. You can then use the traces as entry points to trigger the debug extension. Make sure to have the `.algokit.toml` file available at the root of the workspace.", - "line": 13 + "line": 15 } ] } diff --git a/examples/generators/starter_puya_smart_contract_python/.vscode/settings.json b/examples/generators/starter_puya_smart_contract_python/.vscode/settings.json index 4cf6525..0a9b7c8 100644 --- a/examples/generators/starter_puya_smart_contract_python/.vscode/settings.json +++ b/examples/generators/starter_puya_smart_contract_python/.vscode/settings.json @@ -17,9 +17,9 @@ "python.defaultInterpreterPath": "${workspaceFolder}/.venv", "[python]": { "editor.codeActionsOnSave": { - "source.fixAll": true, + "source.fixAll": "explicit", // Prevent default import sorting from running; Ruff will sort imports for us anyway - "source.organizeImports": false + "source.organizeImports": "never" }, "editor.defaultFormatter": null, }, diff --git a/examples/generators/starter_puya_smart_contract_python/pyproject.toml b/examples/generators/starter_puya_smart_contract_python/pyproject.toml index f9fa94b..1f88c0a 100644 --- a/examples/generators/starter_puya_smart_contract_python/pyproject.toml +++ b/examples/generators/starter_puya_smart_contract_python/pyproject.toml @@ -9,7 +9,7 @@ readme = "README.md" python = "^3.12" algokit-utils = "^2.2.0" python-dotenv = "^1.0.0" -puya = "^0" +puya = { git = "https://github.com/algorandfoundation/puya.git" } # TODO: Update this once Puya v1.0.0 is released [tool.poetry.group.dev.dependencies] diff --git a/examples/generators/starter_puya_smart_contract_python/smart_contracts/__main__.py b/examples/generators/starter_puya_smart_contract_python/smart_contracts/__main__.py index 7db8a69..aa936c9 100644 --- a/examples/generators/starter_puya_smart_contract_python/smart_contracts/__main__.py +++ b/examples/generators/starter_puya_smart_contract_python/smart_contracts/__main__.py @@ -7,6 +7,7 @@ from smart_contracts.config import contracts from smart_contracts.helpers.build import build from smart_contracts.helpers.deploy import deploy +from smart_contracts.helpers.util import find_app_spec_file # Uncomment the following lines to enable auto generation of AVM Debugger compliant sourcemap and simulation trace file. # Learn more about using AlgoKit AVM Debugger to debug your TEAL source codes and inspect various kinds of @@ -32,7 +33,11 @@ def main(action: str) -> None: case "deploy": for contract in contracts: logger.info(f"Deploying app {contract.name}") - app_spec_path = artifact_path / contract.name / "application.json" + output_dir = artifact_path / contract.name + app_spec_file_name = find_app_spec_file(output_dir) + if app_spec_file_name is None: + raise Exception("Could not deploy app, .arc32.json file not found") + app_spec_path = output_dir / app_spec_file_name if contract.deploy: deploy(app_spec_path, contract.deploy) case "all": diff --git a/examples/generators/starter_puya_smart_contract_python/smart_contracts/helpers/build.py b/examples/generators/starter_puya_smart_contract_python/smart_contracts/helpers/build.py index 0dad0c8..439af55 100644 --- a/examples/generators/starter_puya_smart_contract_python/smart_contracts/helpers/build.py +++ b/examples/generators/starter_puya_smart_contract_python/smart_contracts/helpers/build.py @@ -3,6 +3,8 @@ from pathlib import Path from shutil import rmtree +from smart_contracts.helpers.util import find_app_spec_file + logger = logging.getLogger(__name__) deployment_extension = "py" @@ -30,12 +32,16 @@ def build(output_dir: Path, contract_path: Path) -> Path: if build_result.returncode: raise Exception(f"Could not build contract:\n{build_result.stdout}") + app_spec_file_name = find_app_spec_file(output_dir) + if app_spec_file_name is None: + raise Exception("Could not generate typed client, .arc32.json file not found") + generate_result = subprocess.run( [ "algokit", "generate", "client", - output_dir / "application.json", + output_dir / app_spec_file_name, "--output", output_dir / f"client.{deployment_extension}", ], @@ -53,4 +59,4 @@ def build(output_dir: Path, contract_path: Path) -> Path: raise Exception( f"Could not generate typed client:\n{generate_result.stdout}" ) - return output_dir / "application.json" + return output_dir / app_spec_file_name diff --git a/examples/generators/starter_puya_smart_contract_python/smart_contracts/helpers/util.py b/examples/generators/starter_puya_smart_contract_python/smart_contracts/helpers/util.py new file mode 100644 index 0000000..6cf7e5b --- /dev/null +++ b/examples/generators/starter_puya_smart_contract_python/smart_contracts/helpers/util.py @@ -0,0 +1,8 @@ +from pathlib import Path + + +def find_app_spec_file(output_dir: Path) -> str | None: + for file in output_dir.iterdir(): + if file.is_file() and file.suffixes == [".arc32", ".json"]: + return file.name + return None diff --git a/examples/generators/starter_puya_smart_contract_typescript/.tours/getting-started-with-your-algokit-project.tour b/examples/generators/starter_puya_smart_contract_typescript/.tours/getting-started-with-your-algokit-project.tour index 30f150f..bd27ad2 100644 --- a/examples/generators/starter_puya_smart_contract_typescript/.tours/getting-started-with-your-algokit-project.tour +++ b/examples/generators/starter_puya_smart_contract_typescript/.tours/getting-started-with-your-algokit-project.tour @@ -50,7 +50,7 @@ { "file": "smart_contracts/index.ts", "description": "Uncomment the following lines to enable complementary utilities that will generate artifacts required for the [AlgoKit AVM Debugger](https://github.com/algorandfoundation/algokit-avm-vscode-debugger) VSCode plugin available on the [VSCode Extension Marketplace](https://marketplace.visualstudio.com/items?itemName=algorandfoundation.algokit-avm-vscode-debugger). A new folder will be automatically created in the `.algokit` directory with source maps of all TEAL contracts in this workspace, as well as traces that will appear in a folder at the root of the workspace. You can then use the traces as entry points to trigger the debug extension. Make sure to have the `.algokit.toml` file available at the root of the workspace.", - "line": 13 + "line": 15 } ] } diff --git a/examples/generators/starter_puya_smart_contract_typescript/.vscode/settings.json b/examples/generators/starter_puya_smart_contract_typescript/.vscode/settings.json index dfae20d..0bffa07 100644 --- a/examples/generators/starter_puya_smart_contract_typescript/.vscode/settings.json +++ b/examples/generators/starter_puya_smart_contract_typescript/.vscode/settings.json @@ -20,9 +20,9 @@ "python.defaultInterpreterPath": "${workspaceFolder}/.venv", "[python]": { "editor.codeActionsOnSave": { - "source.fixAll": true, + "source.fixAll": "explicit", // Prevent default import sorting from running; Ruff will sort imports for us anyway - "source.organizeImports": false + "source.organizeImports": "never" }, "editor.defaultFormatter": null, }, diff --git a/examples/generators/starter_puya_smart_contract_typescript/pyproject.toml b/examples/generators/starter_puya_smart_contract_typescript/pyproject.toml index 4367309..969c4cd 100644 --- a/examples/generators/starter_puya_smart_contract_typescript/pyproject.toml +++ b/examples/generators/starter_puya_smart_contract_typescript/pyproject.toml @@ -9,7 +9,7 @@ readme = "README.md" python = "^3.12" algokit-utils = "^2.2.0" python-dotenv = "^1.0.0" -puya = "^0" +puya = { git = "https://github.com/algorandfoundation/puya.git" } # TODO: Update this once Puya v1.0.0 is released [tool.poetry.group.dev.dependencies] diff --git a/examples/generators/starter_puya_smart_contract_typescript/smart_contracts/helpers/build.py b/examples/generators/starter_puya_smart_contract_typescript/smart_contracts/helpers/build.py index 67377d3..8f68b02 100644 --- a/examples/generators/starter_puya_smart_contract_typescript/smart_contracts/helpers/build.py +++ b/examples/generators/starter_puya_smart_contract_typescript/smart_contracts/helpers/build.py @@ -3,6 +3,8 @@ from pathlib import Path from shutil import rmtree +from smart_contracts.helpers.util import find_app_spec_file + logger = logging.getLogger(__name__) deployment_extension = "ts" @@ -30,12 +32,16 @@ def build(output_dir: Path, contract_path: Path) -> Path: if build_result.returncode: raise Exception(f"Could not build contract:\n{build_result.stdout}") + app_spec_file_name = find_app_spec_file(output_dir) + if app_spec_file_name is None: + raise Exception("Could not generate typed client, .arc32.json file not found") + generate_result = subprocess.run( [ "algokit", "generate", "client", - output_dir / "application.json", + output_dir / app_spec_file_name, "--output", output_dir / f"client.{deployment_extension}", ], @@ -53,4 +59,4 @@ def build(output_dir: Path, contract_path: Path) -> Path: raise Exception( f"Could not generate typed client:\n{generate_result.stdout}" ) - return output_dir / "application.json" + return output_dir / app_spec_file_name diff --git a/examples/generators/starter_puya_smart_contract_typescript/smart_contracts/helpers/util.py b/examples/generators/starter_puya_smart_contract_typescript/smart_contracts/helpers/util.py new file mode 100644 index 0000000..6cf7e5b --- /dev/null +++ b/examples/generators/starter_puya_smart_contract_typescript/smart_contracts/helpers/util.py @@ -0,0 +1,8 @@ +from pathlib import Path + + +def find_app_spec_file(output_dir: Path) -> str | None: + for file in output_dir.iterdir(): + if file.is_file() and file.suffixes == [".arc32", ".json"]: + return file.name + return None diff --git a/examples/production_puya/.tours/getting-started-with-your-algokit-project.tour b/examples/production_puya/.tours/getting-started-with-your-algokit-project.tour index c1309a6..6b593eb 100644 --- a/examples/production_puya/.tours/getting-started-with-your-algokit-project.tour +++ b/examples/production_puya/.tours/getting-started-with-your-algokit-project.tour @@ -50,7 +50,7 @@ { "file": "smart_contracts/__main__.py", "description": "Uncomment the following lines to enable complementary utilities that will generate artifacts required for the [AlgoKit AVM Debugger](https://github.com/algorandfoundation/algokit-avm-vscode-debugger) VSCode plugin available on the [VSCode Extension Marketplace](https://marketplace.visualstudio.com/items?itemName=algorandfoundation.algokit-avm-vscode-debugger). A new folder will be automatically created in the `.algokit` directory with source maps of all TEAL contracts in this workspace, as well as traces that will appear in a folder at the root of the workspace. You can then use the traces as entry points to trigger the debug extension. Make sure to have the `.algokit.toml` file available at the root of the workspace.", - "line": 13 + "line": 15 } ] } diff --git a/examples/production_puya/.vscode/settings.json b/examples/production_puya/.vscode/settings.json index 0c2dfec..61681c0 100644 --- a/examples/production_puya/.vscode/settings.json +++ b/examples/production_puya/.vscode/settings.json @@ -17,9 +17,9 @@ "python.defaultInterpreterPath": "${workspaceFolder}/.venv", "[python]": { "editor.codeActionsOnSave": { - "source.fixAll": true, + "source.fixAll": "explicit", // Prevent default import sorting from running; Ruff will sort imports for us anyway - "source.organizeImports": false + "source.organizeImports": "never" }, "editor.defaultFormatter": "ms-python.black-formatter", }, diff --git a/examples/production_puya/pyproject.toml b/examples/production_puya/pyproject.toml index 5242a69..ebf3c52 100644 --- a/examples/production_puya/pyproject.toml +++ b/examples/production_puya/pyproject.toml @@ -9,7 +9,7 @@ readme = "README.md" python = "^3.12" algokit-utils = "^2.2.0" python-dotenv = "^1.0.0" -puya = "^0" +puya = { git = "https://github.com/algorandfoundation/puya.git" } # TODO: Update this once Puya v1.0.0 is released [tool.poetry.group.dev.dependencies] black = {extras = ["d"], version = "*"} diff --git a/examples/production_puya/smart_contracts/__main__.py b/examples/production_puya/smart_contracts/__main__.py index 7db8a69..aa936c9 100644 --- a/examples/production_puya/smart_contracts/__main__.py +++ b/examples/production_puya/smart_contracts/__main__.py @@ -7,6 +7,7 @@ from smart_contracts.config import contracts from smart_contracts.helpers.build import build from smart_contracts.helpers.deploy import deploy +from smart_contracts.helpers.util import find_app_spec_file # Uncomment the following lines to enable auto generation of AVM Debugger compliant sourcemap and simulation trace file. # Learn more about using AlgoKit AVM Debugger to debug your TEAL source codes and inspect various kinds of @@ -32,7 +33,11 @@ def main(action: str) -> None: case "deploy": for contract in contracts: logger.info(f"Deploying app {contract.name}") - app_spec_path = artifact_path / contract.name / "application.json" + output_dir = artifact_path / contract.name + app_spec_file_name = find_app_spec_file(output_dir) + if app_spec_file_name is None: + raise Exception("Could not deploy app, .arc32.json file not found") + app_spec_path = output_dir / app_spec_file_name if contract.deploy: deploy(app_spec_path, contract.deploy) case "all": diff --git a/examples/production_puya/smart_contracts/helpers/build.py b/examples/production_puya/smart_contracts/helpers/build.py index 0dad0c8..439af55 100644 --- a/examples/production_puya/smart_contracts/helpers/build.py +++ b/examples/production_puya/smart_contracts/helpers/build.py @@ -3,6 +3,8 @@ from pathlib import Path from shutil import rmtree +from smart_contracts.helpers.util import find_app_spec_file + logger = logging.getLogger(__name__) deployment_extension = "py" @@ -30,12 +32,16 @@ def build(output_dir: Path, contract_path: Path) -> Path: if build_result.returncode: raise Exception(f"Could not build contract:\n{build_result.stdout}") + app_spec_file_name = find_app_spec_file(output_dir) + if app_spec_file_name is None: + raise Exception("Could not generate typed client, .arc32.json file not found") + generate_result = subprocess.run( [ "algokit", "generate", "client", - output_dir / "application.json", + output_dir / app_spec_file_name, "--output", output_dir / f"client.{deployment_extension}", ], @@ -53,4 +59,4 @@ def build(output_dir: Path, contract_path: Path) -> Path: raise Exception( f"Could not generate typed client:\n{generate_result.stdout}" ) - return output_dir / "application.json" + return output_dir / app_spec_file_name diff --git a/examples/production_puya/smart_contracts/helpers/util.py b/examples/production_puya/smart_contracts/helpers/util.py new file mode 100644 index 0000000..6cf7e5b --- /dev/null +++ b/examples/production_puya/smart_contracts/helpers/util.py @@ -0,0 +1,8 @@ +from pathlib import Path + + +def find_app_spec_file(output_dir: Path) -> str | None: + for file in output_dir.iterdir(): + if file.is_file() and file.suffixes == [".arc32", ".json"]: + return file.name + return None diff --git a/examples/starter_puya/.tours/getting-started-with-your-algokit-project.tour b/examples/starter_puya/.tours/getting-started-with-your-algokit-project.tour index c1309a6..6b593eb 100644 --- a/examples/starter_puya/.tours/getting-started-with-your-algokit-project.tour +++ b/examples/starter_puya/.tours/getting-started-with-your-algokit-project.tour @@ -50,7 +50,7 @@ { "file": "smart_contracts/__main__.py", "description": "Uncomment the following lines to enable complementary utilities that will generate artifacts required for the [AlgoKit AVM Debugger](https://github.com/algorandfoundation/algokit-avm-vscode-debugger) VSCode plugin available on the [VSCode Extension Marketplace](https://marketplace.visualstudio.com/items?itemName=algorandfoundation.algokit-avm-vscode-debugger). A new folder will be automatically created in the `.algokit` directory with source maps of all TEAL contracts in this workspace, as well as traces that will appear in a folder at the root of the workspace. You can then use the traces as entry points to trigger the debug extension. Make sure to have the `.algokit.toml` file available at the root of the workspace.", - "line": 13 + "line": 15 } ] } diff --git a/examples/starter_puya/.vscode/settings.json b/examples/starter_puya/.vscode/settings.json index 4cf6525..0a9b7c8 100644 --- a/examples/starter_puya/.vscode/settings.json +++ b/examples/starter_puya/.vscode/settings.json @@ -17,9 +17,9 @@ "python.defaultInterpreterPath": "${workspaceFolder}/.venv", "[python]": { "editor.codeActionsOnSave": { - "source.fixAll": true, + "source.fixAll": "explicit", // Prevent default import sorting from running; Ruff will sort imports for us anyway - "source.organizeImports": false + "source.organizeImports": "never" }, "editor.defaultFormatter": null, }, diff --git a/examples/starter_puya/pyproject.toml b/examples/starter_puya/pyproject.toml index c8511f6..52e605d 100644 --- a/examples/starter_puya/pyproject.toml +++ b/examples/starter_puya/pyproject.toml @@ -9,7 +9,7 @@ readme = "README.md" python = "^3.12" algokit-utils = "^2.2.0" python-dotenv = "^1.0.0" -puya = "^0" +puya = { git = "https://github.com/algorandfoundation/puya.git" } # TODO: Update this once Puya v1.0.0 is released [tool.poetry.group.dev.dependencies] diff --git a/examples/starter_puya/smart_contracts/__main__.py b/examples/starter_puya/smart_contracts/__main__.py index 7db8a69..aa936c9 100644 --- a/examples/starter_puya/smart_contracts/__main__.py +++ b/examples/starter_puya/smart_contracts/__main__.py @@ -7,6 +7,7 @@ from smart_contracts.config import contracts from smart_contracts.helpers.build import build from smart_contracts.helpers.deploy import deploy +from smart_contracts.helpers.util import find_app_spec_file # Uncomment the following lines to enable auto generation of AVM Debugger compliant sourcemap and simulation trace file. # Learn more about using AlgoKit AVM Debugger to debug your TEAL source codes and inspect various kinds of @@ -32,7 +33,11 @@ def main(action: str) -> None: case "deploy": for contract in contracts: logger.info(f"Deploying app {contract.name}") - app_spec_path = artifact_path / contract.name / "application.json" + output_dir = artifact_path / contract.name + app_spec_file_name = find_app_spec_file(output_dir) + if app_spec_file_name is None: + raise Exception("Could not deploy app, .arc32.json file not found") + app_spec_path = output_dir / app_spec_file_name if contract.deploy: deploy(app_spec_path, contract.deploy) case "all": diff --git a/examples/starter_puya/smart_contracts/helpers/build.py b/examples/starter_puya/smart_contracts/helpers/build.py index 0dad0c8..439af55 100644 --- a/examples/starter_puya/smart_contracts/helpers/build.py +++ b/examples/starter_puya/smart_contracts/helpers/build.py @@ -3,6 +3,8 @@ from pathlib import Path from shutil import rmtree +from smart_contracts.helpers.util import find_app_spec_file + logger = logging.getLogger(__name__) deployment_extension = "py" @@ -30,12 +32,16 @@ def build(output_dir: Path, contract_path: Path) -> Path: if build_result.returncode: raise Exception(f"Could not build contract:\n{build_result.stdout}") + app_spec_file_name = find_app_spec_file(output_dir) + if app_spec_file_name is None: + raise Exception("Could not generate typed client, .arc32.json file not found") + generate_result = subprocess.run( [ "algokit", "generate", "client", - output_dir / "application.json", + output_dir / app_spec_file_name, "--output", output_dir / f"client.{deployment_extension}", ], @@ -53,4 +59,4 @@ def build(output_dir: Path, contract_path: Path) -> Path: raise Exception( f"Could not generate typed client:\n{generate_result.stdout}" ) - return output_dir / "application.json" + return output_dir / app_spec_file_name diff --git a/examples/starter_puya/smart_contracts/helpers/util.py b/examples/starter_puya/smart_contracts/helpers/util.py new file mode 100644 index 0000000..6cf7e5b --- /dev/null +++ b/examples/starter_puya/smart_contracts/helpers/util.py @@ -0,0 +1,8 @@ +from pathlib import Path + + +def find_app_spec_file(output_dir: Path) -> str | None: + for file in output_dir.iterdir(): + if file.is_file() and file.suffixes == [".arc32", ".json"]: + return file.name + return None diff --git a/template_content/pyproject.toml.jinja b/template_content/pyproject.toml.jinja index c6a5796..8262ddf 100644 --- a/template_content/pyproject.toml.jinja +++ b/template_content/pyproject.toml.jinja @@ -9,7 +9,7 @@ readme = "README.md" python = "^3.12" algokit-utils = "^2.2.0" python-dotenv = "^1.0.0" -puya = "^0" +puya = { git = "https://github.com/algorandfoundation/puya.git" } # TODO: Update this once Puya v1.0.0 is released [tool.poetry.group.dev.dependencies] {% if use_python_black -%} diff --git a/template_content/smart_contracts/__main__.py.jinja b/template_content/smart_contracts/__main__.py.jinja index c94b3f3..26e6b8a 100644 --- a/template_content/smart_contracts/__main__.py.jinja +++ b/template_content/smart_contracts/__main__.py.jinja @@ -8,6 +8,7 @@ from smart_contracts.config import contracts from smart_contracts.helpers.build import build {% if deployment_language == 'python' -%} from smart_contracts.helpers.deploy import deploy +from smart_contracts.helpers.util import find_app_spec_file # Uncomment the following lines to enable auto generation of AVM Debugger compliant sourcemap and simulation trace file. # Learn more about using AlgoKit AVM Debugger to debug your TEAL source codes and inspect various kinds of @@ -35,7 +36,11 @@ def main(action: str) -> None: case "deploy": for contract in contracts: logger.info(f"Deploying app {contract.name}") - app_spec_path = artifact_path / contract.name / "application.json" + output_dir = artifact_path / contract.name + app_spec_file_name = find_app_spec_file(output_dir) + if app_spec_file_name is None: + raise Exception("Could not deploy app, .arc32.json file not found") + app_spec_path = output_dir / app_spec_file_name if contract.deploy: deploy(app_spec_path, contract.deploy) case "all": diff --git a/template_content/smart_contracts/helpers/build.py.jinja b/template_content/smart_contracts/helpers/build.py.jinja index 8dd7f79..c21ae50 100644 --- a/template_content/smart_contracts/helpers/build.py.jinja +++ b/template_content/smart_contracts/helpers/build.py.jinja @@ -3,6 +3,8 @@ import subprocess from pathlib import Path from shutil import rmtree +from smart_contracts.helpers.util import find_app_spec_file + logger = logging.getLogger(__name__) {% if deployment_language == 'python' -%} deployment_extension = "py" @@ -33,12 +35,16 @@ def build(output_dir: Path, contract_path: Path) -> Path: if build_result.returncode: raise Exception(f"Could not build contract:\n{build_result.stdout}") + app_spec_file_name = find_app_spec_file(output_dir) + if app_spec_file_name is None: + raise Exception("Could not generate typed client, .arc32.json file not found") + generate_result = subprocess.run( [ "algokit", "generate", "client", - output_dir / "application.json", + output_dir / app_spec_file_name, "--output", output_dir / f"client.{deployment_extension}", ], @@ -56,4 +62,4 @@ def build(output_dir: Path, contract_path: Path) -> Path: raise Exception( f"Could not generate typed client:\n{generate_result.stdout}" ) - return output_dir / "application.json" + return output_dir / app_spec_file_name diff --git a/template_content/smart_contracts/helpers/util.py b/template_content/smart_contracts/helpers/util.py new file mode 100644 index 0000000..6cf7e5b --- /dev/null +++ b/template_content/smart_contracts/helpers/util.py @@ -0,0 +1,8 @@ +from pathlib import Path + + +def find_app_spec_file(output_dir: Path) -> str | None: + for file in output_dir.iterdir(): + if file.is_file() and file.suffixes == [".arc32", ".json"]: + return file.name + return None diff --git a/template_content/{% if ide_vscode %}.tours{% endif %}/getting-started-with-your-algokit-project.tour.jinja b/template_content/{% if ide_vscode %}.tours{% endif %}/getting-started-with-your-algokit-project.tour.jinja index ca507d4..e582960 100644 --- a/template_content/{% if ide_vscode %}.tours{% endif %}/getting-started-with-your-algokit-project.tour.jinja +++ b/template_content/{% if ide_vscode %}.tours{% endif %}/getting-started-with-your-algokit-project.tour.jinja @@ -50,7 +50,7 @@ { "file": "smart_contracts/{% if deployment_language == 'python' %}__main__.py{% else %}index.ts{% endif %}", "description": "Uncomment the following lines to enable complementary utilities that will generate artifacts required for the [AlgoKit AVM Debugger](https://github.com/algorandfoundation/algokit-avm-vscode-debugger) VSCode plugin available on the [VSCode Extension Marketplace](https://marketplace.visualstudio.com/items?itemName=algorandfoundation.algokit-avm-vscode-debugger). A new folder will be automatically created in the `.algokit` directory with source maps of all TEAL contracts in this workspace, as well as traces that will appear in a folder at the root of the workspace. You can then use the traces as entry points to trigger the debug extension. Make sure to have the `.algokit.toml` file available at the root of the workspace.", - "line": 13 + "line": 15 } ] } diff --git a/template_content/{% if ide_vscode %}.vscode{% endif %}/settings.json.jinja b/template_content/{% if ide_vscode %}.vscode{% endif %}/settings.json.jinja index 708895f..5c5dd2b 100644 --- a/template_content/{% if ide_vscode %}.vscode{% endif %}/settings.json.jinja +++ b/template_content/{% if ide_vscode %}.vscode{% endif %}/settings.json.jinja @@ -20,9 +20,9 @@ "python.defaultInterpreterPath": "${workspaceFolder}/.venv", "[python]": { "editor.codeActionsOnSave": { - "source.fixAll": true, + "source.fixAll": "explicit", // Prevent default import sorting from running; Ruff will sort imports for us anyway - "source.organizeImports": false + "source.organizeImports": "never" }, {% if use_python_black -%} "editor.defaultFormatter": "ms-python.black-formatter", From 8da8fc67240f41ba7b07a9a55e770d892388af11 Mon Sep 17 00:00:00 2001 From: Neil Campbell Date: Sat, 23 Mar 2024 00:27:35 +0800 Subject: [PATCH 10/29] chore: fix up the ts deployer build command --- .../production_puya_smart_contract_python/.algokit.toml | 2 +- .../.algokit.toml | 6 +++--- .../starter_puya_smart_contract_python/.algokit.toml | 2 +- .../starter_puya_smart_contract_typescript/.algokit.toml | 6 +++--- examples/production_puya/.algokit.toml | 2 +- examples/starter_puya/.algokit.toml | 2 +- template_content/.algokit.toml.jinja | 8 +------- 7 files changed, 11 insertions(+), 17 deletions(-) diff --git a/examples/generators/production_puya_smart_contract_python/.algokit.toml b/examples/generators/production_puya_smart_contract_python/.algokit.toml index 80544f4..097b3ed 100644 --- a/examples/generators/production_puya_smart_contract_python/.algokit.toml +++ b/examples/generators/production_puya_smart_contract_python/.algokit.toml @@ -42,7 +42,7 @@ audit-teal = { commands = [ 'algokit task analyze smart_contracts/artifacts --recursive --force --exclude rekey-to --exclude is-updatable --exclude missing-fee-check --exclude is-deletable --exclude can-close-asset --exclude can-close-account --exclude unprotected-deletable --exclude unprotected-updatable', ], description = 'Audit TEAL files' } -# Commands indented for CI only, prefixed with `ci-` by convention +# Commands intented for CI only, prefixed with `ci-` by convention ci-teal-diff = { commands = [ 'git add -N ./smart_contracts/artifacts', 'git diff --exit-code --minimal ./smart_contracts/artifacts', diff --git a/examples/generators/production_puya_smart_contract_typescript/.algokit.toml b/examples/generators/production_puya_smart_contract_typescript/.algokit.toml index 54f2ec0..6d66731 100644 --- a/examples/generators/production_puya_smart_contract_typescript/.algokit.toml +++ b/examples/generators/production_puya_smart_contract_typescript/.algokit.toml @@ -22,8 +22,8 @@ environment_secrets = [] [project.run] # Commands intented for use locally and in CI -build = { commands = [ - 'npm run build', +build = { commands = [ + 'poetry run python -m smart_contracts build', ], description = 'Build all smart contracts in the project' } test = { commands = [ 'npm run test', @@ -42,7 +42,7 @@ audit-teal = { commands = [ 'algokit task analyze smart_contracts/artifacts --recursive --force --exclude rekey-to --exclude is-updatable --exclude missing-fee-check --exclude is-deletable --exclude can-close-asset --exclude can-close-account --exclude unprotected-deletable --exclude unprotected-updatable', ], description = 'Audit TEAL files' } -# Commands indented for CI only, prefixed with `ci-` by convention +# Commands intented for CI only, prefixed with `ci-` by convention ci-teal-diff = { commands = [ 'git add -N ./smart_contracts/artifacts', 'git diff --exit-code --minimal ./smart_contracts/artifacts', diff --git a/examples/generators/starter_puya_smart_contract_python/.algokit.toml b/examples/generators/starter_puya_smart_contract_python/.algokit.toml index fe75e3e..436d67c 100644 --- a/examples/generators/starter_puya_smart_contract_python/.algokit.toml +++ b/examples/generators/starter_puya_smart_contract_python/.algokit.toml @@ -31,7 +31,7 @@ audit-teal = { commands = [ 'algokit task analyze smart_contracts/artifacts --recursive --force --exclude rekey-to --exclude is-updatable --exclude missing-fee-check --exclude is-deletable --exclude can-close-asset --exclude can-close-account --exclude unprotected-deletable --exclude unprotected-updatable', ], description = 'Audit TEAL files' } -# Commands indented for CI only, prefixed with `ci-` by convention +# Commands intented for CI only, prefixed with `ci-` by convention ci-teal-diff = { commands = [ 'git add -N ./smart_contracts/artifacts', 'git diff --exit-code --minimal ./smart_contracts/artifacts', diff --git a/examples/generators/starter_puya_smart_contract_typescript/.algokit.toml b/examples/generators/starter_puya_smart_contract_typescript/.algokit.toml index f382c2d..071d625 100644 --- a/examples/generators/starter_puya_smart_contract_typescript/.algokit.toml +++ b/examples/generators/starter_puya_smart_contract_typescript/.algokit.toml @@ -21,8 +21,8 @@ environment_secrets = [] [project.run] # Commands intented for use locally and in CI -build = { commands = [ - 'npm run build', +build = { commands = [ + 'poetry run python -m smart_contracts build', ], description = 'Build all smart contracts in the project' } lint = { commands = [ ], description = 'Perform linting' } @@ -31,7 +31,7 @@ audit-teal = { commands = [ 'algokit task analyze smart_contracts/artifacts --recursive --force --exclude rekey-to --exclude is-updatable --exclude missing-fee-check --exclude is-deletable --exclude can-close-asset --exclude can-close-account --exclude unprotected-deletable --exclude unprotected-updatable', ], description = 'Audit TEAL files' } -# Commands indented for CI only, prefixed with `ci-` by convention +# Commands intented for CI only, prefixed with `ci-` by convention ci-teal-diff = { commands = [ 'git add -N ./smart_contracts/artifacts', 'git diff --exit-code --minimal ./smart_contracts/artifacts', diff --git a/examples/production_puya/.algokit.toml b/examples/production_puya/.algokit.toml index 86892ea..40aba2d 100644 --- a/examples/production_puya/.algokit.toml +++ b/examples/production_puya/.algokit.toml @@ -42,7 +42,7 @@ audit-teal = { commands = [ 'algokit task analyze smart_contracts/artifacts --recursive --force --exclude rekey-to --exclude is-updatable --exclude missing-fee-check --exclude is-deletable --exclude can-close-asset --exclude can-close-account --exclude unprotected-deletable --exclude unprotected-updatable', ], description = 'Audit TEAL files' } -# Commands indented for CI only, prefixed with `ci-` by convention +# Commands intented for CI only, prefixed with `ci-` by convention ci-teal-diff = { commands = [ 'git add -N ./smart_contracts/artifacts', 'git diff --exit-code --minimal ./smart_contracts/artifacts', diff --git a/examples/starter_puya/.algokit.toml b/examples/starter_puya/.algokit.toml index 53c6922..9143339 100644 --- a/examples/starter_puya/.algokit.toml +++ b/examples/starter_puya/.algokit.toml @@ -31,7 +31,7 @@ audit-teal = { commands = [ 'algokit task analyze smart_contracts/artifacts --recursive --force --exclude rekey-to --exclude is-updatable --exclude missing-fee-check --exclude is-deletable --exclude can-close-asset --exclude can-close-account --exclude unprotected-deletable --exclude unprotected-updatable', ], description = 'Audit TEAL files' } -# Commands indented for CI only, prefixed with `ci-` by convention +# Commands intented for CI only, prefixed with `ci-` by convention ci-teal-diff = { commands = [ 'git add -N ./smart_contracts/artifacts', 'git diff --exit-code --minimal ./smart_contracts/artifacts', diff --git a/template_content/.algokit.toml.jinja b/template_content/.algokit.toml.jinja index c36b1bb..0fae664 100644 --- a/template_content/.algokit.toml.jinja +++ b/template_content/.algokit.toml.jinja @@ -28,15 +28,9 @@ environment_secrets = [] [project.run] # Commands intented for use locally and in CI -{%- if deployment_language == 'python' %} build = { commands = [ 'poetry run python -m smart_contracts build', ], description = 'Build all smart contracts in the project' } -{%- elif deployment_language == 'typescript' %} -build = { commands = [ - 'npm run build', -], description = 'Build all smart contracts in the project' } -{%- endif %} {%- if deployment_language == 'python' and use_python_pytest %} test = { commands = [ 'poetry run pytest', @@ -70,7 +64,7 @@ audit-teal = { commands = [ 'algokit task analyze smart_contracts/artifacts --recursive --force --exclude rekey-to --exclude is-updatable --exclude missing-fee-check --exclude is-deletable --exclude can-close-asset --exclude can-close-account --exclude unprotected-deletable --exclude unprotected-updatable', ], description = 'Audit TEAL files' } -# Commands indented for CI only, prefixed with `ci-` by convention +# Commands intented for CI only, prefixed with `ci-` by convention ci-teal-diff = { commands = [ 'git add -N ./smart_contracts/artifacts', 'git diff --exit-code --minimal ./smart_contracts/artifacts', From 49dc5db0147ee99e200daf313e33b71d22d401de Mon Sep 17 00:00:00 2001 From: Altynbek Orumbayev Date: Mon, 25 Mar 2024 14:23:48 +0100 Subject: [PATCH 11/29] chore: renaming puya to python --- README.md | 4 ++-- .../.algokit.toml | 2 +- .../generators/create_contract/copier.yaml | 0 .../{{ contract_name }}/contract.py.j2 | 0 .../{{ contract_name }}/deploy_config.py.j2 | 0 .../.copier-answers.yml | 2 +- .../.editorconfig | 0 .../.env.localnet.template | 0 .../.env.template | 0 .../.env.testnet.template | 0 .../.gitattributes | 0 ...ction-python-smart-contract-python-cd.yaml} | 10 +++++----- ...ction-python-smart-contract-python-ci.yaml} | 18 +++++++++--------- .../.gitignore | 0 .../Build_Beaker_application.xml | 2 +- .../Build_Beaker_application____LocalNet.xml | 2 +- .../Build___Deploy_Beaker_application.xml | 2 +- .../Deploy_Built_Beaker_application.xml | 2 +- .../Reset_AlgoKit_LocalNet.xml | 0 .../Start_AlgoKit_LocalNet.xml | 0 .../Stop_AlgoKit_LocalNet.xml | 0 .../.pre-commit-config.yaml | 0 ...ting-started-with-your-algokit-project.tour | 0 .../.vscode/extensions.json | 0 .../.vscode/launch.json | 0 .../.vscode/settings.json | 0 .../.vscode/tasks.json | 0 .../README.md | 4 +--- .../poetry.toml | 0 .../pyproject.toml | 2 +- .../smart_contracts/README.md | 0 .../smart_contracts/__init__.py | 0 .../smart_contracts/__main__.py | 0 .../smart_contracts/config.py | 0 .../smart_contracts/cool_contract/contract.py | 0 .../cool_contract/deploy_config.py | 0 .../smart_contracts/hello_world/contract.py | 0 .../hello_world/deploy_config.py | 0 .../smart_contracts/helpers/__init__.py | 0 .../smart_contracts/helpers/build.py | 0 .../smart_contracts/helpers/deploy.py | 0 .../smart_contracts/helpers/util.py | 0 .../tests/__init__.py | 0 .../tests/conftest.py | 0 .../tests/hello_world_test.py | 0 .../.algokit.toml | 2 +- .../generators/create_contract/copier.yaml | 0 .../{{ contract_name }}/contract.py.j2 | 0 .../{{ contract_name }}/deploy-config.ts.j2 | 0 .../.copier-answers.yml | 2 +- .../.editorconfig | 0 .../.env.localnet.template | 0 .../.env.template | 0 .../.env.testnet.template | 0 .../.gitattributes | 0 ...n-python-smart-contract-typescript-cd.yaml} | 10 +++++----- ...n-python-smart-contract-typescript-ci.yaml} | 18 +++++++++--------- .../.gitignore | 0 .../Build_Beaker_application.xml | 2 +- .../Build_Beaker_application____LocalNet.xml | 2 +- .../Build___Deploy_Beaker_application.xml | 0 .../Deploy_Built_Beaker_application.xml | 0 .../Reset_AlgoKit_LocalNet.xml | 0 .../Start_AlgoKit_LocalNet.xml | 0 .../Stop_AlgoKit_LocalNet.xml | 0 .../.pre-commit-config.yaml | 0 .../.prettierignore | 0 .../.prettierrc.js | 0 ...ting-started-with-your-algokit-project.tour | 0 .../.vscode/extensions.json | 0 .../.vscode/launch.json | 0 .../.vscode/settings.json | 0 .../.vscode/tasks.json | 0 .../README.md | 4 +--- .../jest.config.ts | 0 .../package.json | 0 .../poetry.toml | 0 .../pyproject.toml | 2 +- .../smart_contracts/README.md | 0 .../smart_contracts/__init__.py | 0 .../smart_contracts/__main__.py | 0 .../smart_contracts/config.py | 0 .../smart_contracts/cool_contract/contract.py | 0 .../cool_contract/deploy-config.ts | 0 .../smart_contracts/hello_world/contract.py | 0 .../hello_world/deploy-config.ts | 0 .../smart_contracts/helpers/__init__.py | 0 .../smart_contracts/helpers/build.py | 0 .../smart_contracts/helpers/util.py | 0 .../smart_contracts/index.ts | 0 .../tests/hello-world.spec.ts | 0 .../tsconfig.json | 0 .../.algokit.toml | 2 +- .../generators/create_contract/copier.yaml | 0 .../{{ contract_name }}/contract.py.j2 | 0 .../{{ contract_name }}/deploy_config.py.j2 | 0 .../.copier-answers.yml | 2 +- .../.editorconfig | 0 .../.env.localnet.template | 0 .../.env.template | 0 .../.env.testnet.template | 0 .../.gitattributes | 0 .../.gitignore | 0 ...ting-started-with-your-algokit-project.tour | 0 .../.vscode/extensions.json | 0 .../.vscode/launch.json | 0 .../.vscode/settings.json | 0 .../.vscode/tasks.json | 0 .../README.md | 4 +--- .../poetry.toml | 0 .../pyproject.toml | 2 +- .../smart_contracts/README.md | 0 .../smart_contracts/__init__.py | 0 .../smart_contracts/__main__.py | 0 .../smart_contracts/config.py | 0 .../smart_contracts/cool_contract/contract.py | 0 .../cool_contract/deploy_config.py | 0 .../smart_contracts/hello_world/contract.py | 0 .../hello_world/deploy_config.py | 0 .../smart_contracts/helpers/__init__.py | 0 .../smart_contracts/helpers/build.py | 0 .../smart_contracts/helpers/deploy.py | 0 .../smart_contracts/helpers/util.py | 8 ++++++++ .../.algokit.toml | 2 +- .../generators/create_contract/copier.yaml | 0 .../{{ contract_name }}/contract.py.j2 | 0 .../{{ contract_name }}/deploy-config.ts.j2 | 0 .../.copier-answers.yml | 2 +- .../.editorconfig | 0 .../.env.localnet.template | 0 .../.env.template | 0 .../.env.testnet.template | 0 .../.gitattributes | 0 .../.gitignore | 0 .../.prettierignore | 0 .../.prettierrc.js | 0 ...ting-started-with-your-algokit-project.tour | 0 .../.vscode/extensions.json | 0 .../.vscode/launch.json | 0 .../.vscode/settings.json | 0 .../.vscode/tasks.json | 0 .../README.md | 4 +--- .../package.json | 0 .../poetry.toml | 0 .../pyproject.toml | 2 +- .../smart_contracts/README.md | 0 .../smart_contracts/__init__.py | 0 .../smart_contracts/__main__.py | 0 .../smart_contracts/config.py | 0 .../smart_contracts/cool_contract/contract.py | 0 .../cool_contract/deploy-config.ts | 0 .../smart_contracts/hello_world/contract.py | 0 .../hello_world/deploy-config.ts | 0 .../smart_contracts/helpers/__init__.py | 0 .../smart_contracts/helpers/build.py | 0 .../smart_contracts/helpers/util.py | 8 ++++++++ .../smart_contracts/index.ts | 0 .../tsconfig.json | 0 .../.algokit.toml | 2 +- .../.copier-answers.yml | 2 +- .../.editorconfig | 0 .../.env.localnet.template | 0 .../.env.template | 0 .../.env.testnet.template | 0 .../.gitattributes | 0 .../workflows/production-python-cd.yaml} | 10 +++++----- .../workflows/production-python-ci.yaml} | 18 +++++++++--------- .../.gitignore | 0 .../Build_Beaker_application.xml | 2 +- .../Build_Beaker_application____LocalNet.xml | 2 +- .../Build___Deploy_Beaker_application.xml | 2 +- .../Deploy_Built_Beaker_application.xml | 2 +- .../Reset_AlgoKit_LocalNet.xml | 0 .../Start_AlgoKit_LocalNet.xml | 0 .../Stop_AlgoKit_LocalNet.xml | 0 .../.pre-commit-config.yaml | 0 ...ting-started-with-your-algokit-project.tour | 0 .../.vscode/extensions.json | 0 .../.vscode/launch.json | 0 .../.vscode/settings.json | 0 .../.vscode/tasks.json | 0 .../README.md | 4 +--- .../poetry.toml | 0 .../pyproject.toml | 2 +- .../smart_contracts/README.md | 0 .../smart_contracts/__init__.py | 0 .../smart_contracts/__main__.py | 0 .../smart_contracts/config.py | 0 .../smart_contracts/hello_world/contract.py | 0 .../hello_world/deploy_config.py | 0 .../smart_contracts/helpers/__init__.py | 0 .../smart_contracts/helpers/build.py | 0 .../smart_contracts/helpers/deploy.py | 0 .../smart_contracts/helpers/util.py | 8 ++++++++ .../tests/__init__.py | 0 .../tests/conftest.py | 0 .../tests/hello_world_test.py | 0 .../.algokit.toml | 2 +- .../.copier-answers.yml | 2 +- .../.editorconfig | 0 .../.env.localnet.template | 0 .../.env.template | 0 .../.env.testnet.template | 0 .../.gitattributes | 0 .../.gitignore | 0 ...ting-started-with-your-algokit-project.tour | 0 .../.vscode/extensions.json | 0 .../.vscode/launch.json | 0 .../.vscode/settings.json | 0 .../.vscode/tasks.json | 0 .../README.md | 4 +--- .../poetry.toml | 0 .../pyproject.toml | 2 +- .../smart_contracts/README.md | 0 .../smart_contracts/__init__.py | 0 .../smart_contracts/__main__.py | 0 .../smart_contracts/config.py | 0 .../smart_contracts/hello_world/contract.py | 0 .../hello_world/deploy_config.py | 0 .../smart_contracts/helpers/__init__.py | 0 .../smart_contracts/helpers/build.py | 0 .../smart_contracts/helpers/deploy.py | 0 .../smart_contracts/helpers/util.py | 8 ++++++++ template_content/README.md.jinja | 2 -- tests/test_generators.py | 4 ++-- tests/test_templates.py | 2 +- 226 files changed, 113 insertions(+), 95 deletions(-) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/.algokit.toml (97%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/.algokit/generators/create_contract/copier.yaml (100%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/contract.py.j2 (100%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/deploy_config.py.j2 (100%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/.copier-answers.yml (80%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/.editorconfig (100%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/.env.localnet.template (100%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/.env.template (100%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/.env.testnet.template (100%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/.gitattributes (100%) rename examples/generators/{production_puya_smart_contract_python/.github/workflows/production-puya-smart-contract-python-cd.yaml => production_python_smart_contract_python/.github/workflows/production-python-smart-contract-python-cd.yaml} (80%) rename examples/generators/{production_puya_smart_contract_python/.github/workflows/production-puya-smart-contract-python-ci.yaml => production_python_smart_contract_python/.github/workflows/production-python-smart-contract-python-ci.yaml} (78%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/.gitignore (100%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/.idea/runConfigurations/Build_Beaker_application.xml (96%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/.idea/runConfigurations/Build_Beaker_application____LocalNet.xml (96%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/.idea/runConfigurations/Build___Deploy_Beaker_application.xml (96%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/.idea/runConfigurations/Deploy_Built_Beaker_application.xml (96%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/.idea/runConfigurations/Reset_AlgoKit_LocalNet.xml (100%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/.idea/runConfigurations/Start_AlgoKit_LocalNet.xml (100%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/.idea/runConfigurations/Stop_AlgoKit_LocalNet.xml (100%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/.pre-commit-config.yaml (100%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/.tours/getting-started-with-your-algokit-project.tour (100%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/.vscode/extensions.json (100%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/.vscode/launch.json (100%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/.vscode/settings.json (100%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/.vscode/tasks.json (100%) rename examples/{production_puya => generators/production_python_smart_contract_python}/README.md (98%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/poetry.toml (100%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/pyproject.toml (95%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/smart_contracts/README.md (100%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/smart_contracts/__init__.py (100%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/smart_contracts/__main__.py (100%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/smart_contracts/config.py (100%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/smart_contracts/cool_contract/contract.py (100%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/smart_contracts/cool_contract/deploy_config.py (100%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/smart_contracts/hello_world/contract.py (100%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/smart_contracts/hello_world/deploy_config.py (100%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/smart_contracts/helpers/__init__.py (100%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/smart_contracts/helpers/build.py (100%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/smart_contracts/helpers/deploy.py (100%) rename examples/{production_puya => generators/production_python_smart_contract_python}/smart_contracts/helpers/util.py (100%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/tests/__init__.py (100%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/tests/conftest.py (100%) rename examples/generators/{production_puya_smart_contract_python => production_python_smart_contract_python}/tests/hello_world_test.py (100%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/.algokit.toml (97%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/.algokit/generators/create_contract/copier.yaml (100%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/contract.py.j2 (100%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/deploy-config.ts.j2 (100%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/.copier-answers.yml (79%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/.editorconfig (100%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/.env.localnet.template (100%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/.env.template (100%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/.env.testnet.template (100%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/.gitattributes (100%) rename examples/generators/{production_puya_smart_contract_typescript/.github/workflows/production-puya-smart-contract-typescript-cd.yaml => production_python_smart_contract_typescript/.github/workflows/production-python-smart-contract-typescript-cd.yaml} (79%) rename examples/generators/{production_puya_smart_contract_typescript/.github/workflows/production-puya-smart-contract-typescript-ci.yaml => production_python_smart_contract_typescript/.github/workflows/production-python-smart-contract-typescript-ci.yaml} (76%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/.gitignore (100%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/.idea/runConfigurations/Build_Beaker_application.xml (96%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/.idea/runConfigurations/Build_Beaker_application____LocalNet.xml (96%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/.idea/runConfigurations/Build___Deploy_Beaker_application.xml (100%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/.idea/runConfigurations/Deploy_Built_Beaker_application.xml (100%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/.idea/runConfigurations/Reset_AlgoKit_LocalNet.xml (100%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/.idea/runConfigurations/Start_AlgoKit_LocalNet.xml (100%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/.idea/runConfigurations/Stop_AlgoKit_LocalNet.xml (100%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/.pre-commit-config.yaml (100%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/.prettierignore (100%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/.prettierrc.js (100%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/.tours/getting-started-with-your-algokit-project.tour (100%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/.vscode/extensions.json (100%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/.vscode/launch.json (100%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/.vscode/settings.json (100%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/.vscode/tasks.json (100%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/README.md (98%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/jest.config.ts (100%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/package.json (100%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/poetry.toml (100%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/pyproject.toml (95%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/smart_contracts/README.md (100%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/smart_contracts/__init__.py (100%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/smart_contracts/__main__.py (100%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/smart_contracts/config.py (100%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/smart_contracts/cool_contract/contract.py (100%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/smart_contracts/cool_contract/deploy-config.ts (100%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/smart_contracts/hello_world/contract.py (100%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/smart_contracts/hello_world/deploy-config.ts (100%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/smart_contracts/helpers/__init__.py (100%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/smart_contracts/helpers/build.py (100%) rename examples/{starter_puya => generators/production_python_smart_contract_typescript}/smart_contracts/helpers/util.py (100%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/smart_contracts/index.ts (100%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/tests/hello-world.spec.ts (100%) rename examples/generators/{production_puya_smart_contract_typescript => production_python_smart_contract_typescript}/tsconfig.json (100%) rename examples/generators/{starter_puya_smart_contract_python => starter_python_smart_contract_python}/.algokit.toml (97%) rename examples/generators/{starter_puya_smart_contract_python => starter_python_smart_contract_python}/.algokit/generators/create_contract/copier.yaml (100%) rename examples/generators/{starter_puya_smart_contract_python => starter_python_smart_contract_python}/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/contract.py.j2 (100%) rename examples/generators/{starter_puya_smart_contract_python => starter_python_smart_contract_python}/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/deploy_config.py.j2 (100%) rename examples/generators/{starter_puya_smart_contract_python => starter_python_smart_contract_python}/.copier-answers.yml (80%) rename examples/generators/{starter_puya_smart_contract_python => starter_python_smart_contract_python}/.editorconfig (100%) rename examples/generators/{starter_puya_smart_contract_python => starter_python_smart_contract_python}/.env.localnet.template (100%) rename examples/generators/{starter_puya_smart_contract_python => starter_python_smart_contract_python}/.env.template (100%) rename examples/generators/{starter_puya_smart_contract_python => starter_python_smart_contract_python}/.env.testnet.template (100%) rename examples/generators/{starter_puya_smart_contract_python => starter_python_smart_contract_python}/.gitattributes (100%) rename examples/generators/{starter_puya_smart_contract_python => starter_python_smart_contract_python}/.gitignore (100%) rename examples/generators/{starter_puya_smart_contract_python => starter_python_smart_contract_python}/.tours/getting-started-with-your-algokit-project.tour (100%) rename examples/generators/{starter_puya_smart_contract_python => starter_python_smart_contract_python}/.vscode/extensions.json (100%) rename examples/generators/{starter_puya_smart_contract_python => starter_python_smart_contract_python}/.vscode/launch.json (100%) rename examples/generators/{starter_puya_smart_contract_python => starter_python_smart_contract_python}/.vscode/settings.json (100%) rename examples/generators/{starter_puya_smart_contract_python => starter_python_smart_contract_python}/.vscode/tasks.json (100%) rename examples/{starter_puya => generators/starter_python_smart_contract_python}/README.md (96%) rename examples/generators/{starter_puya_smart_contract_python => starter_python_smart_contract_python}/poetry.toml (100%) rename examples/generators/{starter_puya_smart_contract_python => starter_python_smart_contract_python}/pyproject.toml (90%) rename examples/generators/{starter_puya_smart_contract_python => starter_python_smart_contract_python}/smart_contracts/README.md (100%) rename examples/generators/{starter_puya_smart_contract_python => starter_python_smart_contract_python}/smart_contracts/__init__.py (100%) rename examples/generators/{starter_puya_smart_contract_python => starter_python_smart_contract_python}/smart_contracts/__main__.py (100%) rename examples/generators/{starter_puya_smart_contract_python => starter_python_smart_contract_python}/smart_contracts/config.py (100%) rename examples/generators/{starter_puya_smart_contract_python => starter_python_smart_contract_python}/smart_contracts/cool_contract/contract.py (100%) rename examples/generators/{starter_puya_smart_contract_python => starter_python_smart_contract_python}/smart_contracts/cool_contract/deploy_config.py (100%) rename examples/generators/{starter_puya_smart_contract_python => starter_python_smart_contract_python}/smart_contracts/hello_world/contract.py (100%) rename examples/generators/{starter_puya_smart_contract_python => starter_python_smart_contract_python}/smart_contracts/hello_world/deploy_config.py (100%) rename examples/generators/{starter_puya_smart_contract_python => starter_python_smart_contract_python}/smart_contracts/helpers/__init__.py (100%) rename examples/generators/{starter_puya_smart_contract_python => starter_python_smart_contract_python}/smart_contracts/helpers/build.py (100%) rename examples/generators/{starter_puya_smart_contract_python => starter_python_smart_contract_python}/smart_contracts/helpers/deploy.py (100%) create mode 100644 examples/generators/starter_python_smart_contract_python/smart_contracts/helpers/util.py rename examples/generators/{starter_puya_smart_contract_typescript => starter_python_smart_contract_typescript}/.algokit.toml (96%) rename examples/generators/{starter_puya_smart_contract_typescript => starter_python_smart_contract_typescript}/.algokit/generators/create_contract/copier.yaml (100%) rename examples/generators/{starter_puya_smart_contract_typescript => starter_python_smart_contract_typescript}/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/contract.py.j2 (100%) rename examples/generators/{starter_puya_smart_contract_typescript => starter_python_smart_contract_typescript}/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/deploy-config.ts.j2 (100%) rename examples/generators/{starter_puya_smart_contract_typescript => starter_python_smart_contract_typescript}/.copier-answers.yml (79%) rename examples/generators/{starter_puya_smart_contract_typescript => starter_python_smart_contract_typescript}/.editorconfig (100%) rename examples/generators/{starter_puya_smart_contract_typescript => starter_python_smart_contract_typescript}/.env.localnet.template (100%) rename examples/generators/{starter_puya_smart_contract_typescript => starter_python_smart_contract_typescript}/.env.template (100%) rename examples/generators/{starter_puya_smart_contract_typescript => starter_python_smart_contract_typescript}/.env.testnet.template (100%) rename examples/generators/{starter_puya_smart_contract_typescript => starter_python_smart_contract_typescript}/.gitattributes (100%) rename examples/generators/{starter_puya_smart_contract_typescript => starter_python_smart_contract_typescript}/.gitignore (100%) rename examples/generators/{starter_puya_smart_contract_typescript => starter_python_smart_contract_typescript}/.prettierignore (100%) rename examples/generators/{starter_puya_smart_contract_typescript => starter_python_smart_contract_typescript}/.prettierrc.js (100%) rename examples/generators/{starter_puya_smart_contract_typescript => starter_python_smart_contract_typescript}/.tours/getting-started-with-your-algokit-project.tour (100%) rename examples/generators/{starter_puya_smart_contract_typescript => starter_python_smart_contract_typescript}/.vscode/extensions.json (100%) rename examples/generators/{starter_puya_smart_contract_typescript => starter_python_smart_contract_typescript}/.vscode/launch.json (100%) rename examples/generators/{starter_puya_smart_contract_typescript => starter_python_smart_contract_typescript}/.vscode/settings.json (100%) rename examples/generators/{starter_puya_smart_contract_typescript => starter_python_smart_contract_typescript}/.vscode/tasks.json (100%) rename examples/generators/{starter_puya_smart_contract_typescript => starter_python_smart_contract_typescript}/README.md (96%) rename examples/generators/{starter_puya_smart_contract_typescript => starter_python_smart_contract_typescript}/package.json (100%) rename examples/generators/{starter_puya_smart_contract_typescript => starter_python_smart_contract_typescript}/poetry.toml (100%) rename examples/generators/{starter_puya_smart_contract_typescript => starter_python_smart_contract_typescript}/pyproject.toml (90%) rename examples/generators/{starter_puya_smart_contract_typescript => starter_python_smart_contract_typescript}/smart_contracts/README.md (100%) rename examples/generators/{starter_puya_smart_contract_typescript => starter_python_smart_contract_typescript}/smart_contracts/__init__.py (100%) rename examples/generators/{starter_puya_smart_contract_typescript => starter_python_smart_contract_typescript}/smart_contracts/__main__.py (100%) rename examples/generators/{starter_puya_smart_contract_typescript => starter_python_smart_contract_typescript}/smart_contracts/config.py (100%) rename examples/generators/{starter_puya_smart_contract_typescript => starter_python_smart_contract_typescript}/smart_contracts/cool_contract/contract.py (100%) rename examples/generators/{starter_puya_smart_contract_typescript => starter_python_smart_contract_typescript}/smart_contracts/cool_contract/deploy-config.ts (100%) rename examples/generators/{starter_puya_smart_contract_typescript => starter_python_smart_contract_typescript}/smart_contracts/hello_world/contract.py (100%) rename examples/generators/{starter_puya_smart_contract_typescript => starter_python_smart_contract_typescript}/smart_contracts/hello_world/deploy-config.ts (100%) rename examples/generators/{starter_puya_smart_contract_typescript => starter_python_smart_contract_typescript}/smart_contracts/helpers/__init__.py (100%) rename examples/generators/{starter_puya_smart_contract_typescript => starter_python_smart_contract_typescript}/smart_contracts/helpers/build.py (100%) create mode 100644 examples/generators/starter_python_smart_contract_typescript/smart_contracts/helpers/util.py rename examples/generators/{starter_puya_smart_contract_typescript => starter_python_smart_contract_typescript}/smart_contracts/index.ts (100%) rename examples/generators/{starter_puya_smart_contract_typescript => starter_python_smart_contract_typescript}/tsconfig.json (100%) rename examples/{production_puya => production_python}/.algokit.toml (98%) rename examples/{production_puya => production_python}/.copier-answers.yml (87%) rename examples/{production_puya => production_python}/.editorconfig (100%) rename examples/{production_puya => production_python}/.env.localnet.template (100%) rename examples/{production_puya => production_python}/.env.template (100%) rename examples/{production_puya => production_python}/.env.testnet.template (100%) rename examples/{production_puya => production_python}/.gitattributes (100%) rename examples/{production_puya/.github/workflows/production-puya-cd.yaml => production_python/.github/workflows/production-python-cd.yaml} (86%) rename examples/{production_puya/.github/workflows/production-puya-ci.yaml => production_python/.github/workflows/production-python-ci.yaml} (86%) rename examples/{production_puya => production_python}/.gitignore (100%) rename examples/{production_puya => production_python}/.idea/runConfigurations/Build_Beaker_application.xml (97%) rename examples/{production_puya => production_python}/.idea/runConfigurations/Build_Beaker_application____LocalNet.xml (97%) rename examples/{production_puya => production_python}/.idea/runConfigurations/Build___Deploy_Beaker_application.xml (97%) rename examples/{production_puya => production_python}/.idea/runConfigurations/Deploy_Built_Beaker_application.xml (97%) rename examples/{production_puya => production_python}/.idea/runConfigurations/Reset_AlgoKit_LocalNet.xml (100%) rename examples/{production_puya => production_python}/.idea/runConfigurations/Start_AlgoKit_LocalNet.xml (100%) rename examples/{production_puya => production_python}/.idea/runConfigurations/Stop_AlgoKit_LocalNet.xml (100%) rename examples/{production_puya => production_python}/.pre-commit-config.yaml (100%) rename examples/{production_puya => production_python}/.tours/getting-started-with-your-algokit-project.tour (100%) rename examples/{production_puya => production_python}/.vscode/extensions.json (100%) rename examples/{production_puya => production_python}/.vscode/launch.json (100%) rename examples/{production_puya => production_python}/.vscode/settings.json (100%) rename examples/{production_puya => production_python}/.vscode/tasks.json (100%) rename examples/{generators/production_puya_smart_contract_python => production_python}/README.md (98%) rename examples/{production_puya => production_python}/poetry.toml (100%) rename examples/{production_puya => production_python}/pyproject.toml (97%) rename examples/{production_puya => production_python}/smart_contracts/README.md (100%) rename examples/{production_puya => production_python}/smart_contracts/__init__.py (100%) rename examples/{production_puya => production_python}/smart_contracts/__main__.py (100%) rename examples/{production_puya => production_python}/smart_contracts/config.py (100%) rename examples/{production_puya => production_python}/smart_contracts/hello_world/contract.py (100%) rename examples/{production_puya => production_python}/smart_contracts/hello_world/deploy_config.py (100%) rename examples/{production_puya => production_python}/smart_contracts/helpers/__init__.py (100%) rename examples/{production_puya => production_python}/smart_contracts/helpers/build.py (100%) rename examples/{production_puya => production_python}/smart_contracts/helpers/deploy.py (100%) create mode 100644 examples/production_python/smart_contracts/helpers/util.py rename examples/{production_puya => production_python}/tests/__init__.py (100%) rename examples/{production_puya => production_python}/tests/conftest.py (100%) rename examples/{production_puya => production_python}/tests/hello_world_test.py (100%) rename examples/{starter_puya => starter_python}/.algokit.toml (98%) rename examples/{starter_puya => starter_python}/.copier-answers.yml (88%) rename examples/{starter_puya => starter_python}/.editorconfig (100%) rename examples/{starter_puya => starter_python}/.env.localnet.template (100%) rename examples/{starter_puya => starter_python}/.env.template (100%) rename examples/{starter_puya => starter_python}/.env.testnet.template (100%) rename examples/{starter_puya => starter_python}/.gitattributes (100%) rename examples/{starter_puya => starter_python}/.gitignore (100%) rename examples/{starter_puya => starter_python}/.tours/getting-started-with-your-algokit-project.tour (100%) rename examples/{starter_puya => starter_python}/.vscode/extensions.json (100%) rename examples/{starter_puya => starter_python}/.vscode/launch.json (100%) rename examples/{starter_puya => starter_python}/.vscode/settings.json (100%) rename examples/{starter_puya => starter_python}/.vscode/tasks.json (100%) rename examples/{generators/starter_puya_smart_contract_python => starter_python}/README.md (96%) rename examples/{starter_puya => starter_python}/poetry.toml (100%) rename examples/{starter_puya => starter_python}/pyproject.toml (94%) rename examples/{starter_puya => starter_python}/smart_contracts/README.md (100%) rename examples/{starter_puya => starter_python}/smart_contracts/__init__.py (100%) rename examples/{starter_puya => starter_python}/smart_contracts/__main__.py (100%) rename examples/{starter_puya => starter_python}/smart_contracts/config.py (100%) rename examples/{starter_puya => starter_python}/smart_contracts/hello_world/contract.py (100%) rename examples/{starter_puya => starter_python}/smart_contracts/hello_world/deploy_config.py (100%) rename examples/{starter_puya => starter_python}/smart_contracts/helpers/__init__.py (100%) rename examples/{starter_puya => starter_python}/smart_contracts/helpers/build.py (100%) rename examples/{starter_puya => starter_python}/smart_contracts/helpers/deploy.py (100%) create mode 100644 examples/starter_python/smart_contracts/helpers/util.py diff --git a/README.md b/README.md index bb545b9..60629b4 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,9 @@ --- -This template provides a production-ready baseline for developing and deploying [Puya](https://github.com/algorand-devrel/puya) smart contracts. +This template provides a production-ready baseline for developing and deploying [Puya](https://github.com/algorandfoundation/puya) smart contracts. -To use it [install AlgoKit](https://github.com/algorandfoundation/algokit-cli#readme) and then either pass in `-t puya` to `algokit init` or select the `puya` template. +To use it [install AlgoKit](https://github.com/algorandfoundation/algokit-cli#readme) and then either pass in `-t python` to `algokit init` or select the `python` template. This is one of the official templates used by AlgoKit to initialize an Algorand smart contract project. It's a [Copier template](https://copier.readthedocs.io/en/stable/). diff --git a/examples/generators/production_puya_smart_contract_python/.algokit.toml b/examples/generators/production_python_smart_contract_python/.algokit.toml similarity index 97% rename from examples/generators/production_puya_smart_contract_python/.algokit.toml rename to examples/generators/production_python_smart_contract_python/.algokit.toml index 097b3ed..7ae4f9a 100644 --- a/examples/generators/production_puya_smart_contract_python/.algokit.toml +++ b/examples/generators/production_python_smart_contract_python/.algokit.toml @@ -7,7 +7,7 @@ path = ".algokit/generators/create_contract" [project] type = 'contract' -name = 'production_puya_smart_contract_python' +name = 'production_python_smart_contract_python' artifacts = 'smart_contracts/artifacts' [project.deploy] diff --git a/examples/generators/production_puya_smart_contract_python/.algokit/generators/create_contract/copier.yaml b/examples/generators/production_python_smart_contract_python/.algokit/generators/create_contract/copier.yaml similarity index 100% rename from examples/generators/production_puya_smart_contract_python/.algokit/generators/create_contract/copier.yaml rename to examples/generators/production_python_smart_contract_python/.algokit/generators/create_contract/copier.yaml diff --git a/examples/generators/production_puya_smart_contract_python/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/contract.py.j2 b/examples/generators/production_python_smart_contract_python/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/contract.py.j2 similarity index 100% rename from examples/generators/production_puya_smart_contract_python/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/contract.py.j2 rename to examples/generators/production_python_smart_contract_python/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/contract.py.j2 diff --git a/examples/generators/production_puya_smart_contract_python/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/deploy_config.py.j2 b/examples/generators/production_python_smart_contract_python/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/deploy_config.py.j2 similarity index 100% rename from examples/generators/production_puya_smart_contract_python/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/deploy_config.py.j2 rename to examples/generators/production_python_smart_contract_python/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/deploy_config.py.j2 diff --git a/examples/generators/production_puya_smart_contract_python/.copier-answers.yml b/examples/generators/production_python_smart_contract_python/.copier-answers.yml similarity index 80% rename from examples/generators/production_puya_smart_contract_python/.copier-answers.yml rename to examples/generators/production_python_smart_contract_python/.copier-answers.yml index 46b550e..db599c8 100644 --- a/examples/generators/production_puya_smart_contract_python/.copier-answers.yml +++ b/examples/generators/production_python_smart_contract_python/.copier-answers.yml @@ -6,5 +6,5 @@ author_name: None contract_name: hello_world deployment_language: python preset_name: production -project_name: production_puya_smart_contract_python +project_name: production_python_smart_contract_python diff --git a/examples/generators/production_puya_smart_contract_python/.editorconfig b/examples/generators/production_python_smart_contract_python/.editorconfig similarity index 100% rename from examples/generators/production_puya_smart_contract_python/.editorconfig rename to examples/generators/production_python_smart_contract_python/.editorconfig diff --git a/examples/generators/production_puya_smart_contract_python/.env.localnet.template b/examples/generators/production_python_smart_contract_python/.env.localnet.template similarity index 100% rename from examples/generators/production_puya_smart_contract_python/.env.localnet.template rename to examples/generators/production_python_smart_contract_python/.env.localnet.template diff --git a/examples/generators/production_puya_smart_contract_python/.env.template b/examples/generators/production_python_smart_contract_python/.env.template similarity index 100% rename from examples/generators/production_puya_smart_contract_python/.env.template rename to examples/generators/production_python_smart_contract_python/.env.template diff --git a/examples/generators/production_puya_smart_contract_python/.env.testnet.template b/examples/generators/production_python_smart_contract_python/.env.testnet.template similarity index 100% rename from examples/generators/production_puya_smart_contract_python/.env.testnet.template rename to examples/generators/production_python_smart_contract_python/.env.testnet.template diff --git a/examples/generators/production_puya_smart_contract_python/.gitattributes b/examples/generators/production_python_smart_contract_python/.gitattributes similarity index 100% rename from examples/generators/production_puya_smart_contract_python/.gitattributes rename to examples/generators/production_python_smart_contract_python/.gitattributes diff --git a/examples/generators/production_puya_smart_contract_python/.github/workflows/production-puya-smart-contract-python-cd.yaml b/examples/generators/production_python_smart_contract_python/.github/workflows/production-python-smart-contract-python-cd.yaml similarity index 80% rename from examples/generators/production_puya_smart_contract_python/.github/workflows/production-puya-smart-contract-python-cd.yaml rename to examples/generators/production_python_smart_contract_python/.github/workflows/production-python-smart-contract-python-cd.yaml index b342776..b009df4 100644 --- a/examples/generators/production_puya_smart_contract_python/.github/workflows/production-puya-smart-contract-python-cd.yaml +++ b/examples/generators/production_python_smart_contract_python/.github/workflows/production-python-smart-contract-python-cd.yaml @@ -1,4 +1,4 @@ -name: Release production_puya_smart_contract_python +name: Release production_python_smart_contract_python on: workflow_call: @@ -8,8 +8,8 @@ on: jobs: validate: - name: Validate production_puya_smart_contract_python - uses: ./.github/workflows/production-puya-smart-contract-python-ci.yaml + name: Validate production_python_smart_contract_python + uses: ./.github/workflows/production-python-smart-contract-python-ci.yaml deploy-testnet: runs-on: "ubuntu-latest" needs: validate @@ -31,7 +31,7 @@ jobs: run: pipx install git+https://github.com/algorandfoundation/algokit-cli@feat/command_orchestration - name: Bootstrap dependencies - run: algokit bootstrap all --project-name 'production_puya_smart_contract_python' + run: algokit bootstrap all --project-name 'production_python_smart_contract_python' - name: Configure git shell: bash @@ -40,7 +40,7 @@ jobs: git config --global user.email "actions@github.com" && git config --global user.name "github-actions" - name: Deploy to testnet - run: algokit deploy testnet --project-name 'production_puya_smart_contract_python' + run: algokit deploy testnet --project-name 'production_python_smart_contract_python' env: # This is the account that becomes the creator of the contract DEPLOYER_MNEMONIC: ${{ secrets.DEPLOYER_MNEMONIC }} diff --git a/examples/generators/production_puya_smart_contract_python/.github/workflows/production-puya-smart-contract-python-ci.yaml b/examples/generators/production_python_smart_contract_python/.github/workflows/production-python-smart-contract-python-ci.yaml similarity index 78% rename from examples/generators/production_puya_smart_contract_python/.github/workflows/production-puya-smart-contract-python-ci.yaml rename to examples/generators/production_python_smart_contract_python/.github/workflows/production-python-smart-contract-python-ci.yaml index 9aff089..a5fa7b6 100644 --- a/examples/generators/production_puya_smart_contract_python/.github/workflows/production-puya-smart-contract-python-ci.yaml +++ b/examples/generators/production_python_smart_contract_python/.github/workflows/production-python-smart-contract-python-ci.yaml @@ -1,4 +1,4 @@ -name: Validate production_puya_smart_contract_python +name: Validate production_python_smart_contract_python on: workflow_call: @@ -27,7 +27,7 @@ jobs: run: algokit localnet start - name: Bootstrap dependencies - run: algokit bootstrap all --project-name 'production_puya_smart_contract_python' + run: algokit bootstrap all --project-name 'production_python_smart_contract_python' - name: Configure git shell: bash @@ -36,25 +36,25 @@ jobs: git config --global user.email "actions@github.com" && git config --global user.name "github-actions" - name: Audit python dependencies - run: algokit project run audit --project-name 'production_puya_smart_contract_python' + run: algokit project run audit --project-name 'production_python_smart_contract_python' - name: Lint and format python dependencies - run: algokit project run lint --project-name 'production_puya_smart_contract_python' + run: algokit project run lint --project-name 'production_python_smart_contract_python' - name: Run tests shell: bash run: | set -o pipefail - algokit project run test --project-name 'production_puya_smart_contract_python' + algokit project run test --project-name 'production_python_smart_contract_python' - name: Build smart contracts - run: algokit project run build --project-name 'production_puya_smart_contract_python' + run: algokit project run build --project-name 'production_python_smart_contract_python' - name: Scan TEAL files for issues - run: algokit project run audit-teal --project-name 'production_puya_smart_contract_python' + run: algokit project run audit-teal --project-name 'production_python_smart_contract_python' - name: Check output stability of the smart contracts - run: algokit project run ci-teal-diff --project-name 'production_puya_smart_contract_python' + run: algokit project run ci-teal-diff --project-name 'production_python_smart_contract_python' - name: Run deployer against LocalNet - run: algokit project deploy localnet --project-name 'production_puya_smart_contract_python' + run: algokit project deploy localnet --project-name 'production_python_smart_contract_python' diff --git a/examples/generators/production_puya_smart_contract_python/.gitignore b/examples/generators/production_python_smart_contract_python/.gitignore similarity index 100% rename from examples/generators/production_puya_smart_contract_python/.gitignore rename to examples/generators/production_python_smart_contract_python/.gitignore diff --git a/examples/generators/production_puya_smart_contract_python/.idea/runConfigurations/Build_Beaker_application.xml b/examples/generators/production_python_smart_contract_python/.idea/runConfigurations/Build_Beaker_application.xml similarity index 96% rename from examples/generators/production_puya_smart_contract_python/.idea/runConfigurations/Build_Beaker_application.xml rename to examples/generators/production_python_smart_contract_python/.idea/runConfigurations/Build_Beaker_application.xml index e804ef0..f0a1d62 100644 --- a/examples/generators/production_puya_smart_contract_python/.idea/runConfigurations/Build_Beaker_application.xml +++ b/examples/generators/production_python_smart_contract_python/.idea/runConfigurations/Build_Beaker_application.xml @@ -1,6 +1,6 @@ - +