From aad31888c75d2e939385643bb688a78084b2fa9b Mon Sep 17 00:00:00 2001 From: Altynbek Orumbayev Date: Fri, 8 Dec 2023 14:49:55 +0100 Subject: [PATCH 1/3] fix: fixing typo in generator's copier yaml file --- .../generators/create_contract/copier.yaml | 12 +- .../.copier-answers.yml | 25 --- .../.env.testnet.template | 3 - .../.gitattributes | 1 - .../.github/workflows/cd.yaml | 50 ----- .../.github/workflows/checks.yaml | 79 -------- .../.github/workflows/pr.yaml | 8 - .../test_preset_name-production/.gitignore | 174 ------------------ .../.vscode/extensions.json | 10 - .../.vscode/launch.json | 31 ---- .../.vscode/settings.json | 49 ----- .../.vscode/tasks.json | 64 ------- .../test_preset_name-production/poetry.toml | 2 - .../generators/create_contract/copier.yaml | 12 +- .../.copier-answers.yml | 4 +- .../smart_contracts/cool_contract/contract.py | 26 --- .../cool_contract/deploy_config.py | 45 ----- .../generators/create_contract/copier.yaml | 12 +- .../.copier-answers.yml | 4 +- .../smart_contracts/cool_contract/contract.py | 26 --- .../cool_contract/deploy-config.ts | 52 ------ .../generators/create_contract/copier.yaml | 12 +- .../generators/create_contract/copier.yaml | 12 +- 23 files changed, 34 insertions(+), 679 deletions(-) delete mode 100644 tests_generated/test_preset_name-production/.copier-answers.yml delete mode 100644 tests_generated/test_preset_name-production/.env.testnet.template delete mode 100644 tests_generated/test_preset_name-production/.gitattributes delete mode 100644 tests_generated/test_preset_name-production/.github/workflows/cd.yaml delete mode 100644 tests_generated/test_preset_name-production/.github/workflows/checks.yaml delete mode 100644 tests_generated/test_preset_name-production/.github/workflows/pr.yaml delete mode 100644 tests_generated/test_preset_name-production/.gitignore delete mode 100644 tests_generated/test_preset_name-production/.vscode/extensions.json delete mode 100644 tests_generated/test_preset_name-production/.vscode/launch.json delete mode 100644 tests_generated/test_preset_name-production/.vscode/settings.json delete mode 100644 tests_generated/test_preset_name-production/.vscode/tasks.json delete mode 100644 tests_generated/test_preset_name-production/poetry.toml delete mode 100644 tests_generated/test_smart_contract_generator_default_production_preset_python/smart_contracts/cool_contract/contract.py delete mode 100644 tests_generated/test_smart_contract_generator_default_production_preset_python/smart_contracts/cool_contract/deploy_config.py delete mode 100644 tests_generated/test_smart_contract_generator_default_production_preset_typescript/smart_contracts/cool_contract/contract.py delete mode 100644 tests_generated/test_smart_contract_generator_default_production_preset_typescript/smart_contracts/cool_contract/deploy-config.ts diff --git a/template_content/.algokit/generators/create_contract/copier.yaml b/template_content/.algokit/generators/create_contract/copier.yaml index ff232a37..73805de0 100644 --- a/template_content/.algokit/generators/create_contract/copier.yaml +++ b/template_content/.algokit/generators/create_contract/copier.yaml @@ -1,10 +1,10 @@ -_task: - - "echo '==== Successfully initialized new smart contract 🚀 ===='" +_tasks: + - "echo '==== Successfully initialized new smart contract 🚀 ===='" contract_name: - type: str - help: Name of your new contract. - placeholder: "my-new-contract" - default: "my-new-contract" + type: str + help: Name of your new contract. + placeholder: "my-new-contract" + default: "my-new-contract" _templates_suffix: ".j2" diff --git a/tests_generated/test_preset_name-production/.copier-answers.yml b/tests_generated/test_preset_name-production/.copier-answers.yml deleted file mode 100644 index 2925fe04..00000000 --- a/tests_generated/test_preset_name-production/.copier-answers.yml +++ /dev/null @@ -1,25 +0,0 @@ -# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY -_commit: -_src_path: -algod_port: 4001 -algod_server: http://localhost -algod_token: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -author_email: None -author_name: None -contract_name: hello_world -deployment_language: python -ide_vscode: true -indexer_port: 8980 -indexer_server: http://localhost -indexer_token: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -preset_name: production -project_name: test_preset_name-production -python_linter: ruff -use_dispenser: false -use_github_actions: true -use_pre_commit: true -use_python_black: true -use_python_mypy: true -use_python_pip_audit: true -use_python_pytest: true - diff --git a/tests_generated/test_preset_name-production/.env.testnet.template b/tests_generated/test_preset_name-production/.env.testnet.template deleted file mode 100644 index eeea43d7..00000000 --- a/tests_generated/test_preset_name-production/.env.testnet.template +++ /dev/null @@ -1,3 +0,0 @@ -# this file contains algorand network settings for interacting with testnet via algonode -ALGOD_SERVER=https://testnet-api.algonode.cloud -INDEXER_SERVER=https://testnet-idx.algonode.cloud diff --git a/tests_generated/test_preset_name-production/.gitattributes b/tests_generated/test_preset_name-production/.gitattributes deleted file mode 100644 index 6313b56c..00000000 --- a/tests_generated/test_preset_name-production/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -* text=auto eol=lf diff --git a/tests_generated/test_preset_name-production/.github/workflows/cd.yaml b/tests_generated/test_preset_name-production/.github/workflows/cd.yaml deleted file mode 100644 index cf31ccae..00000000 --- a/tests_generated/test_preset_name-production/.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@v3 - - - name: Install poetry - run: pipx install poetry - - - name: Set up Python 3.10 - uses: actions/setup-python@v4 - with: - python-version: '3.10' - 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/tests_generated/test_preset_name-production/.github/workflows/checks.yaml b/tests_generated/test_preset_name-production/.github/workflows/checks.yaml deleted file mode 100644 index c03719d7..00000000 --- a/tests_generated/test_preset_name-production/.github/workflows/checks.yaml +++ /dev/null @@ -1,79 +0,0 @@ -name: Check code base - -on: - workflow_call: - -jobs: - checks: - runs-on: 'ubuntu-latest' - steps: - - name: Checkout source code - uses: actions/checkout@v3 - - - name: Install poetry - run: pipx install poetry - - - name: Set up Python 3.10 - uses: actions/setup-python@v4 - with: - python-version: '3.10' - 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: 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/tests_generated/test_preset_name-production/.github/workflows/pr.yaml b/tests_generated/test_preset_name-production/.github/workflows/pr.yaml deleted file mode 100644 index a80f7840..00000000 --- a/tests_generated/test_preset_name-production/.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/tests_generated/test_preset_name-production/.gitignore b/tests_generated/test_preset_name-production/.gitignore deleted file mode 100644 index 832924c3..00000000 --- a/tests_generated/test_preset_name-production/.gitignore +++ /dev/null @@ -1,174 +0,0 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -cover/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -.pybuilder/ -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -# For a library or package, you might want to ignore these files since the code is -# intended to run in multiple environments; otherwise, check them in: -# .python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# poetry -# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. -# This is especially recommended for binary packages to ensure reproducibility, and is more -# commonly ignored for libraries. -# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control -#poetry.lock - -# pdm -# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. -#pdm.lock -# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it -# in version control. -# https://pdm.fming.dev/#use-with-ide -.pdm.toml - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -.env.* -!.env.*.template -!.env.template -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# Ruff (linter) -.ruff_cache/ - -# Cython debug symbols -cython_debug/ - -# PyCharm -.idea -!.idea/ -.idea/* -!.idea/runConfigurations/ - -# macOS -.DS_Store - -# Received approval test files -*.received.* - -# NPM -node_modules diff --git a/tests_generated/test_preset_name-production/.vscode/extensions.json b/tests_generated/test_preset_name-production/.vscode/extensions.json deleted file mode 100644 index 36d7c10d..00000000 --- a/tests_generated/test_preset_name-production/.vscode/extensions.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "recommendations": [ - "ms-python.python", - "charliermarsh.ruff", - "matangover.mypy", - "ms-python.black-formatter", - "tamasfe.even-better-toml", - "editorconfig.editorconfig" - ] -} diff --git a/tests_generated/test_preset_name-production/.vscode/launch.json b/tests_generated/test_preset_name-production/.vscode/launch.json deleted file mode 100644 index 8a39d265..00000000 --- a/tests_generated/test_preset_name-production/.vscode/launch.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "name": "Build & Deploy Beaker application", - "type": "python", - "request": "launch", - "module": "smart_contracts", - "cwd": "${workspaceFolder}", - "preLaunchTask": "Start AlgoKit LocalNet", - "envFile": "${workspaceFolder}/.env.localnet" - }, - { - "name": "Deploy Built Beaker application", - "type": "python", - "request": "launch", - "module": "smart_contracts", - "args": ["deploy"], - "cwd": "${workspaceFolder}", - "envFile": "${workspaceFolder}/.env.localnet" - }, - { - "name": "Build Beaker application", - "type": "python", - "request": "launch", - "module": "smart_contracts", - "args": ["build"], - "cwd": "${workspaceFolder}" - } - ] -} diff --git a/tests_generated/test_preset_name-production/.vscode/settings.json b/tests_generated/test_preset_name-production/.vscode/settings.json deleted file mode 100644 index 0c2dfecd..00000000 --- a/tests_generated/test_preset_name-production/.vscode/settings.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - // General - see also /.editorconfig - "editor.formatOnSave": true, - "files.exclude": { - "**/.git": true, - "**/.DS_Store": true, - "**/Thumbs.db": true, - ".mypy_cache": true, - ".pytest_cache": true, - ".ruff_cache": true, - "**/__pycache__": true, - ".idea": true - }, - - // Python - "python.analysis.extraPaths": ["${workspaceFolder}/smart_contracts"], - "python.defaultInterpreterPath": "${workspaceFolder}/.venv", - "[python]": { - "editor.codeActionsOnSave": { - "source.fixAll": true, - // Prevent default import sorting from running; Ruff will sort imports for us anyway - "source.organizeImports": false - }, - "editor.defaultFormatter": "ms-python.black-formatter", - }, - "black-formatter.args": ["--config=pyproject.toml"], - "python.testing.pytestEnabled": true, - "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 - "terminal.integrated.shellArgs.windows": ["-ExecutionPolicy", "RemoteSigned"], -} diff --git a/tests_generated/test_preset_name-production/.vscode/tasks.json b/tests_generated/test_preset_name-production/.vscode/tasks.json deleted file mode 100644 index fe7889ae..00000000 --- a/tests_generated/test_preset_name-production/.vscode/tasks.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "version": "2.0.0", - "tasks": [ - { - "label": "Build Beaker application", - "command": "${workspaceFolder}/.venv/bin/python", - "windows": { - "command": "${workspaceFolder}/.venv/Scripts/python.exe" - }, - "args": ["-m", "smart_contracts", "build"], - "options": { - "cwd": "${workspaceFolder}" - }, - "group": { - "kind": "build", - "isDefault": true - }, - "problemMatcher": [] - }, - { - "label": "Build Beaker application (+ LocalNet)", - "command": "${workspaceFolder}/.venv/bin/python", - "windows": { - "command": "${workspaceFolder}/.venv/Scripts/python.exe" - }, - "args": ["-m", "smart_contracts", "build"], - "options": { - "cwd": "${workspaceFolder}" - }, - "dependsOn": "Start AlgoKit LocalNet", - "problemMatcher": [] - }, - { - "label": "Start AlgoKit LocalNet", - "command": "algokit", - "args": ["localnet", "start"], - "type": "shell", - "options": { - "cwd": "${workspaceFolder}" - }, - "problemMatcher": [] - }, - { - "label": "Stop AlgoKit LocalNet", - "command": "algokit", - "args": ["localnet", "stop"], - "type": "shell", - "options": { - "cwd": "${workspaceFolder}" - }, - "problemMatcher": [] - }, - { - "label": "Reset AlgoKit LocalNet", - "command": "algokit", - "args": ["localnet", "reset"], - "type": "shell", - "options": { - "cwd": "${workspaceFolder}" - }, - "problemMatcher": [] - } - ] -} diff --git a/tests_generated/test_preset_name-production/poetry.toml b/tests_generated/test_preset_name-production/poetry.toml deleted file mode 100644 index ab1033bd..00000000 --- a/tests_generated/test_preset_name-production/poetry.toml +++ /dev/null @@ -1,2 +0,0 @@ -[virtualenvs] -in-project = true diff --git a/tests_generated/test_smart_contract_generator_default_production_preset_python/.algokit/generators/create_contract/copier.yaml b/tests_generated/test_smart_contract_generator_default_production_preset_python/.algokit/generators/create_contract/copier.yaml index ff232a37..73805de0 100644 --- a/tests_generated/test_smart_contract_generator_default_production_preset_python/.algokit/generators/create_contract/copier.yaml +++ b/tests_generated/test_smart_contract_generator_default_production_preset_python/.algokit/generators/create_contract/copier.yaml @@ -1,10 +1,10 @@ -_task: - - "echo '==== Successfully initialized new smart contract 🚀 ===='" +_tasks: + - "echo '==== Successfully initialized new smart contract 🚀 ===='" contract_name: - type: str - help: Name of your new contract. - placeholder: "my-new-contract" - default: "my-new-contract" + type: str + help: Name of your new contract. + placeholder: "my-new-contract" + default: "my-new-contract" _templates_suffix: ".j2" diff --git a/tests_generated/test_smart_contract_generator_default_production_preset_python/.copier-answers.yml b/tests_generated/test_smart_contract_generator_default_production_preset_python/.copier-answers.yml index a8e008fb..c3f941e9 100644 --- a/tests_generated/test_smart_contract_generator_default_production_preset_python/.copier-answers.yml +++ b/tests_generated/test_smart_contract_generator_default_production_preset_python/.copier-answers.yml @@ -1,6 +1,6 @@ # Changes here will be overwritten by Copier; NEVER EDIT MANUALLY -_commit: -_src_path: +_commit: 1.9.3-1-gab67cf0 +_src_path: /var/folders/t6/57q65mk543l7xw6_bdgx1bmc0000gn/T/tmpkn2hrvj7/template algod_port: 4001 algod_server: http://localhost algod_token: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa diff --git a/tests_generated/test_smart_contract_generator_default_production_preset_python/smart_contracts/cool_contract/contract.py b/tests_generated/test_smart_contract_generator_default_production_preset_python/smart_contracts/cool_contract/contract.py deleted file mode 100644 index b82e6181..00000000 --- a/tests_generated/test_smart_contract_generator_default_production_preset_python/smart_contracts/cool_contract/contract.py +++ /dev/null @@ -1,26 +0,0 @@ -import beaker -import pyteal as pt -from algokit_utils import DELETABLE_TEMPLATE_NAME, UPDATABLE_TEMPLATE_NAME - -app = beaker.Application("cool_contract") - - -@app.update(authorize=beaker.Authorize.only_creator(), bare=True) -def update() -> pt.Expr: - return pt.Assert( - pt.Tmpl.Int(UPDATABLE_TEMPLATE_NAME), - comment="Check app is updatable", - ) - - -@app.delete(authorize=beaker.Authorize.only_creator(), bare=True) -def delete() -> pt.Expr: - return pt.Assert( - pt.Tmpl.Int(DELETABLE_TEMPLATE_NAME), - comment="Check app is deletable", - ) - - -@app.external -def hello(name: pt.abi.String, *, output: pt.abi.String) -> pt.Expr: - return output.set(pt.Concat(pt.Bytes("Hello, "), name.get())) diff --git a/tests_generated/test_smart_contract_generator_default_production_preset_python/smart_contracts/cool_contract/deploy_config.py b/tests_generated/test_smart_contract_generator_default_production_preset_python/smart_contracts/cool_contract/deploy_config.py deleted file mode 100644 index 964de9a0..00000000 --- a/tests_generated/test_smart_contract_generator_default_production_preset_python/smart_contracts/cool_contract/deploy_config.py +++ /dev/null @@ -1,45 +0,0 @@ -import logging - -import algokit_utils -from algosdk.v2client.algod import AlgodClient -from algosdk.v2client.indexer import IndexerClient - -logger = logging.getLogger(__name__) - - -# define deployment behaviour based on supplied app spec -def deploy( - algod_client: AlgodClient, - indexer_client: IndexerClient, - app_spec: algokit_utils.ApplicationSpecification, - deployer: algokit_utils.Account, -) -> None: - from smart_contracts.artifacts.cool_contract.client import ( - CoolContractClient, - ) - - app_client = CoolContractClient( - algod_client, - creator=deployer, - indexer_client=indexer_client, - ) - is_mainnet = algokit_utils.is_mainnet(algod_client) - app_client.deploy( - on_schema_break=( - algokit_utils.OnSchemaBreak.AppendApp - if is_mainnet - else algokit_utils.OnSchemaBreak.ReplaceApp - ), - on_update=algokit_utils.OnUpdate.AppendApp - if is_mainnet - else algokit_utils.OnUpdate.UpdateApp, - allow_delete=not is_mainnet, - allow_update=not is_mainnet, - ) - - name = "world" - response = app_client.hello(name=name) - logger.info( - f"Called hello on {app_spec.contract.name} ({app_client.app_id}) " - f"with name={name}, received: {response.return_value}" - ) diff --git a/tests_generated/test_smart_contract_generator_default_production_preset_typescript/.algokit/generators/create_contract/copier.yaml b/tests_generated/test_smart_contract_generator_default_production_preset_typescript/.algokit/generators/create_contract/copier.yaml index ff232a37..73805de0 100644 --- a/tests_generated/test_smart_contract_generator_default_production_preset_typescript/.algokit/generators/create_contract/copier.yaml +++ b/tests_generated/test_smart_contract_generator_default_production_preset_typescript/.algokit/generators/create_contract/copier.yaml @@ -1,10 +1,10 @@ -_task: - - "echo '==== Successfully initialized new smart contract 🚀 ===='" +_tasks: + - "echo '==== Successfully initialized new smart contract 🚀 ===='" contract_name: - type: str - help: Name of your new contract. - placeholder: "my-new-contract" - default: "my-new-contract" + type: str + help: Name of your new contract. + placeholder: "my-new-contract" + default: "my-new-contract" _templates_suffix: ".j2" diff --git a/tests_generated/test_smart_contract_generator_default_production_preset_typescript/.copier-answers.yml b/tests_generated/test_smart_contract_generator_default_production_preset_typescript/.copier-answers.yml index 803705b1..6de279c7 100644 --- a/tests_generated/test_smart_contract_generator_default_production_preset_typescript/.copier-answers.yml +++ b/tests_generated/test_smart_contract_generator_default_production_preset_typescript/.copier-answers.yml @@ -1,6 +1,6 @@ # Changes here will be overwritten by Copier; NEVER EDIT MANUALLY -_commit: -_src_path: +_commit: 1.9.3-1-gab67cf0 +_src_path: /var/folders/t6/57q65mk543l7xw6_bdgx1bmc0000gn/T/tmpkn2hrvj7/template algod_port: 4001 algod_server: http://localhost algod_token: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa diff --git a/tests_generated/test_smart_contract_generator_default_production_preset_typescript/smart_contracts/cool_contract/contract.py b/tests_generated/test_smart_contract_generator_default_production_preset_typescript/smart_contracts/cool_contract/contract.py deleted file mode 100644 index b82e6181..00000000 --- a/tests_generated/test_smart_contract_generator_default_production_preset_typescript/smart_contracts/cool_contract/contract.py +++ /dev/null @@ -1,26 +0,0 @@ -import beaker -import pyteal as pt -from algokit_utils import DELETABLE_TEMPLATE_NAME, UPDATABLE_TEMPLATE_NAME - -app = beaker.Application("cool_contract") - - -@app.update(authorize=beaker.Authorize.only_creator(), bare=True) -def update() -> pt.Expr: - return pt.Assert( - pt.Tmpl.Int(UPDATABLE_TEMPLATE_NAME), - comment="Check app is updatable", - ) - - -@app.delete(authorize=beaker.Authorize.only_creator(), bare=True) -def delete() -> pt.Expr: - return pt.Assert( - pt.Tmpl.Int(DELETABLE_TEMPLATE_NAME), - comment="Check app is deletable", - ) - - -@app.external -def hello(name: pt.abi.String, *, output: pt.abi.String) -> pt.Expr: - return output.set(pt.Concat(pt.Bytes("Hello, "), name.get())) diff --git a/tests_generated/test_smart_contract_generator_default_production_preset_typescript/smart_contracts/cool_contract/deploy-config.ts b/tests_generated/test_smart_contract_generator_default_production_preset_typescript/smart_contracts/cool_contract/deploy-config.ts deleted file mode 100644 index d51faf47..00000000 --- a/tests_generated/test_smart_contract_generator_default_production_preset_typescript/smart_contracts/cool_contract/deploy-config.ts +++ /dev/null @@ -1,52 +0,0 @@ -import * as algokit from '@algorandfoundation/algokit-utils' -import { CoolContractClient } from '../artifacts/cool_contract/client' - -// Below is a showcase of various deployment options you can use in TypeScript Client -export async function deploy() { - console.log('=== Deploying CoolContract ===') - - const algod = algokit.getAlgoClient() - const indexer = algokit.getAlgoIndexerClient() - const deployer = await algokit.mnemonicAccountFromEnvironment({ name: 'DEPLOYER', fundWith: algokit.algos(3) }, algod) - await algokit.ensureFunded( - { - accountToFund: deployer, - minSpendingBalance: algokit.algos(2), - minFundingIncrement: algokit.algos(2), - }, - algod, - ) - const appClient = new CoolContractClient( - { - resolveBy: 'creatorAndName', - findExistingUsing: indexer, - sender: deployer, - creatorAddress: deployer.addr, - }, - algod, - ) - const isMainNet = await algokit.isMainNet(algod) - const app = await appClient.deploy({ - allowDelete: !isMainNet, - allowUpdate: !isMainNet, - onSchemaBreak: isMainNet ? 'append' : 'replace', - onUpdate: isMainNet ? 'append' : 'update', - }) - - - // If app was just created fund the app account - if (['create', 'replace'].includes(app.operationPerformed)) { - algokit.transferAlgos( - { - amount: algokit.algos(1), - from: deployer, - to: app.appAddress, - }, - algod, - ) - } - - const method = 'hello' - const response = await appClient.hello({ name: 'world' }) - console.log(`Called ${method} on ${app.name} (${app.appId}) with name = world, received: ${response.return}`) -} diff --git a/tests_generated/test_smart_contract_generator_default_starter_preset_python/.algokit/generators/create_contract/copier.yaml b/tests_generated/test_smart_contract_generator_default_starter_preset_python/.algokit/generators/create_contract/copier.yaml index ff232a37..73805de0 100644 --- a/tests_generated/test_smart_contract_generator_default_starter_preset_python/.algokit/generators/create_contract/copier.yaml +++ b/tests_generated/test_smart_contract_generator_default_starter_preset_python/.algokit/generators/create_contract/copier.yaml @@ -1,10 +1,10 @@ -_task: - - "echo '==== Successfully initialized new smart contract 🚀 ===='" +_tasks: + - "echo '==== Successfully initialized new smart contract 🚀 ===='" contract_name: - type: str - help: Name of your new contract. - placeholder: "my-new-contract" - default: "my-new-contract" + type: str + help: Name of your new contract. + placeholder: "my-new-contract" + default: "my-new-contract" _templates_suffix: ".j2" diff --git a/tests_generated/test_smart_contract_generator_default_starter_preset_typescript/.algokit/generators/create_contract/copier.yaml b/tests_generated/test_smart_contract_generator_default_starter_preset_typescript/.algokit/generators/create_contract/copier.yaml index ff232a37..73805de0 100644 --- a/tests_generated/test_smart_contract_generator_default_starter_preset_typescript/.algokit/generators/create_contract/copier.yaml +++ b/tests_generated/test_smart_contract_generator_default_starter_preset_typescript/.algokit/generators/create_contract/copier.yaml @@ -1,10 +1,10 @@ -_task: - - "echo '==== Successfully initialized new smart contract 🚀 ===='" +_tasks: + - "echo '==== Successfully initialized new smart contract 🚀 ===='" contract_name: - type: str - help: Name of your new contract. - placeholder: "my-new-contract" - default: "my-new-contract" + type: str + help: Name of your new contract. + placeholder: "my-new-contract" + default: "my-new-contract" _templates_suffix: ".j2" From 4583b78b69951d32c58a270b62b444403e0fdd15 Mon Sep 17 00:00:00 2001 From: Altynbek Orumbayev Date: Fri, 8 Dec 2023 15:02:29 +0100 Subject: [PATCH 2/3] chore: bumping min version --- template_content/.algokit.toml.jinja | 2 +- .../.algokit.toml | 2 +- .../.algokit.toml | 2 +- tests_generated/test_use_github_actions-True/.algokit.toml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/template_content/.algokit.toml.jinja b/template_content/.algokit.toml.jinja index 891c2878..786275c6 100644 --- a/template_content/.algokit.toml.jinja +++ b/template_content/.algokit.toml.jinja @@ -1,5 +1,5 @@ [algokit] -min_version = "v1.4.0" +min_version = "v1.7.3" [deploy] {%- if deployment_language == 'python' %} diff --git a/tests_generated/test_smart_contract_generator_default_starter_preset_python/.algokit.toml b/tests_generated/test_smart_contract_generator_default_starter_preset_python/.algokit.toml index 6ffa3b4c..77dfd4bf 100644 --- a/tests_generated/test_smart_contract_generator_default_starter_preset_python/.algokit.toml +++ b/tests_generated/test_smart_contract_generator_default_starter_preset_python/.algokit.toml @@ -1,5 +1,5 @@ [algokit] -min_version = "v1.4.0" +min_version = "v1.7.3" [deploy] command = "poetry run python -m smart_contracts deploy" diff --git a/tests_generated/test_smart_contract_generator_default_starter_preset_typescript/.algokit.toml b/tests_generated/test_smart_contract_generator_default_starter_preset_typescript/.algokit.toml index 17861919..08717563 100644 --- a/tests_generated/test_smart_contract_generator_default_starter_preset_typescript/.algokit.toml +++ b/tests_generated/test_smart_contract_generator_default_starter_preset_typescript/.algokit.toml @@ -1,5 +1,5 @@ [algokit] -min_version = "v1.4.0" +min_version = "v1.7.3" [deploy] command = "npm run deploy:ci" diff --git a/tests_generated/test_use_github_actions-True/.algokit.toml b/tests_generated/test_use_github_actions-True/.algokit.toml index 6ffa3b4c..77dfd4bf 100644 --- a/tests_generated/test_use_github_actions-True/.algokit.toml +++ b/tests_generated/test_use_github_actions-True/.algokit.toml @@ -1,5 +1,5 @@ [algokit] -min_version = "v1.4.0" +min_version = "v1.7.3" [deploy] command = "poetry run python -m smart_contracts deploy" From ba4b43620e73860651ffa357b5ff0a40d79715d5 Mon Sep 17 00:00:00 2001 From: Altynbek Orumbayev Date: Fri, 8 Dec 2023 15:12:43 +0100 Subject: [PATCH 3/3] chore: regenerating test artifacts --- .../test_default_parameters/.algokit.toml | 2 +- .../.algokit.toml | 2 +- .../.algokit.toml | 2 +- .../test_ide_jetbrains-False/.algokit.toml | 2 +- .../test_ide_jetbrains-True/.algokit.toml | 2 +- .../test_ide_vscode-False/.algokit.toml | 2 +- .../test_ide_vscode-True/.algokit.toml | 2 +- .../test_preset_name-production/.algokit.toml | 2 +- .../.copier-answers.yml | 25 +++ .../.env.testnet.template | 3 + .../.gitattributes | 1 + .../.github/workflows/cd.yaml | 50 +++++ .../.github/workflows/checks.yaml | 79 ++++++++ .../.github/workflows/pr.yaml | 8 + .../test_preset_name-production/.gitignore | 174 ++++++++++++++++++ .../.vscode/extensions.json | 10 + .../.vscode/launch.json | 31 ++++ .../.vscode/settings.json | 49 +++++ .../.vscode/tasks.json | 64 +++++++ .../test_preset_name-production/poetry.toml | 2 + .../test_preset_name-starter/.algokit.toml | 2 +- .../test_python_linter-flake8/.algokit.toml | 2 +- .../test_python_linter-none/.algokit.toml | 2 +- .../test_python_linter-ruff/.algokit.toml | 2 +- .../.algokit.toml | 2 +- .../.copier-answers.yml | 4 +- .../smart_contracts/cool_contract/contract.py | 26 +++ .../cool_contract/deploy_config.py | 45 +++++ .../.algokit.toml | 2 +- .../.copier-answers.yml | 4 +- .../smart_contracts/cool_contract/contract.py | 26 +++ .../cool_contract/deploy-config.ts | 52 ++++++ .../.algokit.toml | 2 +- .../test_use_python_black-False/.algokit.toml | 2 +- .../test_use_python_black-True/.algokit.toml | 2 +- .../test_use_python_mypy-False/.algokit.toml | 2 +- .../test_use_python_mypy-True/.algokit.toml | 2 +- .../.algokit.toml | 2 +- .../test_use_python_pytest-True/.algokit.toml | 2 +- 39 files changed, 670 insertions(+), 25 deletions(-) create mode 100644 tests_generated/test_preset_name-production/.copier-answers.yml create mode 100644 tests_generated/test_preset_name-production/.env.testnet.template create mode 100644 tests_generated/test_preset_name-production/.gitattributes create mode 100644 tests_generated/test_preset_name-production/.github/workflows/cd.yaml create mode 100644 tests_generated/test_preset_name-production/.github/workflows/checks.yaml create mode 100644 tests_generated/test_preset_name-production/.github/workflows/pr.yaml create mode 100644 tests_generated/test_preset_name-production/.gitignore create mode 100644 tests_generated/test_preset_name-production/.vscode/extensions.json create mode 100644 tests_generated/test_preset_name-production/.vscode/launch.json create mode 100644 tests_generated/test_preset_name-production/.vscode/settings.json create mode 100644 tests_generated/test_preset_name-production/.vscode/tasks.json create mode 100644 tests_generated/test_preset_name-production/poetry.toml create mode 100644 tests_generated/test_smart_contract_generator_default_production_preset_python/smart_contracts/cool_contract/contract.py create mode 100644 tests_generated/test_smart_contract_generator_default_production_preset_python/smart_contracts/cool_contract/deploy_config.py create mode 100644 tests_generated/test_smart_contract_generator_default_production_preset_typescript/smart_contracts/cool_contract/contract.py create mode 100644 tests_generated/test_smart_contract_generator_default_production_preset_typescript/smart_contracts/cool_contract/deploy-config.ts diff --git a/tests_generated/test_default_parameters/.algokit.toml b/tests_generated/test_default_parameters/.algokit.toml index 6ffa3b4c..77dfd4bf 100644 --- a/tests_generated/test_default_parameters/.algokit.toml +++ b/tests_generated/test_default_parameters/.algokit.toml @@ -1,5 +1,5 @@ [algokit] -min_version = "v1.4.0" +min_version = "v1.7.3" [deploy] command = "poetry run python -m smart_contracts deploy" diff --git a/tests_generated/test_deployment_language-python/.algokit.toml b/tests_generated/test_deployment_language-python/.algokit.toml index 6ffa3b4c..77dfd4bf 100644 --- a/tests_generated/test_deployment_language-python/.algokit.toml +++ b/tests_generated/test_deployment_language-python/.algokit.toml @@ -1,5 +1,5 @@ [algokit] -min_version = "v1.4.0" +min_version = "v1.7.3" [deploy] command = "poetry run python -m smart_contracts deploy" diff --git a/tests_generated/test_deployment_language-typescript/.algokit.toml b/tests_generated/test_deployment_language-typescript/.algokit.toml index 17861919..08717563 100644 --- a/tests_generated/test_deployment_language-typescript/.algokit.toml +++ b/tests_generated/test_deployment_language-typescript/.algokit.toml @@ -1,5 +1,5 @@ [algokit] -min_version = "v1.4.0" +min_version = "v1.7.3" [deploy] command = "npm run deploy:ci" diff --git a/tests_generated/test_ide_jetbrains-False/.algokit.toml b/tests_generated/test_ide_jetbrains-False/.algokit.toml index 6ffa3b4c..77dfd4bf 100644 --- a/tests_generated/test_ide_jetbrains-False/.algokit.toml +++ b/tests_generated/test_ide_jetbrains-False/.algokit.toml @@ -1,5 +1,5 @@ [algokit] -min_version = "v1.4.0" +min_version = "v1.7.3" [deploy] command = "poetry run python -m smart_contracts deploy" diff --git a/tests_generated/test_ide_jetbrains-True/.algokit.toml b/tests_generated/test_ide_jetbrains-True/.algokit.toml index 6ffa3b4c..77dfd4bf 100644 --- a/tests_generated/test_ide_jetbrains-True/.algokit.toml +++ b/tests_generated/test_ide_jetbrains-True/.algokit.toml @@ -1,5 +1,5 @@ [algokit] -min_version = "v1.4.0" +min_version = "v1.7.3" [deploy] command = "poetry run python -m smart_contracts deploy" diff --git a/tests_generated/test_ide_vscode-False/.algokit.toml b/tests_generated/test_ide_vscode-False/.algokit.toml index 6ffa3b4c..77dfd4bf 100644 --- a/tests_generated/test_ide_vscode-False/.algokit.toml +++ b/tests_generated/test_ide_vscode-False/.algokit.toml @@ -1,5 +1,5 @@ [algokit] -min_version = "v1.4.0" +min_version = "v1.7.3" [deploy] command = "poetry run python -m smart_contracts deploy" diff --git a/tests_generated/test_ide_vscode-True/.algokit.toml b/tests_generated/test_ide_vscode-True/.algokit.toml index 6ffa3b4c..77dfd4bf 100644 --- a/tests_generated/test_ide_vscode-True/.algokit.toml +++ b/tests_generated/test_ide_vscode-True/.algokit.toml @@ -1,5 +1,5 @@ [algokit] -min_version = "v1.4.0" +min_version = "v1.7.3" [deploy] command = "poetry run python -m smart_contracts deploy" diff --git a/tests_generated/test_preset_name-production/.algokit.toml b/tests_generated/test_preset_name-production/.algokit.toml index 6ffa3b4c..77dfd4bf 100644 --- a/tests_generated/test_preset_name-production/.algokit.toml +++ b/tests_generated/test_preset_name-production/.algokit.toml @@ -1,5 +1,5 @@ [algokit] -min_version = "v1.4.0" +min_version = "v1.7.3" [deploy] command = "poetry run python -m smart_contracts deploy" diff --git a/tests_generated/test_preset_name-production/.copier-answers.yml b/tests_generated/test_preset_name-production/.copier-answers.yml new file mode 100644 index 00000000..2925fe04 --- /dev/null +++ b/tests_generated/test_preset_name-production/.copier-answers.yml @@ -0,0 +1,25 @@ +# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY +_commit: +_src_path: +algod_port: 4001 +algod_server: http://localhost +algod_token: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +author_email: None +author_name: None +contract_name: hello_world +deployment_language: python +ide_vscode: true +indexer_port: 8980 +indexer_server: http://localhost +indexer_token: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +preset_name: production +project_name: test_preset_name-production +python_linter: ruff +use_dispenser: false +use_github_actions: true +use_pre_commit: true +use_python_black: true +use_python_mypy: true +use_python_pip_audit: true +use_python_pytest: true + diff --git a/tests_generated/test_preset_name-production/.env.testnet.template b/tests_generated/test_preset_name-production/.env.testnet.template new file mode 100644 index 00000000..eeea43d7 --- /dev/null +++ b/tests_generated/test_preset_name-production/.env.testnet.template @@ -0,0 +1,3 @@ +# this file contains algorand network settings for interacting with testnet via algonode +ALGOD_SERVER=https://testnet-api.algonode.cloud +INDEXER_SERVER=https://testnet-idx.algonode.cloud diff --git a/tests_generated/test_preset_name-production/.gitattributes b/tests_generated/test_preset_name-production/.gitattributes new file mode 100644 index 00000000..6313b56c --- /dev/null +++ b/tests_generated/test_preset_name-production/.gitattributes @@ -0,0 +1 @@ +* text=auto eol=lf diff --git a/tests_generated/test_preset_name-production/.github/workflows/cd.yaml b/tests_generated/test_preset_name-production/.github/workflows/cd.yaml new file mode 100644 index 00000000..cf31ccae --- /dev/null +++ b/tests_generated/test_preset_name-production/.github/workflows/cd.yaml @@ -0,0 +1,50 @@ +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@v3 + + - name: Install poetry + run: pipx install poetry + + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: '3.10' + 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/tests_generated/test_preset_name-production/.github/workflows/checks.yaml b/tests_generated/test_preset_name-production/.github/workflows/checks.yaml new file mode 100644 index 00000000..c03719d7 --- /dev/null +++ b/tests_generated/test_preset_name-production/.github/workflows/checks.yaml @@ -0,0 +1,79 @@ +name: Check code base + +on: + workflow_call: + +jobs: + checks: + runs-on: 'ubuntu-latest' + steps: + - name: Checkout source code + uses: actions/checkout@v3 + + - name: Install poetry + run: pipx install poetry + + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: '3.10' + 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: 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/tests_generated/test_preset_name-production/.github/workflows/pr.yaml b/tests_generated/test_preset_name-production/.github/workflows/pr.yaml new file mode 100644 index 00000000..a80f7840 --- /dev/null +++ b/tests_generated/test_preset_name-production/.github/workflows/pr.yaml @@ -0,0 +1,8 @@ +name: Pull Request validation + +on: [pull_request] + +jobs: + pr-check: + name: Perform Checks + uses: ./.github/workflows/checks.yaml diff --git a/tests_generated/test_preset_name-production/.gitignore b/tests_generated/test_preset_name-production/.gitignore new file mode 100644 index 00000000..832924c3 --- /dev/null +++ b/tests_generated/test_preset_name-production/.gitignore @@ -0,0 +1,174 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +.env.* +!.env.*.template +!.env.template +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Ruff (linter) +.ruff_cache/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +.idea +!.idea/ +.idea/* +!.idea/runConfigurations/ + +# macOS +.DS_Store + +# Received approval test files +*.received.* + +# NPM +node_modules diff --git a/tests_generated/test_preset_name-production/.vscode/extensions.json b/tests_generated/test_preset_name-production/.vscode/extensions.json new file mode 100644 index 00000000..36d7c10d --- /dev/null +++ b/tests_generated/test_preset_name-production/.vscode/extensions.json @@ -0,0 +1,10 @@ +{ + "recommendations": [ + "ms-python.python", + "charliermarsh.ruff", + "matangover.mypy", + "ms-python.black-formatter", + "tamasfe.even-better-toml", + "editorconfig.editorconfig" + ] +} diff --git a/tests_generated/test_preset_name-production/.vscode/launch.json b/tests_generated/test_preset_name-production/.vscode/launch.json new file mode 100644 index 00000000..8a39d265 --- /dev/null +++ b/tests_generated/test_preset_name-production/.vscode/launch.json @@ -0,0 +1,31 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Build & Deploy Beaker application", + "type": "python", + "request": "launch", + "module": "smart_contracts", + "cwd": "${workspaceFolder}", + "preLaunchTask": "Start AlgoKit LocalNet", + "envFile": "${workspaceFolder}/.env.localnet" + }, + { + "name": "Deploy Built Beaker application", + "type": "python", + "request": "launch", + "module": "smart_contracts", + "args": ["deploy"], + "cwd": "${workspaceFolder}", + "envFile": "${workspaceFolder}/.env.localnet" + }, + { + "name": "Build Beaker application", + "type": "python", + "request": "launch", + "module": "smart_contracts", + "args": ["build"], + "cwd": "${workspaceFolder}" + } + ] +} diff --git a/tests_generated/test_preset_name-production/.vscode/settings.json b/tests_generated/test_preset_name-production/.vscode/settings.json new file mode 100644 index 00000000..0c2dfecd --- /dev/null +++ b/tests_generated/test_preset_name-production/.vscode/settings.json @@ -0,0 +1,49 @@ +{ + // General - see also /.editorconfig + "editor.formatOnSave": true, + "files.exclude": { + "**/.git": true, + "**/.DS_Store": true, + "**/Thumbs.db": true, + ".mypy_cache": true, + ".pytest_cache": true, + ".ruff_cache": true, + "**/__pycache__": true, + ".idea": true + }, + + // Python + "python.analysis.extraPaths": ["${workspaceFolder}/smart_contracts"], + "python.defaultInterpreterPath": "${workspaceFolder}/.venv", + "[python]": { + "editor.codeActionsOnSave": { + "source.fixAll": true, + // Prevent default import sorting from running; Ruff will sort imports for us anyway + "source.organizeImports": false + }, + "editor.defaultFormatter": "ms-python.black-formatter", + }, + "black-formatter.args": ["--config=pyproject.toml"], + "python.testing.pytestEnabled": true, + "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 + "terminal.integrated.shellArgs.windows": ["-ExecutionPolicy", "RemoteSigned"], +} diff --git a/tests_generated/test_preset_name-production/.vscode/tasks.json b/tests_generated/test_preset_name-production/.vscode/tasks.json new file mode 100644 index 00000000..fe7889ae --- /dev/null +++ b/tests_generated/test_preset_name-production/.vscode/tasks.json @@ -0,0 +1,64 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Build Beaker application", + "command": "${workspaceFolder}/.venv/bin/python", + "windows": { + "command": "${workspaceFolder}/.venv/Scripts/python.exe" + }, + "args": ["-m", "smart_contracts", "build"], + "options": { + "cwd": "${workspaceFolder}" + }, + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [] + }, + { + "label": "Build Beaker application (+ LocalNet)", + "command": "${workspaceFolder}/.venv/bin/python", + "windows": { + "command": "${workspaceFolder}/.venv/Scripts/python.exe" + }, + "args": ["-m", "smart_contracts", "build"], + "options": { + "cwd": "${workspaceFolder}" + }, + "dependsOn": "Start AlgoKit LocalNet", + "problemMatcher": [] + }, + { + "label": "Start AlgoKit LocalNet", + "command": "algokit", + "args": ["localnet", "start"], + "type": "shell", + "options": { + "cwd": "${workspaceFolder}" + }, + "problemMatcher": [] + }, + { + "label": "Stop AlgoKit LocalNet", + "command": "algokit", + "args": ["localnet", "stop"], + "type": "shell", + "options": { + "cwd": "${workspaceFolder}" + }, + "problemMatcher": [] + }, + { + "label": "Reset AlgoKit LocalNet", + "command": "algokit", + "args": ["localnet", "reset"], + "type": "shell", + "options": { + "cwd": "${workspaceFolder}" + }, + "problemMatcher": [] + } + ] +} diff --git a/tests_generated/test_preset_name-production/poetry.toml b/tests_generated/test_preset_name-production/poetry.toml new file mode 100644 index 00000000..ab1033bd --- /dev/null +++ b/tests_generated/test_preset_name-production/poetry.toml @@ -0,0 +1,2 @@ +[virtualenvs] +in-project = true diff --git a/tests_generated/test_preset_name-starter/.algokit.toml b/tests_generated/test_preset_name-starter/.algokit.toml index 6ffa3b4c..77dfd4bf 100644 --- a/tests_generated/test_preset_name-starter/.algokit.toml +++ b/tests_generated/test_preset_name-starter/.algokit.toml @@ -1,5 +1,5 @@ [algokit] -min_version = "v1.4.0" +min_version = "v1.7.3" [deploy] command = "poetry run python -m smart_contracts deploy" diff --git a/tests_generated/test_python_linter-flake8/.algokit.toml b/tests_generated/test_python_linter-flake8/.algokit.toml index 6ffa3b4c..77dfd4bf 100644 --- a/tests_generated/test_python_linter-flake8/.algokit.toml +++ b/tests_generated/test_python_linter-flake8/.algokit.toml @@ -1,5 +1,5 @@ [algokit] -min_version = "v1.4.0" +min_version = "v1.7.3" [deploy] command = "poetry run python -m smart_contracts deploy" diff --git a/tests_generated/test_python_linter-none/.algokit.toml b/tests_generated/test_python_linter-none/.algokit.toml index 6ffa3b4c..77dfd4bf 100644 --- a/tests_generated/test_python_linter-none/.algokit.toml +++ b/tests_generated/test_python_linter-none/.algokit.toml @@ -1,5 +1,5 @@ [algokit] -min_version = "v1.4.0" +min_version = "v1.7.3" [deploy] command = "poetry run python -m smart_contracts deploy" diff --git a/tests_generated/test_python_linter-ruff/.algokit.toml b/tests_generated/test_python_linter-ruff/.algokit.toml index 6ffa3b4c..77dfd4bf 100644 --- a/tests_generated/test_python_linter-ruff/.algokit.toml +++ b/tests_generated/test_python_linter-ruff/.algokit.toml @@ -1,5 +1,5 @@ [algokit] -min_version = "v1.4.0" +min_version = "v1.7.3" [deploy] command = "poetry run python -m smart_contracts deploy" diff --git a/tests_generated/test_smart_contract_generator_default_production_preset_python/.algokit.toml b/tests_generated/test_smart_contract_generator_default_production_preset_python/.algokit.toml index 6ffa3b4c..77dfd4bf 100644 --- a/tests_generated/test_smart_contract_generator_default_production_preset_python/.algokit.toml +++ b/tests_generated/test_smart_contract_generator_default_production_preset_python/.algokit.toml @@ -1,5 +1,5 @@ [algokit] -min_version = "v1.4.0" +min_version = "v1.7.3" [deploy] command = "poetry run python -m smart_contracts deploy" diff --git a/tests_generated/test_smart_contract_generator_default_production_preset_python/.copier-answers.yml b/tests_generated/test_smart_contract_generator_default_production_preset_python/.copier-answers.yml index c3f941e9..a8e008fb 100644 --- a/tests_generated/test_smart_contract_generator_default_production_preset_python/.copier-answers.yml +++ b/tests_generated/test_smart_contract_generator_default_production_preset_python/.copier-answers.yml @@ -1,6 +1,6 @@ # Changes here will be overwritten by Copier; NEVER EDIT MANUALLY -_commit: 1.9.3-1-gab67cf0 -_src_path: /var/folders/t6/57q65mk543l7xw6_bdgx1bmc0000gn/T/tmpkn2hrvj7/template +_commit: +_src_path: algod_port: 4001 algod_server: http://localhost algod_token: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa diff --git a/tests_generated/test_smart_contract_generator_default_production_preset_python/smart_contracts/cool_contract/contract.py b/tests_generated/test_smart_contract_generator_default_production_preset_python/smart_contracts/cool_contract/contract.py new file mode 100644 index 00000000..b82e6181 --- /dev/null +++ b/tests_generated/test_smart_contract_generator_default_production_preset_python/smart_contracts/cool_contract/contract.py @@ -0,0 +1,26 @@ +import beaker +import pyteal as pt +from algokit_utils import DELETABLE_TEMPLATE_NAME, UPDATABLE_TEMPLATE_NAME + +app = beaker.Application("cool_contract") + + +@app.update(authorize=beaker.Authorize.only_creator(), bare=True) +def update() -> pt.Expr: + return pt.Assert( + pt.Tmpl.Int(UPDATABLE_TEMPLATE_NAME), + comment="Check app is updatable", + ) + + +@app.delete(authorize=beaker.Authorize.only_creator(), bare=True) +def delete() -> pt.Expr: + return pt.Assert( + pt.Tmpl.Int(DELETABLE_TEMPLATE_NAME), + comment="Check app is deletable", + ) + + +@app.external +def hello(name: pt.abi.String, *, output: pt.abi.String) -> pt.Expr: + return output.set(pt.Concat(pt.Bytes("Hello, "), name.get())) diff --git a/tests_generated/test_smart_contract_generator_default_production_preset_python/smart_contracts/cool_contract/deploy_config.py b/tests_generated/test_smart_contract_generator_default_production_preset_python/smart_contracts/cool_contract/deploy_config.py new file mode 100644 index 00000000..964de9a0 --- /dev/null +++ b/tests_generated/test_smart_contract_generator_default_production_preset_python/smart_contracts/cool_contract/deploy_config.py @@ -0,0 +1,45 @@ +import logging + +import algokit_utils +from algosdk.v2client.algod import AlgodClient +from algosdk.v2client.indexer import IndexerClient + +logger = logging.getLogger(__name__) + + +# define deployment behaviour based on supplied app spec +def deploy( + algod_client: AlgodClient, + indexer_client: IndexerClient, + app_spec: algokit_utils.ApplicationSpecification, + deployer: algokit_utils.Account, +) -> None: + from smart_contracts.artifacts.cool_contract.client import ( + CoolContractClient, + ) + + app_client = CoolContractClient( + algod_client, + creator=deployer, + indexer_client=indexer_client, + ) + is_mainnet = algokit_utils.is_mainnet(algod_client) + app_client.deploy( + on_schema_break=( + algokit_utils.OnSchemaBreak.AppendApp + if is_mainnet + else algokit_utils.OnSchemaBreak.ReplaceApp + ), + on_update=algokit_utils.OnUpdate.AppendApp + if is_mainnet + else algokit_utils.OnUpdate.UpdateApp, + allow_delete=not is_mainnet, + allow_update=not is_mainnet, + ) + + name = "world" + response = app_client.hello(name=name) + logger.info( + f"Called hello on {app_spec.contract.name} ({app_client.app_id}) " + f"with name={name}, received: {response.return_value}" + ) diff --git a/tests_generated/test_smart_contract_generator_default_production_preset_typescript/.algokit.toml b/tests_generated/test_smart_contract_generator_default_production_preset_typescript/.algokit.toml index 17861919..08717563 100644 --- a/tests_generated/test_smart_contract_generator_default_production_preset_typescript/.algokit.toml +++ b/tests_generated/test_smart_contract_generator_default_production_preset_typescript/.algokit.toml @@ -1,5 +1,5 @@ [algokit] -min_version = "v1.4.0" +min_version = "v1.7.3" [deploy] command = "npm run deploy:ci" diff --git a/tests_generated/test_smart_contract_generator_default_production_preset_typescript/.copier-answers.yml b/tests_generated/test_smart_contract_generator_default_production_preset_typescript/.copier-answers.yml index 6de279c7..803705b1 100644 --- a/tests_generated/test_smart_contract_generator_default_production_preset_typescript/.copier-answers.yml +++ b/tests_generated/test_smart_contract_generator_default_production_preset_typescript/.copier-answers.yml @@ -1,6 +1,6 @@ # Changes here will be overwritten by Copier; NEVER EDIT MANUALLY -_commit: 1.9.3-1-gab67cf0 -_src_path: /var/folders/t6/57q65mk543l7xw6_bdgx1bmc0000gn/T/tmpkn2hrvj7/template +_commit: +_src_path: algod_port: 4001 algod_server: http://localhost algod_token: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa diff --git a/tests_generated/test_smart_contract_generator_default_production_preset_typescript/smart_contracts/cool_contract/contract.py b/tests_generated/test_smart_contract_generator_default_production_preset_typescript/smart_contracts/cool_contract/contract.py new file mode 100644 index 00000000..b82e6181 --- /dev/null +++ b/tests_generated/test_smart_contract_generator_default_production_preset_typescript/smart_contracts/cool_contract/contract.py @@ -0,0 +1,26 @@ +import beaker +import pyteal as pt +from algokit_utils import DELETABLE_TEMPLATE_NAME, UPDATABLE_TEMPLATE_NAME + +app = beaker.Application("cool_contract") + + +@app.update(authorize=beaker.Authorize.only_creator(), bare=True) +def update() -> pt.Expr: + return pt.Assert( + pt.Tmpl.Int(UPDATABLE_TEMPLATE_NAME), + comment="Check app is updatable", + ) + + +@app.delete(authorize=beaker.Authorize.only_creator(), bare=True) +def delete() -> pt.Expr: + return pt.Assert( + pt.Tmpl.Int(DELETABLE_TEMPLATE_NAME), + comment="Check app is deletable", + ) + + +@app.external +def hello(name: pt.abi.String, *, output: pt.abi.String) -> pt.Expr: + return output.set(pt.Concat(pt.Bytes("Hello, "), name.get())) diff --git a/tests_generated/test_smart_contract_generator_default_production_preset_typescript/smart_contracts/cool_contract/deploy-config.ts b/tests_generated/test_smart_contract_generator_default_production_preset_typescript/smart_contracts/cool_contract/deploy-config.ts new file mode 100644 index 00000000..d51faf47 --- /dev/null +++ b/tests_generated/test_smart_contract_generator_default_production_preset_typescript/smart_contracts/cool_contract/deploy-config.ts @@ -0,0 +1,52 @@ +import * as algokit from '@algorandfoundation/algokit-utils' +import { CoolContractClient } from '../artifacts/cool_contract/client' + +// Below is a showcase of various deployment options you can use in TypeScript Client +export async function deploy() { + console.log('=== Deploying CoolContract ===') + + const algod = algokit.getAlgoClient() + const indexer = algokit.getAlgoIndexerClient() + const deployer = await algokit.mnemonicAccountFromEnvironment({ name: 'DEPLOYER', fundWith: algokit.algos(3) }, algod) + await algokit.ensureFunded( + { + accountToFund: deployer, + minSpendingBalance: algokit.algos(2), + minFundingIncrement: algokit.algos(2), + }, + algod, + ) + const appClient = new CoolContractClient( + { + resolveBy: 'creatorAndName', + findExistingUsing: indexer, + sender: deployer, + creatorAddress: deployer.addr, + }, + algod, + ) + const isMainNet = await algokit.isMainNet(algod) + const app = await appClient.deploy({ + allowDelete: !isMainNet, + allowUpdate: !isMainNet, + onSchemaBreak: isMainNet ? 'append' : 'replace', + onUpdate: isMainNet ? 'append' : 'update', + }) + + + // If app was just created fund the app account + if (['create', 'replace'].includes(app.operationPerformed)) { + algokit.transferAlgos( + { + amount: algokit.algos(1), + from: deployer, + to: app.appAddress, + }, + algod, + ) + } + + const method = 'hello' + const response = await appClient.hello({ name: 'world' }) + console.log(`Called ${method} on ${app.name} (${app.appId}) with name = world, received: ${response.return}`) +} diff --git a/tests_generated/test_use_github_actions-False/.algokit.toml b/tests_generated/test_use_github_actions-False/.algokit.toml index 6ffa3b4c..77dfd4bf 100644 --- a/tests_generated/test_use_github_actions-False/.algokit.toml +++ b/tests_generated/test_use_github_actions-False/.algokit.toml @@ -1,5 +1,5 @@ [algokit] -min_version = "v1.4.0" +min_version = "v1.7.3" [deploy] command = "poetry run python -m smart_contracts deploy" diff --git a/tests_generated/test_use_python_black-False/.algokit.toml b/tests_generated/test_use_python_black-False/.algokit.toml index 6ffa3b4c..77dfd4bf 100644 --- a/tests_generated/test_use_python_black-False/.algokit.toml +++ b/tests_generated/test_use_python_black-False/.algokit.toml @@ -1,5 +1,5 @@ [algokit] -min_version = "v1.4.0" +min_version = "v1.7.3" [deploy] command = "poetry run python -m smart_contracts deploy" diff --git a/tests_generated/test_use_python_black-True/.algokit.toml b/tests_generated/test_use_python_black-True/.algokit.toml index 6ffa3b4c..77dfd4bf 100644 --- a/tests_generated/test_use_python_black-True/.algokit.toml +++ b/tests_generated/test_use_python_black-True/.algokit.toml @@ -1,5 +1,5 @@ [algokit] -min_version = "v1.4.0" +min_version = "v1.7.3" [deploy] command = "poetry run python -m smart_contracts deploy" diff --git a/tests_generated/test_use_python_mypy-False/.algokit.toml b/tests_generated/test_use_python_mypy-False/.algokit.toml index 6ffa3b4c..77dfd4bf 100644 --- a/tests_generated/test_use_python_mypy-False/.algokit.toml +++ b/tests_generated/test_use_python_mypy-False/.algokit.toml @@ -1,5 +1,5 @@ [algokit] -min_version = "v1.4.0" +min_version = "v1.7.3" [deploy] command = "poetry run python -m smart_contracts deploy" diff --git a/tests_generated/test_use_python_mypy-True/.algokit.toml b/tests_generated/test_use_python_mypy-True/.algokit.toml index 6ffa3b4c..77dfd4bf 100644 --- a/tests_generated/test_use_python_mypy-True/.algokit.toml +++ b/tests_generated/test_use_python_mypy-True/.algokit.toml @@ -1,5 +1,5 @@ [algokit] -min_version = "v1.4.0" +min_version = "v1.7.3" [deploy] command = "poetry run python -m smart_contracts deploy" diff --git a/tests_generated/test_use_python_pytest-False/.algokit.toml b/tests_generated/test_use_python_pytest-False/.algokit.toml index 6ffa3b4c..77dfd4bf 100644 --- a/tests_generated/test_use_python_pytest-False/.algokit.toml +++ b/tests_generated/test_use_python_pytest-False/.algokit.toml @@ -1,5 +1,5 @@ [algokit] -min_version = "v1.4.0" +min_version = "v1.7.3" [deploy] command = "poetry run python -m smart_contracts deploy" diff --git a/tests_generated/test_use_python_pytest-True/.algokit.toml b/tests_generated/test_use_python_pytest-True/.algokit.toml index 6ffa3b4c..77dfd4bf 100644 --- a/tests_generated/test_use_python_pytest-True/.algokit.toml +++ b/tests_generated/test_use_python_pytest-True/.algokit.toml @@ -1,5 +1,5 @@ [algokit] -min_version = "v1.4.0" +min_version = "v1.7.3" [deploy] command = "poetry run python -m smart_contracts deploy"