generated from algorandfoundation/algokit-beaker-default-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding latest changes from beaker template (debugger, typed sim…
…ulate) (#2) * feat: adding latest changes from beaker template (debugger, typed simulate) * chore: minor tweaks * refactor: simplifying configuration and test variations * chore: fixing typos * feat: Update contract.py.j2 templates - Updated the `hello` method in the `contract.py.j2` template files to return a modified greeting message. - The greeting message now includes a comma after "Hello" for better readability and clarity.
- Loading branch information
1 parent
a8c9a1b
commit ee81044
Showing
198 changed files
with
3,050 additions
and
243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,11 +30,13 @@ author_name: | |
type: str | ||
help: Package author name | ||
placeholder: "Your Name" | ||
default: "Your Name" | ||
|
||
author_email: | ||
type: str | ||
help: Package author email | ||
placeholder: "[email protected]" | ||
default: "[email protected]" | ||
|
||
ide_vscode: | ||
type: bool | ||
|
@@ -55,9 +57,33 @@ deployment_language: | |
TypeScript: "typescript" | ||
default: "python" | ||
|
||
use_python_pytest: | ||
type: bool | ||
when: false | ||
help: Do you want to include unit tests (via pytest)? | ||
# deployment_language is empty when using the default_language | ||
default: |- | ||
{% if deployment_language|length == 0 or deployment_language == 'python' -%} | ||
yes | ||
{%- else -%} | ||
no | ||
{%- endif %} | ||
use_typescript_jest: | ||
type: bool | ||
when: false | ||
help: Do you want to include unit tests (via jest)? | ||
default: |- | ||
{% if deployment_language == 'typescript' -%} | ||
yes | ||
{%- else -%} | ||
no | ||
{%- endif %} | ||
python_linter: | ||
type: str | ||
help: Do you want to use a Python linter? | ||
when: false | ||
choices: | ||
Ruff: "ruff" | ||
Flake8: "flake8" | ||
|
@@ -67,39 +93,40 @@ python_linter: | |
use_python_black: | ||
type: bool | ||
when: false | ||
help: Do you want to use a Python formatter (via Black)? | ||
default: yes | ||
|
||
use_python_mypy: | ||
type: bool | ||
when: false | ||
help: Do you want to use a Python type checker (via mypy)? | ||
default: |- | ||
yes | ||
use_python_pytest: | ||
type: bool | ||
help: Do you want to include unit tests (via pytest)? | ||
default: yes | ||
|
||
use_python_pip_audit: | ||
type: bool | ||
when: false | ||
help: Do you want to include Python dependency vulnerability scanning (via pip-audit)? | ||
default: yes | ||
|
||
use_github_actions: | ||
type: bool | ||
when: false | ||
help: Do you want to include Github Actions workflows for build and testnet deployment? | ||
default: |- | ||
yes | ||
use_pre_commit: | ||
type: bool | ||
when: false | ||
help: Do you want to include pre-commit for linting, type checking and formatting? | ||
default: |- | ||
yes | ||
use_dispenser: | ||
type: bool | ||
when: false | ||
help: Do you want to fund your deployment account using an optional dispenser account? | ||
default: no | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{- contract_name.split('_')|join('-') -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{- contract_name.split('_')|map('capitalize')|join -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[algokit] | ||
min_version = "v1.7.3" | ||
min_version = "v1.8.0" | ||
|
||
[deploy] | ||
{%- if deployment_language == 'python' %} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
33 changes: 33 additions & 0 deletions
33
...eployment_language == 'typescript' or use_typescript_jest %}package.json{% endif %}.jinja
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"name": "smart_contracts", | ||
"version": "1.0.0", | ||
"description": "Smart contract deployer", | ||
"main": "index.ts", | ||
"scripts": { | ||
"deploy": "ts-node-dev --transpile-only --watch .env -r dotenv/config smart_contracts/index.ts", | ||
"deploy:ci": "ts-node --transpile-only -r dotenv/config smart_contracts/index.ts", | ||
{%- if use_typescript_jest %} | ||
"test": "jest --coverage", | ||
{%- endif %} | ||
"format": "prettier --write ." | ||
}, | ||
"engines": { | ||
"node": ">=18.0" | ||
}, | ||
"dependencies": { | ||
"@algorandfoundation/algokit-utils": "^5.1.0", | ||
"algosdk": "^2.5.0" | ||
}, | ||
"devDependencies": { | ||
{%- if use_typescript_jest %} | ||
"@types/jest": "^29.5.11", | ||
{%- endif %} | ||
"dotenv": "^16.0.3", | ||
"prettier": "^2.8.4", | ||
{%- if use_typescript_jest %} | ||
"ts-jest": "^29.1.1", | ||
{%- endif %} | ||
"ts-node-dev": "^2.0.0", | ||
"typescript": "^4.9.5" | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
... if deployment_language == 'typescript' or use_typescript_jest %}tsconfig.json{% endif %}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2020", | ||
"declaration": true, | ||
"declarationMap": true, | ||
"sourceMap": true, | ||
"strict": true, | ||
"noImplicitReturns": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"esModuleInterop": true, | ||
"experimentalDecorators": true, | ||
"emitDecoratorMetadata": true, | ||
"skipLibCheck": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"allowJs": false, | ||
"allowSyntheticDefaultImports": true, | ||
"moduleResolution": "Node", | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"noEmit": true | ||
}, | ||
"include": ["src/**/*.ts"], | ||
"exclude": ["node_modules", "dist", "coverage"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 24 additions & 8 deletions
32
...%}tests{% endif %}/{% if use_python_pytest %}{{ contract_name }}_test.py{% endif %}.jinja
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,48 @@ | ||
import algokit_utils | ||
import pytest | ||
from algokit_utils import get_localnet_default_account | ||
from algokit_utils.config import config | ||
from algosdk.v2client.algod import AlgodClient | ||
from algosdk.v2client.indexer import IndexerClient | ||
|
||
from smart_contracts.artifacts.{{ contract_name }}.client import {{ contract_name.split('_')|map('capitalize')|join }}Client | ||
from smart_contracts.artifacts.{{ contract_name }}.client import {% include pathjoin('includes', 'contract_name_pascal.jinja') %}Client | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def {{ contract_name }}_client( | ||
algod_client: AlgodClient, indexer_client: IndexerClient | ||
) -> {{ contract_name.split('_')|map('capitalize')|join }}Client: | ||
client = {{ contract_name.split('_')|map('capitalize')|join }}Client( | ||
) -> {% include pathjoin('includes', 'contract_name_pascal.jinja') %}Client: | ||
config.configure( | ||
debug=True, | ||
# trace_all=True, | ||
) | ||
|
||
client = {% include pathjoin('includes', 'contract_name_pascal.jinja') %}Client( | ||
algod_client, | ||
creator=get_localnet_default_account(algod_client), | ||
indexer_client=indexer_client, | ||
) | ||
|
||
client.deploy( | ||
on_schema_break=algokit_utils.OnSchemaBreak.ReplaceApp, | ||
on_update=algokit_utils.OnUpdate.UpdateApp, | ||
allow_delete=True, | ||
allow_update=True, | ||
on_schema_break=algokit_utils.OnSchemaBreak.AppendApp, | ||
on_update=algokit_utils.OnUpdate.AppendApp, | ||
) | ||
return client | ||
|
||
|
||
def test_says_hello({{ contract_name }}_client: {{ contract_name.split('_')|map('capitalize')|join }}Client) -> None: | ||
def test_says_hello({{ contract_name }}_client: {% include pathjoin('includes', 'contract_name_pascal.jinja') %}Client) -> None: | ||
result = {{ contract_name }}_client.hello(name="World") | ||
|
||
assert result.return_value == "Hello, World" | ||
|
||
|
||
def test_simulate_says_hello_with_correct_budget_consumed( | ||
{{ contract_name }}_client: {% include pathjoin('includes', 'contract_name_pascal.jinja') %}Client, algod_client: AlgodClient | ||
) -> None: | ||
result = ( | ||
{{ contract_name }}_client.compose().hello(name="World").hello(name="Jane").simulate() | ||
) | ||
|
||
assert result.abi_results[0].return_value == "Hello, World" | ||
assert result.abi_results[1].return_value == "Hello, Jane" | ||
assert result.simulate_response["txn-groups"][0]["app-budget-consumed"] < 100 |
Oops, something went wrong.