From 3b2d772d87460dc6d547de278007723652619156 Mon Sep 17 00:00:00 2001 From: Altynbek Orumbayev Date: Fri, 8 Mar 2024 22:33:43 +0100 Subject: [PATCH] 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