diff --git a/examples/generators/production_python_smart_contract_python/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/deploy_config.py.j2 b/examples/generators/production_python_smart_contract_python/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/deploy_config.py.j2 index 7d4017a..eb726b9 100644 --- a/examples/generators/production_python_smart_contract_python/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/deploy_config.py.j2 +++ b/examples/generators/production_python_smart_contract_python/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/deploy_config.py.j2 @@ -14,7 +14,7 @@ def deploy( app_spec: algokit_utils.ApplicationSpecification, deployer: algokit_utils.Account, ) -> None: - from smart_contracts.artifacts.{{ contract_name }}.client import ( + from smart_contracts.artifacts.{{ contract_name }}.{{ contract_name }}_client import ( {{ contract_name.split('_')|map('capitalize')|join }}Client, ) diff --git a/examples/generators/production_python_smart_contract_python/.tours/getting-started-with-your-algokit-project.tour b/examples/generators/production_python_smart_contract_python/.tours/getting-started-with-your-algokit-project.tour index 2c210ee..6d0f8b2 100644 --- a/examples/generators/production_python_smart_contract_python/.tours/getting-started-with-your-algokit-project.tour +++ b/examples/generators/production_python_smart_contract_python/.tours/getting-started-with-your-algokit-project.tour @@ -47,5 +47,10 @@ "description": "Uncomment the following lines to enable complementary utilities that will generate artifacts required for the [AlgoKit AVM Debugger](https://github.com/algorandfoundation/algokit-avm-vscode-debugger) VSCode plugin available on the [VSCode Extension Marketplace](https://marketplace.visualstudio.com/items?itemName=algorandfoundation.algokit-avm-vscode-debugger). A new folder will be automatically created in the `.algokit` directory with source maps of all TEAL contracts in this workspace, as well as traces that will appear in a folder at the root of the workspace. You can then use the traces as entry points to trigger the debug extension. Make sure to have the `.algokit.toml` file available at the root of the workspace.", "line": 15 } + { + "file": "smart_contracts/_helpers/__init__.py", + "description": "This folder contains helper scripts for contract management. These automate tasks like compiling, generating clients, and deploying. Usually, you won't need to edit these files, but advanced users can expand them for custom needs.", + "line": 1 + } ] } diff --git a/examples/generators/production_python_smart_contract_python/smart_contracts/__main__.py b/examples/generators/production_python_smart_contract_python/smart_contracts/__main__.py index f14eb5d..ab2e910 100644 --- a/examples/generators/production_python_smart_contract_python/smart_contracts/__main__.py +++ b/examples/generators/production_python_smart_contract_python/smart_contracts/__main__.py @@ -4,10 +4,9 @@ from dotenv import load_dotenv -from smart_contracts.config import contracts -from smart_contracts.helpers.build import build -from smart_contracts.helpers.deploy import deploy -from smart_contracts.helpers.util import find_app_spec_file +from smart_contracts._helpers.build import build +from smart_contracts._helpers.config import contracts +from smart_contracts._helpers.deploy import deploy # Uncomment the following lines to enable auto generation of AVM Debugger compliant sourcemap and simulation trace file. # Learn more about using AlgoKit AVM Debugger to debug your TEAL source codes and inspect various kinds of @@ -36,7 +35,14 @@ def main(action: str) -> None: for contract in contracts: logger.info(f"Deploying app {contract.name}") output_dir = artifact_path / contract.name - app_spec_file_name = find_app_spec_file(output_dir) + app_spec_file_name = next( + ( + file.name + for file in output_dir.iterdir() + if file.is_file() and file.suffixes == [".arc32", ".json"] + ), + None, + ) if app_spec_file_name is None: raise Exception("Could not deploy app, .arc32.json file not found") app_spec_path = output_dir / app_spec_file_name diff --git a/examples/generators/production_python_smart_contract_python/smart_contracts/helpers/__init__.py b/examples/generators/production_python_smart_contract_python/smart_contracts/_helpers/__init__.py similarity index 100% rename from examples/generators/production_python_smart_contract_python/smart_contracts/helpers/__init__.py rename to examples/generators/production_python_smart_contract_python/smart_contracts/_helpers/__init__.py diff --git a/examples/generators/production_python_smart_contract_python/smart_contracts/_helpers/build.py b/examples/generators/production_python_smart_contract_python/smart_contracts/_helpers/build.py new file mode 100644 index 0000000..771b585 --- /dev/null +++ b/examples/generators/production_python_smart_contract_python/smart_contracts/_helpers/build.py @@ -0,0 +1,74 @@ +import logging +import subprocess +from pathlib import Path +from shutil import rmtree + +logger = logging.getLogger(__name__) +deployment_extension = "py" + + +def _get_output_path(output_dir: Path, deployment_extension: str) -> Path: + return output_dir / Path( + "{contract_name}" + + ("_client" if deployment_extension == "py" else "Client") + + f".{deployment_extension}" + ) + + +def build(output_dir: Path, contract_path: Path) -> Path: + output_dir = output_dir.resolve() + if output_dir.exists(): + rmtree(output_dir) + output_dir.mkdir(exist_ok=True, parents=True) + logger.info(f"Exporting {contract_path} to {output_dir}") + + build_result = subprocess.run( + [ + "algokit", + "--no-color", + "compile", + "python", + contract_path.absolute(), + f"--out-dir={output_dir}", + "--output-arc32", + ], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + text=True, + ) + if build_result.returncode: + raise Exception(f"Could not build contract:\n{build_result.stdout}") + + app_spec_file_names = [file.name for file in output_dir.glob("*.arc32.json")] + + for app_spec_file_name in app_spec_file_names: + if app_spec_file_name is None: + raise Exception( + "Could not generate typed client, .arc32.json file not found" + ) + print(app_spec_file_name) + generate_result = subprocess.run( + [ + "algokit", + "generate", + "client", + output_dir, + "--output", + _get_output_path(output_dir, deployment_extension), + ], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + text=True, + ) + if generate_result.returncode: + if "No such command" in generate_result.stdout: + raise Exception( + "Could not generate typed client, requires AlgoKit 2.0.0 or " + "later. Please update AlgoKit" + ) + else: + raise Exception( + f"Could not generate typed client:\n{generate_result.stdout}" + ) + + return output_dir / app_spec_file_name diff --git a/examples/generators/production_python_smart_contract_python/smart_contracts/config.py b/examples/generators/production_python_smart_contract_python/smart_contracts/_helpers/config.py similarity index 100% rename from examples/generators/production_python_smart_contract_python/smart_contracts/config.py rename to examples/generators/production_python_smart_contract_python/smart_contracts/_helpers/config.py diff --git a/examples/generators/production_python_smart_contract_python/smart_contracts/helpers/deploy.py b/examples/generators/production_python_smart_contract_python/smart_contracts/_helpers/deploy.py similarity index 100% rename from examples/generators/production_python_smart_contract_python/smart_contracts/helpers/deploy.py rename to examples/generators/production_python_smart_contract_python/smart_contracts/_helpers/deploy.py diff --git a/examples/generators/production_python_smart_contract_python/smart_contracts/cool_contract/deploy_config.py b/examples/generators/production_python_smart_contract_python/smart_contracts/cool_contract/deploy_config.py index 3b14a80..c4f0afd 100644 --- a/examples/generators/production_python_smart_contract_python/smart_contracts/cool_contract/deploy_config.py +++ b/examples/generators/production_python_smart_contract_python/smart_contracts/cool_contract/deploy_config.py @@ -14,7 +14,7 @@ def deploy( app_spec: algokit_utils.ApplicationSpecification, deployer: algokit_utils.Account, ) -> None: - from smart_contracts.artifacts.cool_contract.client import ( + from smart_contracts.artifacts.cool_contract.cool_contract_client import ( CoolContractClient, ) diff --git a/examples/generators/production_python_smart_contract_python/smart_contracts/hello_world/deploy_config.py b/examples/generators/production_python_smart_contract_python/smart_contracts/hello_world/deploy_config.py index 82e67a8..36dda16 100644 --- a/examples/generators/production_python_smart_contract_python/smart_contracts/hello_world/deploy_config.py +++ b/examples/generators/production_python_smart_contract_python/smart_contracts/hello_world/deploy_config.py @@ -14,7 +14,7 @@ def deploy( app_spec: algokit_utils.ApplicationSpecification, deployer: algokit_utils.Account, ) -> None: - from smart_contracts.artifacts.hello_world.client import ( + from smart_contracts.artifacts.hello_world.hello_world_client import ( HelloWorldClient, ) diff --git a/examples/generators/production_python_smart_contract_python/smart_contracts/helpers/build.py b/examples/generators/production_python_smart_contract_python/smart_contracts/helpers/build.py deleted file mode 100644 index d797acd..0000000 --- a/examples/generators/production_python_smart_contract_python/smart_contracts/helpers/build.py +++ /dev/null @@ -1,63 +0,0 @@ -import logging -import subprocess -from pathlib import Path -from shutil import rmtree - -from smart_contracts.helpers.util import find_app_spec_file - -logger = logging.getLogger(__name__) -deployment_extension = "py" - - -def build(output_dir: Path, contract_path: Path) -> Path: - output_dir = output_dir.resolve() - if output_dir.exists(): - rmtree(output_dir) - output_dir.mkdir(exist_ok=True, parents=True) - logger.info(f"Exporting {contract_path} to {output_dir}") - - build_result = subprocess.run( - [ - "algokit", - "--no-color", - "compile", - "python", - contract_path.absolute(), - f"--out-dir={output_dir}", - "--output-arc32", - ], - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - text=True, - ) - if build_result.returncode: - raise Exception(f"Could not build contract:\n{build_result.stdout}") - - app_spec_file_name = find_app_spec_file(output_dir) - if app_spec_file_name is None: - raise Exception("Could not generate typed client, .arc32.json file not found") - - generate_result = subprocess.run( - [ - "algokit", - "generate", - "client", - output_dir / app_spec_file_name, - "--output", - output_dir / f"client.{deployment_extension}", - ], - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - text=True, - ) - if generate_result.returncode: - if "No such command" in generate_result.stdout: - raise Exception( - "Could not generate typed client, requires AlgoKit 2.0.0 or " - "later. Please update AlgoKit" - ) - else: - raise Exception( - f"Could not generate typed client:\n{generate_result.stdout}" - ) - return output_dir / app_spec_file_name diff --git a/examples/generators/production_python_smart_contract_python/smart_contracts/helpers/util.py b/examples/generators/production_python_smart_contract_python/smart_contracts/helpers/util.py deleted file mode 100644 index 6cf7e5b..0000000 --- a/examples/generators/production_python_smart_contract_python/smart_contracts/helpers/util.py +++ /dev/null @@ -1,8 +0,0 @@ -from pathlib import Path - - -def find_app_spec_file(output_dir: Path) -> str | None: - for file in output_dir.iterdir(): - if file.is_file() and file.suffixes == [".arc32", ".json"]: - return file.name - return None diff --git a/examples/generators/production_python_smart_contract_python/tests/hello_world_client_test.py b/examples/generators/production_python_smart_contract_python/tests/hello_world_client_test.py index bb13a43..1c8ebff 100644 --- a/examples/generators/production_python_smart_contract_python/tests/hello_world_client_test.py +++ b/examples/generators/production_python_smart_contract_python/tests/hello_world_client_test.py @@ -5,7 +5,7 @@ from algosdk.v2client.algod import AlgodClient from algosdk.v2client.indexer import IndexerClient -from smart_contracts.artifacts.hello_world.client import HelloWorldClient +from smart_contracts.artifacts.hello_world.hello_world_client import HelloWorldClient @pytest.fixture(scope="session") diff --git a/examples/generators/production_python_smart_contract_typescript/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/deploy-config.ts.j2 b/examples/generators/production_python_smart_contract_typescript/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/deploy-config.ts.j2 index e8c272e..68f8bc3 100644 --- a/examples/generators/production_python_smart_contract_typescript/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/deploy-config.ts.j2 +++ b/examples/generators/production_python_smart_contract_typescript/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/deploy-config.ts.j2 @@ -1,5 +1,5 @@ import * as algokit from '@algorandfoundation/algokit-utils' -import { {{ contract_name.split('_')|map('capitalize')|join }}Client } from '../artifacts/{{ contract_name }}/client' +import { {{ contract_name.split('_')|map('capitalize')|join }}Client } from '../artifacts/{{ contract_name }}/{{ contract_name.split('_')|map('capitalize')|join }}Client' // Below is a showcase of various deployment options you can use in TypeScript Client export async function deploy() { diff --git a/examples/generators/production_python_smart_contract_typescript/.tours/getting-started-with-your-algokit-project.tour b/examples/generators/production_python_smart_contract_typescript/.tours/getting-started-with-your-algokit-project.tour index c166a39..2eb8a76 100644 --- a/examples/generators/production_python_smart_contract_typescript/.tours/getting-started-with-your-algokit-project.tour +++ b/examples/generators/production_python_smart_contract_typescript/.tours/getting-started-with-your-algokit-project.tour @@ -42,5 +42,10 @@ "description": "Uncomment the following lines to enable complementary utilities that will generate artifacts required for the [AlgoKit AVM Debugger](https://github.com/algorandfoundation/algokit-avm-vscode-debugger) VSCode plugin available on the [VSCode Extension Marketplace](https://marketplace.visualstudio.com/items?itemName=algorandfoundation.algokit-avm-vscode-debugger). A new folder will be automatically created in the `.algokit` directory with source maps of all TEAL contracts in this workspace, as well as traces that will appear in a folder at the root of the workspace. You can then use the traces as entry points to trigger the debug extension. Make sure to have the `.algokit.toml` file available at the root of the workspace.", "line": 15 } + { + "file": "smart_contracts/_helpers/__init__.py", + "description": "This folder contains helper scripts for contract management. These automate tasks like compiling, generating clients, and deploying. Usually, you won't need to edit these files, but advanced users can expand them for custom needs.", + "line": 1 + } ] } diff --git a/examples/generators/production_python_smart_contract_typescript/smart_contracts/__main__.py b/examples/generators/production_python_smart_contract_typescript/smart_contracts/__main__.py index cf91c3a..6cf51e4 100644 --- a/examples/generators/production_python_smart_contract_typescript/smart_contracts/__main__.py +++ b/examples/generators/production_python_smart_contract_typescript/smart_contracts/__main__.py @@ -4,8 +4,8 @@ from dotenv import load_dotenv -from smart_contracts.config import contracts -from smart_contracts.helpers.build import build +from smart_contracts._helpers.build import build +from smart_contracts._helpers.config import contracts logging.basicConfig( level=logging.DEBUG, format="%(asctime)s %(levelname)-10s: %(message)s" diff --git a/examples/generators/production_python_smart_contract_typescript/smart_contracts/helpers/__init__.py b/examples/generators/production_python_smart_contract_typescript/smart_contracts/_helpers/__init__.py similarity index 100% rename from examples/generators/production_python_smart_contract_typescript/smart_contracts/helpers/__init__.py rename to examples/generators/production_python_smart_contract_typescript/smart_contracts/_helpers/__init__.py diff --git a/examples/generators/production_python_smart_contract_typescript/smart_contracts/_helpers/build.py b/examples/generators/production_python_smart_contract_typescript/smart_contracts/_helpers/build.py new file mode 100644 index 0000000..a78f2d9 --- /dev/null +++ b/examples/generators/production_python_smart_contract_typescript/smart_contracts/_helpers/build.py @@ -0,0 +1,74 @@ +import logging +import subprocess +from pathlib import Path +from shutil import rmtree + +logger = logging.getLogger(__name__) +deployment_extension = "ts" + + +def _get_output_path(output_dir: Path, deployment_extension: str) -> Path: + return output_dir / Path( + "{contract_name}" + + ("_client" if deployment_extension == "py" else "Client") + + f".{deployment_extension}" + ) + + +def build(output_dir: Path, contract_path: Path) -> Path: + output_dir = output_dir.resolve() + if output_dir.exists(): + rmtree(output_dir) + output_dir.mkdir(exist_ok=True, parents=True) + logger.info(f"Exporting {contract_path} to {output_dir}") + + build_result = subprocess.run( + [ + "algokit", + "--no-color", + "compile", + "python", + contract_path.absolute(), + f"--out-dir={output_dir}", + "--output-arc32", + ], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + text=True, + ) + if build_result.returncode: + raise Exception(f"Could not build contract:\n{build_result.stdout}") + + app_spec_file_names = [file.name for file in output_dir.glob("*.arc32.json")] + + for app_spec_file_name in app_spec_file_names: + if app_spec_file_name is None: + raise Exception( + "Could not generate typed client, .arc32.json file not found" + ) + print(app_spec_file_name) + generate_result = subprocess.run( + [ + "algokit", + "generate", + "client", + output_dir, + "--output", + _get_output_path(output_dir, deployment_extension), + ], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + text=True, + ) + if generate_result.returncode: + if "No such command" in generate_result.stdout: + raise Exception( + "Could not generate typed client, requires AlgoKit 2.0.0 or " + "later. Please update AlgoKit" + ) + else: + raise Exception( + f"Could not generate typed client:\n{generate_result.stdout}" + ) + + return output_dir / app_spec_file_name diff --git a/examples/generators/production_python_smart_contract_typescript/smart_contracts/config.py b/examples/generators/production_python_smart_contract_typescript/smart_contracts/_helpers/config.py similarity index 100% rename from examples/generators/production_python_smart_contract_typescript/smart_contracts/config.py rename to examples/generators/production_python_smart_contract_typescript/smart_contracts/_helpers/config.py diff --git a/examples/generators/production_python_smart_contract_typescript/smart_contracts/cool_contract/deploy-config.ts b/examples/generators/production_python_smart_contract_typescript/smart_contracts/cool_contract/deploy-config.ts index 2c5fbdf..893e0d7 100644 --- a/examples/generators/production_python_smart_contract_typescript/smart_contracts/cool_contract/deploy-config.ts +++ b/examples/generators/production_python_smart_contract_typescript/smart_contracts/cool_contract/deploy-config.ts @@ -1,5 +1,5 @@ import * as algokit from '@algorandfoundation/algokit-utils' -import { CoolContractClient } from '../artifacts/cool_contract/client' +import { CoolContractClient } from '../artifacts/cool_contract/CoolContractClient' // Below is a showcase of various deployment options you can use in TypeScript Client export async function deploy() { diff --git a/examples/generators/production_python_smart_contract_typescript/smart_contracts/hello_world/deploy-config.ts b/examples/generators/production_python_smart_contract_typescript/smart_contracts/hello_world/deploy-config.ts index c8b69ba..2a46d19 100644 --- a/examples/generators/production_python_smart_contract_typescript/smart_contracts/hello_world/deploy-config.ts +++ b/examples/generators/production_python_smart_contract_typescript/smart_contracts/hello_world/deploy-config.ts @@ -1,5 +1,5 @@ import * as algokit from '@algorandfoundation/algokit-utils' -import { HelloWorldClient } from '../artifacts/hello_world/client' +import { HelloWorldClient } from '../artifacts/hello_world/HelloWorldClient' // Below is a showcase of various deployment options you can use in TypeScript Client export async function deploy() { diff --git a/examples/generators/production_python_smart_contract_typescript/smart_contracts/helpers/build.py b/examples/generators/production_python_smart_contract_typescript/smart_contracts/helpers/build.py deleted file mode 100644 index c604b01..0000000 --- a/examples/generators/production_python_smart_contract_typescript/smart_contracts/helpers/build.py +++ /dev/null @@ -1,63 +0,0 @@ -import logging -import subprocess -from pathlib import Path -from shutil import rmtree - -from smart_contracts.helpers.util import find_app_spec_file - -logger = logging.getLogger(__name__) -deployment_extension = "ts" - - -def build(output_dir: Path, contract_path: Path) -> Path: - output_dir = output_dir.resolve() - if output_dir.exists(): - rmtree(output_dir) - output_dir.mkdir(exist_ok=True, parents=True) - logger.info(f"Exporting {contract_path} to {output_dir}") - - build_result = subprocess.run( - [ - "algokit", - "--no-color", - "compile", - "python", - contract_path.absolute(), - f"--out-dir={output_dir}", - "--output-arc32", - ], - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - text=True, - ) - if build_result.returncode: - raise Exception(f"Could not build contract:\n{build_result.stdout}") - - app_spec_file_name = find_app_spec_file(output_dir) - if app_spec_file_name is None: - raise Exception("Could not generate typed client, .arc32.json file not found") - - generate_result = subprocess.run( - [ - "algokit", - "generate", - "client", - output_dir / app_spec_file_name, - "--output", - output_dir / f"client.{deployment_extension}", - ], - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - text=True, - ) - if generate_result.returncode: - if "No such command" in generate_result.stdout: - raise Exception( - "Could not generate typed client, requires AlgoKit 2.0.0 or " - "later. Please update AlgoKit" - ) - else: - raise Exception( - f"Could not generate typed client:\n{generate_result.stdout}" - ) - return output_dir / app_spec_file_name diff --git a/examples/generators/production_python_smart_contract_typescript/smart_contracts/helpers/util.py b/examples/generators/production_python_smart_contract_typescript/smart_contracts/helpers/util.py deleted file mode 100644 index 6cf7e5b..0000000 --- a/examples/generators/production_python_smart_contract_typescript/smart_contracts/helpers/util.py +++ /dev/null @@ -1,8 +0,0 @@ -from pathlib import Path - - -def find_app_spec_file(output_dir: Path) -> str | None: - for file in output_dir.iterdir(): - if file.is_file() and file.suffixes == [".arc32", ".json"]: - return file.name - return None diff --git a/examples/generators/production_python_smart_contract_typescript/tests/hello-world.spec.ts b/examples/generators/production_python_smart_contract_typescript/tests/hello-world.spec.ts index b5ad81a..0c99f4b 100644 --- a/examples/generators/production_python_smart_contract_typescript/tests/hello-world.spec.ts +++ b/examples/generators/production_python_smart_contract_typescript/tests/hello-world.spec.ts @@ -1,5 +1,5 @@ import { algorandFixture } from '@algorandfoundation/algokit-utils/testing' -import { HelloWorldClient } from '../smart_contracts/artifacts/hello_world/client' +import { HelloWorldClient } from '../smart_contracts/artifacts/hello_world/HelloWorldClient' import { Account, Algodv2, Indexer } from 'algosdk' import * as algokit from '@algorandfoundation/algokit-utils' diff --git a/examples/generators/starter_python_smart_contract_python/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/deploy_config.py.j2 b/examples/generators/starter_python_smart_contract_python/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/deploy_config.py.j2 index 7d4017a..eb726b9 100644 --- a/examples/generators/starter_python_smart_contract_python/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/deploy_config.py.j2 +++ b/examples/generators/starter_python_smart_contract_python/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/deploy_config.py.j2 @@ -14,7 +14,7 @@ def deploy( app_spec: algokit_utils.ApplicationSpecification, deployer: algokit_utils.Account, ) -> None: - from smart_contracts.artifacts.{{ contract_name }}.client import ( + from smart_contracts.artifacts.{{ contract_name }}.{{ contract_name }}_client import ( {{ contract_name.split('_')|map('capitalize')|join }}Client, ) diff --git a/examples/generators/starter_python_smart_contract_python/.tours/getting-started-with-your-algokit-project.tour b/examples/generators/starter_python_smart_contract_python/.tours/getting-started-with-your-algokit-project.tour index 445db2a..a82b9c9 100644 --- a/examples/generators/starter_python_smart_contract_python/.tours/getting-started-with-your-algokit-project.tour +++ b/examples/generators/starter_python_smart_contract_python/.tours/getting-started-with-your-algokit-project.tour @@ -42,5 +42,10 @@ "description": "Uncomment the following lines to enable complementary utilities that will generate artifacts required for the [AlgoKit AVM Debugger](https://github.com/algorandfoundation/algokit-avm-vscode-debugger) VSCode plugin available on the [VSCode Extension Marketplace](https://marketplace.visualstudio.com/items?itemName=algorandfoundation.algokit-avm-vscode-debugger). A new folder will be automatically created in the `.algokit` directory with source maps of all TEAL contracts in this workspace, as well as traces that will appear in a folder at the root of the workspace. You can then use the traces as entry points to trigger the debug extension. Make sure to have the `.algokit.toml` file available at the root of the workspace.", "line": 15 } + { + "file": "smart_contracts/_helpers/__init__.py", + "description": "This folder contains helper scripts for contract management. These automate tasks like compiling, generating clients, and deploying. Usually, you won't need to edit these files, but advanced users can expand them for custom needs.", + "line": 1 + } ] } diff --git a/examples/generators/starter_python_smart_contract_python/smart_contracts/__main__.py b/examples/generators/starter_python_smart_contract_python/smart_contracts/__main__.py index f14eb5d..ab2e910 100644 --- a/examples/generators/starter_python_smart_contract_python/smart_contracts/__main__.py +++ b/examples/generators/starter_python_smart_contract_python/smart_contracts/__main__.py @@ -4,10 +4,9 @@ from dotenv import load_dotenv -from smart_contracts.config import contracts -from smart_contracts.helpers.build import build -from smart_contracts.helpers.deploy import deploy -from smart_contracts.helpers.util import find_app_spec_file +from smart_contracts._helpers.build import build +from smart_contracts._helpers.config import contracts +from smart_contracts._helpers.deploy import deploy # Uncomment the following lines to enable auto generation of AVM Debugger compliant sourcemap and simulation trace file. # Learn more about using AlgoKit AVM Debugger to debug your TEAL source codes and inspect various kinds of @@ -36,7 +35,14 @@ def main(action: str) -> None: for contract in contracts: logger.info(f"Deploying app {contract.name}") output_dir = artifact_path / contract.name - app_spec_file_name = find_app_spec_file(output_dir) + app_spec_file_name = next( + ( + file.name + for file in output_dir.iterdir() + if file.is_file() and file.suffixes == [".arc32", ".json"] + ), + None, + ) if app_spec_file_name is None: raise Exception("Could not deploy app, .arc32.json file not found") app_spec_path = output_dir / app_spec_file_name diff --git a/examples/generators/starter_python_smart_contract_python/smart_contracts/helpers/__init__.py b/examples/generators/starter_python_smart_contract_python/smart_contracts/_helpers/__init__.py similarity index 100% rename from examples/generators/starter_python_smart_contract_python/smart_contracts/helpers/__init__.py rename to examples/generators/starter_python_smart_contract_python/smart_contracts/_helpers/__init__.py diff --git a/examples/generators/starter_python_smart_contract_python/smart_contracts/_helpers/build.py b/examples/generators/starter_python_smart_contract_python/smart_contracts/_helpers/build.py new file mode 100644 index 0000000..771b585 --- /dev/null +++ b/examples/generators/starter_python_smart_contract_python/smart_contracts/_helpers/build.py @@ -0,0 +1,74 @@ +import logging +import subprocess +from pathlib import Path +from shutil import rmtree + +logger = logging.getLogger(__name__) +deployment_extension = "py" + + +def _get_output_path(output_dir: Path, deployment_extension: str) -> Path: + return output_dir / Path( + "{contract_name}" + + ("_client" if deployment_extension == "py" else "Client") + + f".{deployment_extension}" + ) + + +def build(output_dir: Path, contract_path: Path) -> Path: + output_dir = output_dir.resolve() + if output_dir.exists(): + rmtree(output_dir) + output_dir.mkdir(exist_ok=True, parents=True) + logger.info(f"Exporting {contract_path} to {output_dir}") + + build_result = subprocess.run( + [ + "algokit", + "--no-color", + "compile", + "python", + contract_path.absolute(), + f"--out-dir={output_dir}", + "--output-arc32", + ], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + text=True, + ) + if build_result.returncode: + raise Exception(f"Could not build contract:\n{build_result.stdout}") + + app_spec_file_names = [file.name for file in output_dir.glob("*.arc32.json")] + + for app_spec_file_name in app_spec_file_names: + if app_spec_file_name is None: + raise Exception( + "Could not generate typed client, .arc32.json file not found" + ) + print(app_spec_file_name) + generate_result = subprocess.run( + [ + "algokit", + "generate", + "client", + output_dir, + "--output", + _get_output_path(output_dir, deployment_extension), + ], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + text=True, + ) + if generate_result.returncode: + if "No such command" in generate_result.stdout: + raise Exception( + "Could not generate typed client, requires AlgoKit 2.0.0 or " + "later. Please update AlgoKit" + ) + else: + raise Exception( + f"Could not generate typed client:\n{generate_result.stdout}" + ) + + return output_dir / app_spec_file_name diff --git a/examples/generators/starter_python_smart_contract_python/smart_contracts/config.py b/examples/generators/starter_python_smart_contract_python/smart_contracts/_helpers/config.py similarity index 100% rename from examples/generators/starter_python_smart_contract_python/smart_contracts/config.py rename to examples/generators/starter_python_smart_contract_python/smart_contracts/_helpers/config.py diff --git a/examples/generators/starter_python_smart_contract_python/smart_contracts/helpers/deploy.py b/examples/generators/starter_python_smart_contract_python/smart_contracts/_helpers/deploy.py similarity index 100% rename from examples/generators/starter_python_smart_contract_python/smart_contracts/helpers/deploy.py rename to examples/generators/starter_python_smart_contract_python/smart_contracts/_helpers/deploy.py diff --git a/examples/generators/starter_python_smart_contract_python/smart_contracts/cool_contract/deploy_config.py b/examples/generators/starter_python_smart_contract_python/smart_contracts/cool_contract/deploy_config.py index 3b14a80..c4f0afd 100644 --- a/examples/generators/starter_python_smart_contract_python/smart_contracts/cool_contract/deploy_config.py +++ b/examples/generators/starter_python_smart_contract_python/smart_contracts/cool_contract/deploy_config.py @@ -14,7 +14,7 @@ def deploy( app_spec: algokit_utils.ApplicationSpecification, deployer: algokit_utils.Account, ) -> None: - from smart_contracts.artifacts.cool_contract.client import ( + from smart_contracts.artifacts.cool_contract.cool_contract_client import ( CoolContractClient, ) diff --git a/examples/generators/starter_python_smart_contract_python/smart_contracts/hello_world/deploy_config.py b/examples/generators/starter_python_smart_contract_python/smart_contracts/hello_world/deploy_config.py index 82e67a8..36dda16 100644 --- a/examples/generators/starter_python_smart_contract_python/smart_contracts/hello_world/deploy_config.py +++ b/examples/generators/starter_python_smart_contract_python/smart_contracts/hello_world/deploy_config.py @@ -14,7 +14,7 @@ def deploy( app_spec: algokit_utils.ApplicationSpecification, deployer: algokit_utils.Account, ) -> None: - from smart_contracts.artifacts.hello_world.client import ( + from smart_contracts.artifacts.hello_world.hello_world_client import ( HelloWorldClient, ) diff --git a/examples/generators/starter_python_smart_contract_python/smart_contracts/helpers/build.py b/examples/generators/starter_python_smart_contract_python/smart_contracts/helpers/build.py deleted file mode 100644 index d797acd..0000000 --- a/examples/generators/starter_python_smart_contract_python/smart_contracts/helpers/build.py +++ /dev/null @@ -1,63 +0,0 @@ -import logging -import subprocess -from pathlib import Path -from shutil import rmtree - -from smart_contracts.helpers.util import find_app_spec_file - -logger = logging.getLogger(__name__) -deployment_extension = "py" - - -def build(output_dir: Path, contract_path: Path) -> Path: - output_dir = output_dir.resolve() - if output_dir.exists(): - rmtree(output_dir) - output_dir.mkdir(exist_ok=True, parents=True) - logger.info(f"Exporting {contract_path} to {output_dir}") - - build_result = subprocess.run( - [ - "algokit", - "--no-color", - "compile", - "python", - contract_path.absolute(), - f"--out-dir={output_dir}", - "--output-arc32", - ], - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - text=True, - ) - if build_result.returncode: - raise Exception(f"Could not build contract:\n{build_result.stdout}") - - app_spec_file_name = find_app_spec_file(output_dir) - if app_spec_file_name is None: - raise Exception("Could not generate typed client, .arc32.json file not found") - - generate_result = subprocess.run( - [ - "algokit", - "generate", - "client", - output_dir / app_spec_file_name, - "--output", - output_dir / f"client.{deployment_extension}", - ], - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - text=True, - ) - if generate_result.returncode: - if "No such command" in generate_result.stdout: - raise Exception( - "Could not generate typed client, requires AlgoKit 2.0.0 or " - "later. Please update AlgoKit" - ) - else: - raise Exception( - f"Could not generate typed client:\n{generate_result.stdout}" - ) - return output_dir / app_spec_file_name diff --git a/examples/generators/starter_python_smart_contract_python/smart_contracts/helpers/util.py b/examples/generators/starter_python_smart_contract_python/smart_contracts/helpers/util.py deleted file mode 100644 index 6cf7e5b..0000000 --- a/examples/generators/starter_python_smart_contract_python/smart_contracts/helpers/util.py +++ /dev/null @@ -1,8 +0,0 @@ -from pathlib import Path - - -def find_app_spec_file(output_dir: Path) -> str | None: - for file in output_dir.iterdir(): - if file.is_file() and file.suffixes == [".arc32", ".json"]: - return file.name - return None diff --git a/examples/generators/starter_python_smart_contract_typescript/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/deploy-config.ts.j2 b/examples/generators/starter_python_smart_contract_typescript/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/deploy-config.ts.j2 index e8c272e..68f8bc3 100644 --- a/examples/generators/starter_python_smart_contract_typescript/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/deploy-config.ts.j2 +++ b/examples/generators/starter_python_smart_contract_typescript/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/deploy-config.ts.j2 @@ -1,5 +1,5 @@ import * as algokit from '@algorandfoundation/algokit-utils' -import { {{ contract_name.split('_')|map('capitalize')|join }}Client } from '../artifacts/{{ contract_name }}/client' +import { {{ contract_name.split('_')|map('capitalize')|join }}Client } from '../artifacts/{{ contract_name }}/{{ contract_name.split('_')|map('capitalize')|join }}Client' // Below is a showcase of various deployment options you can use in TypeScript Client export async function deploy() { diff --git a/examples/generators/starter_python_smart_contract_typescript/.tours/getting-started-with-your-algokit-project.tour b/examples/generators/starter_python_smart_contract_typescript/.tours/getting-started-with-your-algokit-project.tour index c166a39..2eb8a76 100644 --- a/examples/generators/starter_python_smart_contract_typescript/.tours/getting-started-with-your-algokit-project.tour +++ b/examples/generators/starter_python_smart_contract_typescript/.tours/getting-started-with-your-algokit-project.tour @@ -42,5 +42,10 @@ "description": "Uncomment the following lines to enable complementary utilities that will generate artifacts required for the [AlgoKit AVM Debugger](https://github.com/algorandfoundation/algokit-avm-vscode-debugger) VSCode plugin available on the [VSCode Extension Marketplace](https://marketplace.visualstudio.com/items?itemName=algorandfoundation.algokit-avm-vscode-debugger). A new folder will be automatically created in the `.algokit` directory with source maps of all TEAL contracts in this workspace, as well as traces that will appear in a folder at the root of the workspace. You can then use the traces as entry points to trigger the debug extension. Make sure to have the `.algokit.toml` file available at the root of the workspace.", "line": 15 } + { + "file": "smart_contracts/_helpers/__init__.py", + "description": "This folder contains helper scripts for contract management. These automate tasks like compiling, generating clients, and deploying. Usually, you won't need to edit these files, but advanced users can expand them for custom needs.", + "line": 1 + } ] } diff --git a/examples/generators/starter_python_smart_contract_typescript/smart_contracts/__main__.py b/examples/generators/starter_python_smart_contract_typescript/smart_contracts/__main__.py index cf91c3a..6cf51e4 100644 --- a/examples/generators/starter_python_smart_contract_typescript/smart_contracts/__main__.py +++ b/examples/generators/starter_python_smart_contract_typescript/smart_contracts/__main__.py @@ -4,8 +4,8 @@ from dotenv import load_dotenv -from smart_contracts.config import contracts -from smart_contracts.helpers.build import build +from smart_contracts._helpers.build import build +from smart_contracts._helpers.config import contracts logging.basicConfig( level=logging.DEBUG, format="%(asctime)s %(levelname)-10s: %(message)s" diff --git a/examples/generators/starter_python_smart_contract_typescript/smart_contracts/helpers/__init__.py b/examples/generators/starter_python_smart_contract_typescript/smart_contracts/_helpers/__init__.py similarity index 100% rename from examples/generators/starter_python_smart_contract_typescript/smart_contracts/helpers/__init__.py rename to examples/generators/starter_python_smart_contract_typescript/smart_contracts/_helpers/__init__.py diff --git a/examples/generators/starter_python_smart_contract_typescript/smart_contracts/_helpers/build.py b/examples/generators/starter_python_smart_contract_typescript/smart_contracts/_helpers/build.py new file mode 100644 index 0000000..a78f2d9 --- /dev/null +++ b/examples/generators/starter_python_smart_contract_typescript/smart_contracts/_helpers/build.py @@ -0,0 +1,74 @@ +import logging +import subprocess +from pathlib import Path +from shutil import rmtree + +logger = logging.getLogger(__name__) +deployment_extension = "ts" + + +def _get_output_path(output_dir: Path, deployment_extension: str) -> Path: + return output_dir / Path( + "{contract_name}" + + ("_client" if deployment_extension == "py" else "Client") + + f".{deployment_extension}" + ) + + +def build(output_dir: Path, contract_path: Path) -> Path: + output_dir = output_dir.resolve() + if output_dir.exists(): + rmtree(output_dir) + output_dir.mkdir(exist_ok=True, parents=True) + logger.info(f"Exporting {contract_path} to {output_dir}") + + build_result = subprocess.run( + [ + "algokit", + "--no-color", + "compile", + "python", + contract_path.absolute(), + f"--out-dir={output_dir}", + "--output-arc32", + ], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + text=True, + ) + if build_result.returncode: + raise Exception(f"Could not build contract:\n{build_result.stdout}") + + app_spec_file_names = [file.name for file in output_dir.glob("*.arc32.json")] + + for app_spec_file_name in app_spec_file_names: + if app_spec_file_name is None: + raise Exception( + "Could not generate typed client, .arc32.json file not found" + ) + print(app_spec_file_name) + generate_result = subprocess.run( + [ + "algokit", + "generate", + "client", + output_dir, + "--output", + _get_output_path(output_dir, deployment_extension), + ], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + text=True, + ) + if generate_result.returncode: + if "No such command" in generate_result.stdout: + raise Exception( + "Could not generate typed client, requires AlgoKit 2.0.0 or " + "later. Please update AlgoKit" + ) + else: + raise Exception( + f"Could not generate typed client:\n{generate_result.stdout}" + ) + + return output_dir / app_spec_file_name diff --git a/examples/generators/starter_python_smart_contract_typescript/smart_contracts/config.py b/examples/generators/starter_python_smart_contract_typescript/smart_contracts/_helpers/config.py similarity index 100% rename from examples/generators/starter_python_smart_contract_typescript/smart_contracts/config.py rename to examples/generators/starter_python_smart_contract_typescript/smart_contracts/_helpers/config.py diff --git a/examples/generators/starter_python_smart_contract_typescript/smart_contracts/cool_contract/deploy-config.ts b/examples/generators/starter_python_smart_contract_typescript/smart_contracts/cool_contract/deploy-config.ts index 2c5fbdf..893e0d7 100644 --- a/examples/generators/starter_python_smart_contract_typescript/smart_contracts/cool_contract/deploy-config.ts +++ b/examples/generators/starter_python_smart_contract_typescript/smart_contracts/cool_contract/deploy-config.ts @@ -1,5 +1,5 @@ import * as algokit from '@algorandfoundation/algokit-utils' -import { CoolContractClient } from '../artifacts/cool_contract/client' +import { CoolContractClient } from '../artifacts/cool_contract/CoolContractClient' // Below is a showcase of various deployment options you can use in TypeScript Client export async function deploy() { diff --git a/examples/generators/starter_python_smart_contract_typescript/smart_contracts/hello_world/deploy-config.ts b/examples/generators/starter_python_smart_contract_typescript/smart_contracts/hello_world/deploy-config.ts index c8b69ba..2a46d19 100644 --- a/examples/generators/starter_python_smart_contract_typescript/smart_contracts/hello_world/deploy-config.ts +++ b/examples/generators/starter_python_smart_contract_typescript/smart_contracts/hello_world/deploy-config.ts @@ -1,5 +1,5 @@ import * as algokit from '@algorandfoundation/algokit-utils' -import { HelloWorldClient } from '../artifacts/hello_world/client' +import { HelloWorldClient } from '../artifacts/hello_world/HelloWorldClient' // Below is a showcase of various deployment options you can use in TypeScript Client export async function deploy() { diff --git a/examples/generators/starter_python_smart_contract_typescript/smart_contracts/helpers/build.py b/examples/generators/starter_python_smart_contract_typescript/smart_contracts/helpers/build.py deleted file mode 100644 index c604b01..0000000 --- a/examples/generators/starter_python_smart_contract_typescript/smart_contracts/helpers/build.py +++ /dev/null @@ -1,63 +0,0 @@ -import logging -import subprocess -from pathlib import Path -from shutil import rmtree - -from smart_contracts.helpers.util import find_app_spec_file - -logger = logging.getLogger(__name__) -deployment_extension = "ts" - - -def build(output_dir: Path, contract_path: Path) -> Path: - output_dir = output_dir.resolve() - if output_dir.exists(): - rmtree(output_dir) - output_dir.mkdir(exist_ok=True, parents=True) - logger.info(f"Exporting {contract_path} to {output_dir}") - - build_result = subprocess.run( - [ - "algokit", - "--no-color", - "compile", - "python", - contract_path.absolute(), - f"--out-dir={output_dir}", - "--output-arc32", - ], - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - text=True, - ) - if build_result.returncode: - raise Exception(f"Could not build contract:\n{build_result.stdout}") - - app_spec_file_name = find_app_spec_file(output_dir) - if app_spec_file_name is None: - raise Exception("Could not generate typed client, .arc32.json file not found") - - generate_result = subprocess.run( - [ - "algokit", - "generate", - "client", - output_dir / app_spec_file_name, - "--output", - output_dir / f"client.{deployment_extension}", - ], - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - text=True, - ) - if generate_result.returncode: - if "No such command" in generate_result.stdout: - raise Exception( - "Could not generate typed client, requires AlgoKit 2.0.0 or " - "later. Please update AlgoKit" - ) - else: - raise Exception( - f"Could not generate typed client:\n{generate_result.stdout}" - ) - return output_dir / app_spec_file_name diff --git a/examples/generators/starter_python_smart_contract_typescript/smart_contracts/helpers/util.py b/examples/generators/starter_python_smart_contract_typescript/smart_contracts/helpers/util.py deleted file mode 100644 index 6cf7e5b..0000000 --- a/examples/generators/starter_python_smart_contract_typescript/smart_contracts/helpers/util.py +++ /dev/null @@ -1,8 +0,0 @@ -from pathlib import Path - - -def find_app_spec_file(output_dir: Path) -> str | None: - for file in output_dir.iterdir(): - if file.is_file() and file.suffixes == [".arc32", ".json"]: - return file.name - return None diff --git a/examples/production_python/.tours/getting-started-with-your-algokit-project.tour b/examples/production_python/.tours/getting-started-with-your-algokit-project.tour index 2c210ee..6d0f8b2 100644 --- a/examples/production_python/.tours/getting-started-with-your-algokit-project.tour +++ b/examples/production_python/.tours/getting-started-with-your-algokit-project.tour @@ -47,5 +47,10 @@ "description": "Uncomment the following lines to enable complementary utilities that will generate artifacts required for the [AlgoKit AVM Debugger](https://github.com/algorandfoundation/algokit-avm-vscode-debugger) VSCode plugin available on the [VSCode Extension Marketplace](https://marketplace.visualstudio.com/items?itemName=algorandfoundation.algokit-avm-vscode-debugger). A new folder will be automatically created in the `.algokit` directory with source maps of all TEAL contracts in this workspace, as well as traces that will appear in a folder at the root of the workspace. You can then use the traces as entry points to trigger the debug extension. Make sure to have the `.algokit.toml` file available at the root of the workspace.", "line": 15 } + { + "file": "smart_contracts/_helpers/__init__.py", + "description": "This folder contains helper scripts for contract management. These automate tasks like compiling, generating clients, and deploying. Usually, you won't need to edit these files, but advanced users can expand them for custom needs.", + "line": 1 + } ] } diff --git a/examples/production_python/smart_contracts/__main__.py b/examples/production_python/smart_contracts/__main__.py index f14eb5d..ab2e910 100644 --- a/examples/production_python/smart_contracts/__main__.py +++ b/examples/production_python/smart_contracts/__main__.py @@ -4,10 +4,9 @@ from dotenv import load_dotenv -from smart_contracts.config import contracts -from smart_contracts.helpers.build import build -from smart_contracts.helpers.deploy import deploy -from smart_contracts.helpers.util import find_app_spec_file +from smart_contracts._helpers.build import build +from smart_contracts._helpers.config import contracts +from smart_contracts._helpers.deploy import deploy # Uncomment the following lines to enable auto generation of AVM Debugger compliant sourcemap and simulation trace file. # Learn more about using AlgoKit AVM Debugger to debug your TEAL source codes and inspect various kinds of @@ -36,7 +35,14 @@ def main(action: str) -> None: for contract in contracts: logger.info(f"Deploying app {contract.name}") output_dir = artifact_path / contract.name - app_spec_file_name = find_app_spec_file(output_dir) + app_spec_file_name = next( + ( + file.name + for file in output_dir.iterdir() + if file.is_file() and file.suffixes == [".arc32", ".json"] + ), + None, + ) if app_spec_file_name is None: raise Exception("Could not deploy app, .arc32.json file not found") app_spec_path = output_dir / app_spec_file_name diff --git a/examples/production_python/smart_contracts/helpers/__init__.py b/examples/production_python/smart_contracts/_helpers/__init__.py similarity index 100% rename from examples/production_python/smart_contracts/helpers/__init__.py rename to examples/production_python/smart_contracts/_helpers/__init__.py diff --git a/examples/production_python/smart_contracts/_helpers/build.py b/examples/production_python/smart_contracts/_helpers/build.py new file mode 100644 index 0000000..771b585 --- /dev/null +++ b/examples/production_python/smart_contracts/_helpers/build.py @@ -0,0 +1,74 @@ +import logging +import subprocess +from pathlib import Path +from shutil import rmtree + +logger = logging.getLogger(__name__) +deployment_extension = "py" + + +def _get_output_path(output_dir: Path, deployment_extension: str) -> Path: + return output_dir / Path( + "{contract_name}" + + ("_client" if deployment_extension == "py" else "Client") + + f".{deployment_extension}" + ) + + +def build(output_dir: Path, contract_path: Path) -> Path: + output_dir = output_dir.resolve() + if output_dir.exists(): + rmtree(output_dir) + output_dir.mkdir(exist_ok=True, parents=True) + logger.info(f"Exporting {contract_path} to {output_dir}") + + build_result = subprocess.run( + [ + "algokit", + "--no-color", + "compile", + "python", + contract_path.absolute(), + f"--out-dir={output_dir}", + "--output-arc32", + ], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + text=True, + ) + if build_result.returncode: + raise Exception(f"Could not build contract:\n{build_result.stdout}") + + app_spec_file_names = [file.name for file in output_dir.glob("*.arc32.json")] + + for app_spec_file_name in app_spec_file_names: + if app_spec_file_name is None: + raise Exception( + "Could not generate typed client, .arc32.json file not found" + ) + print(app_spec_file_name) + generate_result = subprocess.run( + [ + "algokit", + "generate", + "client", + output_dir, + "--output", + _get_output_path(output_dir, deployment_extension), + ], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + text=True, + ) + if generate_result.returncode: + if "No such command" in generate_result.stdout: + raise Exception( + "Could not generate typed client, requires AlgoKit 2.0.0 or " + "later. Please update AlgoKit" + ) + else: + raise Exception( + f"Could not generate typed client:\n{generate_result.stdout}" + ) + + return output_dir / app_spec_file_name diff --git a/examples/production_python/smart_contracts/config.py b/examples/production_python/smart_contracts/_helpers/config.py similarity index 100% rename from examples/production_python/smart_contracts/config.py rename to examples/production_python/smart_contracts/_helpers/config.py diff --git a/examples/production_python/smart_contracts/helpers/deploy.py b/examples/production_python/smart_contracts/_helpers/deploy.py similarity index 100% rename from examples/production_python/smart_contracts/helpers/deploy.py rename to examples/production_python/smart_contracts/_helpers/deploy.py diff --git a/examples/production_python/smart_contracts/hello_world/deploy_config.py b/examples/production_python/smart_contracts/hello_world/deploy_config.py index 82e67a8..36dda16 100644 --- a/examples/production_python/smart_contracts/hello_world/deploy_config.py +++ b/examples/production_python/smart_contracts/hello_world/deploy_config.py @@ -14,7 +14,7 @@ def deploy( app_spec: algokit_utils.ApplicationSpecification, deployer: algokit_utils.Account, ) -> None: - from smart_contracts.artifacts.hello_world.client import ( + from smart_contracts.artifacts.hello_world.hello_world_client import ( HelloWorldClient, ) diff --git a/examples/production_python/smart_contracts/helpers/build.py b/examples/production_python/smart_contracts/helpers/build.py deleted file mode 100644 index d797acd..0000000 --- a/examples/production_python/smart_contracts/helpers/build.py +++ /dev/null @@ -1,63 +0,0 @@ -import logging -import subprocess -from pathlib import Path -from shutil import rmtree - -from smart_contracts.helpers.util import find_app_spec_file - -logger = logging.getLogger(__name__) -deployment_extension = "py" - - -def build(output_dir: Path, contract_path: Path) -> Path: - output_dir = output_dir.resolve() - if output_dir.exists(): - rmtree(output_dir) - output_dir.mkdir(exist_ok=True, parents=True) - logger.info(f"Exporting {contract_path} to {output_dir}") - - build_result = subprocess.run( - [ - "algokit", - "--no-color", - "compile", - "python", - contract_path.absolute(), - f"--out-dir={output_dir}", - "--output-arc32", - ], - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - text=True, - ) - if build_result.returncode: - raise Exception(f"Could not build contract:\n{build_result.stdout}") - - app_spec_file_name = find_app_spec_file(output_dir) - if app_spec_file_name is None: - raise Exception("Could not generate typed client, .arc32.json file not found") - - generate_result = subprocess.run( - [ - "algokit", - "generate", - "client", - output_dir / app_spec_file_name, - "--output", - output_dir / f"client.{deployment_extension}", - ], - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - text=True, - ) - if generate_result.returncode: - if "No such command" in generate_result.stdout: - raise Exception( - "Could not generate typed client, requires AlgoKit 2.0.0 or " - "later. Please update AlgoKit" - ) - else: - raise Exception( - f"Could not generate typed client:\n{generate_result.stdout}" - ) - return output_dir / app_spec_file_name diff --git a/examples/production_python/smart_contracts/helpers/util.py b/examples/production_python/smart_contracts/helpers/util.py deleted file mode 100644 index 6cf7e5b..0000000 --- a/examples/production_python/smart_contracts/helpers/util.py +++ /dev/null @@ -1,8 +0,0 @@ -from pathlib import Path - - -def find_app_spec_file(output_dir: Path) -> str | None: - for file in output_dir.iterdir(): - if file.is_file() and file.suffixes == [".arc32", ".json"]: - return file.name - return None diff --git a/examples/production_python/tests/hello_world_client_test.py b/examples/production_python/tests/hello_world_client_test.py index bb13a43..1c8ebff 100644 --- a/examples/production_python/tests/hello_world_client_test.py +++ b/examples/production_python/tests/hello_world_client_test.py @@ -5,7 +5,7 @@ from algosdk.v2client.algod import AlgodClient from algosdk.v2client.indexer import IndexerClient -from smart_contracts.artifacts.hello_world.client import HelloWorldClient +from smart_contracts.artifacts.hello_world.hello_world_client import HelloWorldClient @pytest.fixture(scope="session") diff --git a/examples/starter_python/.tours/getting-started-with-your-algokit-project.tour b/examples/starter_python/.tours/getting-started-with-your-algokit-project.tour index 445db2a..a82b9c9 100644 --- a/examples/starter_python/.tours/getting-started-with-your-algokit-project.tour +++ b/examples/starter_python/.tours/getting-started-with-your-algokit-project.tour @@ -42,5 +42,10 @@ "description": "Uncomment the following lines to enable complementary utilities that will generate artifacts required for the [AlgoKit AVM Debugger](https://github.com/algorandfoundation/algokit-avm-vscode-debugger) VSCode plugin available on the [VSCode Extension Marketplace](https://marketplace.visualstudio.com/items?itemName=algorandfoundation.algokit-avm-vscode-debugger). A new folder will be automatically created in the `.algokit` directory with source maps of all TEAL contracts in this workspace, as well as traces that will appear in a folder at the root of the workspace. You can then use the traces as entry points to trigger the debug extension. Make sure to have the `.algokit.toml` file available at the root of the workspace.", "line": 15 } + { + "file": "smart_contracts/_helpers/__init__.py", + "description": "This folder contains helper scripts for contract management. These automate tasks like compiling, generating clients, and deploying. Usually, you won't need to edit these files, but advanced users can expand them for custom needs.", + "line": 1 + } ] } diff --git a/examples/starter_python/smart_contracts/__main__.py b/examples/starter_python/smart_contracts/__main__.py index f14eb5d..ab2e910 100644 --- a/examples/starter_python/smart_contracts/__main__.py +++ b/examples/starter_python/smart_contracts/__main__.py @@ -4,10 +4,9 @@ from dotenv import load_dotenv -from smart_contracts.config import contracts -from smart_contracts.helpers.build import build -from smart_contracts.helpers.deploy import deploy -from smart_contracts.helpers.util import find_app_spec_file +from smart_contracts._helpers.build import build +from smart_contracts._helpers.config import contracts +from smart_contracts._helpers.deploy import deploy # Uncomment the following lines to enable auto generation of AVM Debugger compliant sourcemap and simulation trace file. # Learn more about using AlgoKit AVM Debugger to debug your TEAL source codes and inspect various kinds of @@ -36,7 +35,14 @@ def main(action: str) -> None: for contract in contracts: logger.info(f"Deploying app {contract.name}") output_dir = artifact_path / contract.name - app_spec_file_name = find_app_spec_file(output_dir) + app_spec_file_name = next( + ( + file.name + for file in output_dir.iterdir() + if file.is_file() and file.suffixes == [".arc32", ".json"] + ), + None, + ) if app_spec_file_name is None: raise Exception("Could not deploy app, .arc32.json file not found") app_spec_path = output_dir / app_spec_file_name diff --git a/examples/starter_python/smart_contracts/helpers/__init__.py b/examples/starter_python/smart_contracts/_helpers/__init__.py similarity index 100% rename from examples/starter_python/smart_contracts/helpers/__init__.py rename to examples/starter_python/smart_contracts/_helpers/__init__.py diff --git a/examples/starter_python/smart_contracts/_helpers/build.py b/examples/starter_python/smart_contracts/_helpers/build.py new file mode 100644 index 0000000..771b585 --- /dev/null +++ b/examples/starter_python/smart_contracts/_helpers/build.py @@ -0,0 +1,74 @@ +import logging +import subprocess +from pathlib import Path +from shutil import rmtree + +logger = logging.getLogger(__name__) +deployment_extension = "py" + + +def _get_output_path(output_dir: Path, deployment_extension: str) -> Path: + return output_dir / Path( + "{contract_name}" + + ("_client" if deployment_extension == "py" else "Client") + + f".{deployment_extension}" + ) + + +def build(output_dir: Path, contract_path: Path) -> Path: + output_dir = output_dir.resolve() + if output_dir.exists(): + rmtree(output_dir) + output_dir.mkdir(exist_ok=True, parents=True) + logger.info(f"Exporting {contract_path} to {output_dir}") + + build_result = subprocess.run( + [ + "algokit", + "--no-color", + "compile", + "python", + contract_path.absolute(), + f"--out-dir={output_dir}", + "--output-arc32", + ], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + text=True, + ) + if build_result.returncode: + raise Exception(f"Could not build contract:\n{build_result.stdout}") + + app_spec_file_names = [file.name for file in output_dir.glob("*.arc32.json")] + + for app_spec_file_name in app_spec_file_names: + if app_spec_file_name is None: + raise Exception( + "Could not generate typed client, .arc32.json file not found" + ) + print(app_spec_file_name) + generate_result = subprocess.run( + [ + "algokit", + "generate", + "client", + output_dir, + "--output", + _get_output_path(output_dir, deployment_extension), + ], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + text=True, + ) + if generate_result.returncode: + if "No such command" in generate_result.stdout: + raise Exception( + "Could not generate typed client, requires AlgoKit 2.0.0 or " + "later. Please update AlgoKit" + ) + else: + raise Exception( + f"Could not generate typed client:\n{generate_result.stdout}" + ) + + return output_dir / app_spec_file_name diff --git a/examples/starter_python/smart_contracts/config.py b/examples/starter_python/smart_contracts/_helpers/config.py similarity index 100% rename from examples/starter_python/smart_contracts/config.py rename to examples/starter_python/smart_contracts/_helpers/config.py diff --git a/examples/starter_python/smart_contracts/helpers/deploy.py b/examples/starter_python/smart_contracts/_helpers/deploy.py similarity index 100% rename from examples/starter_python/smart_contracts/helpers/deploy.py rename to examples/starter_python/smart_contracts/_helpers/deploy.py diff --git a/examples/starter_python/smart_contracts/hello_world/deploy_config.py b/examples/starter_python/smart_contracts/hello_world/deploy_config.py index 82e67a8..36dda16 100644 --- a/examples/starter_python/smart_contracts/hello_world/deploy_config.py +++ b/examples/starter_python/smart_contracts/hello_world/deploy_config.py @@ -14,7 +14,7 @@ def deploy( app_spec: algokit_utils.ApplicationSpecification, deployer: algokit_utils.Account, ) -> None: - from smart_contracts.artifacts.hello_world.client import ( + from smart_contracts.artifacts.hello_world.hello_world_client import ( HelloWorldClient, ) diff --git a/examples/starter_python/smart_contracts/helpers/build.py b/examples/starter_python/smart_contracts/helpers/build.py deleted file mode 100644 index d797acd..0000000 --- a/examples/starter_python/smart_contracts/helpers/build.py +++ /dev/null @@ -1,63 +0,0 @@ -import logging -import subprocess -from pathlib import Path -from shutil import rmtree - -from smart_contracts.helpers.util import find_app_spec_file - -logger = logging.getLogger(__name__) -deployment_extension = "py" - - -def build(output_dir: Path, contract_path: Path) -> Path: - output_dir = output_dir.resolve() - if output_dir.exists(): - rmtree(output_dir) - output_dir.mkdir(exist_ok=True, parents=True) - logger.info(f"Exporting {contract_path} to {output_dir}") - - build_result = subprocess.run( - [ - "algokit", - "--no-color", - "compile", - "python", - contract_path.absolute(), - f"--out-dir={output_dir}", - "--output-arc32", - ], - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - text=True, - ) - if build_result.returncode: - raise Exception(f"Could not build contract:\n{build_result.stdout}") - - app_spec_file_name = find_app_spec_file(output_dir) - if app_spec_file_name is None: - raise Exception("Could not generate typed client, .arc32.json file not found") - - generate_result = subprocess.run( - [ - "algokit", - "generate", - "client", - output_dir / app_spec_file_name, - "--output", - output_dir / f"client.{deployment_extension}", - ], - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - text=True, - ) - if generate_result.returncode: - if "No such command" in generate_result.stdout: - raise Exception( - "Could not generate typed client, requires AlgoKit 2.0.0 or " - "later. Please update AlgoKit" - ) - else: - raise Exception( - f"Could not generate typed client:\n{generate_result.stdout}" - ) - return output_dir / app_spec_file_name diff --git a/examples/starter_python/smart_contracts/helpers/util.py b/examples/starter_python/smart_contracts/helpers/util.py deleted file mode 100644 index 6cf7e5b..0000000 --- a/examples/starter_python/smart_contracts/helpers/util.py +++ /dev/null @@ -1,8 +0,0 @@ -from pathlib import Path - - -def find_app_spec_file(output_dir: Path) -> str | None: - for file in output_dir.iterdir(): - if file.is_file() and file.suffixes == [".arc32", ".json"]: - return file.name - return None diff --git a/template_content/.algokit/generators/create_contract/smart_contracts/{% raw %}{{ contract_name }}{% endraw %}/{% if deployment_language == 'python' %}deploy_config.py.j2{% endif %} b/template_content/.algokit/generators/create_contract/smart_contracts/{% raw %}{{ contract_name }}{% endraw %}/{% if deployment_language == 'python' %}deploy_config.py.j2{% endif %} index 7d4017a..eb726b9 100644 --- a/template_content/.algokit/generators/create_contract/smart_contracts/{% raw %}{{ contract_name }}{% endraw %}/{% if deployment_language == 'python' %}deploy_config.py.j2{% endif %} +++ b/template_content/.algokit/generators/create_contract/smart_contracts/{% raw %}{{ contract_name }}{% endraw %}/{% if deployment_language == 'python' %}deploy_config.py.j2{% endif %} @@ -14,7 +14,7 @@ def deploy( app_spec: algokit_utils.ApplicationSpecification, deployer: algokit_utils.Account, ) -> None: - from smart_contracts.artifacts.{{ contract_name }}.client import ( + from smart_contracts.artifacts.{{ contract_name }}.{{ contract_name }}_client import ( {{ contract_name.split('_')|map('capitalize')|join }}Client, ) diff --git a/template_content/.algokit/generators/create_contract/smart_contracts/{% raw %}{{ contract_name }}{% endraw %}/{% if deployment_language == 'typescript' %}deploy-config.ts.j2{% endif %} b/template_content/.algokit/generators/create_contract/smart_contracts/{% raw %}{{ contract_name }}{% endraw %}/{% if deployment_language == 'typescript' %}deploy-config.ts.j2{% endif %} index e8c272e..68f8bc3 100644 --- a/template_content/.algokit/generators/create_contract/smart_contracts/{% raw %}{{ contract_name }}{% endraw %}/{% if deployment_language == 'typescript' %}deploy-config.ts.j2{% endif %} +++ b/template_content/.algokit/generators/create_contract/smart_contracts/{% raw %}{{ contract_name }}{% endraw %}/{% if deployment_language == 'typescript' %}deploy-config.ts.j2{% endif %} @@ -1,5 +1,5 @@ import * as algokit from '@algorandfoundation/algokit-utils' -import { {{ contract_name.split('_')|map('capitalize')|join }}Client } from '../artifacts/{{ contract_name }}/client' +import { {{ contract_name.split('_')|map('capitalize')|join }}Client } from '../artifacts/{{ contract_name }}/{{ contract_name.split('_')|map('capitalize')|join }}Client' // Below is a showcase of various deployment options you can use in TypeScript Client export async function deploy() { diff --git a/template_content/smart_contracts/__main__.py.jinja b/template_content/smart_contracts/__main__.py.jinja index f40cb95..dc3e78a 100644 --- a/template_content/smart_contracts/__main__.py.jinja +++ b/template_content/smart_contracts/__main__.py.jinja @@ -4,11 +4,10 @@ from pathlib import Path from dotenv import load_dotenv -from smart_contracts.config import contracts -from smart_contracts.helpers.build import build +from smart_contracts._helpers.build import build +from smart_contracts._helpers.config import contracts {% if deployment_language == 'python' -%} -from smart_contracts.helpers.deploy import deploy -from smart_contracts.helpers.util import find_app_spec_file +from smart_contracts._helpers.deploy import deploy # Uncomment the following lines to enable auto generation of AVM Debugger compliant sourcemap and simulation trace file. # Learn more about using AlgoKit AVM Debugger to debug your TEAL source codes and inspect various kinds of @@ -39,7 +38,14 @@ def main(action: str) -> None: for contract in contracts: logger.info(f"Deploying app {contract.name}") output_dir = artifact_path / contract.name - app_spec_file_name = find_app_spec_file(output_dir) + app_spec_file_name = next( + ( + file.name + for file in output_dir.iterdir() + if file.is_file() and file.suffixes == [".arc32", ".json"] + ), + None, + ) if app_spec_file_name is None: raise Exception("Could not deploy app, .arc32.json file not found") app_spec_path = output_dir / app_spec_file_name diff --git a/template_content/smart_contracts/helpers/__init__.py b/template_content/smart_contracts/_helpers/__init__.py similarity index 100% rename from template_content/smart_contracts/helpers/__init__.py rename to template_content/smart_contracts/_helpers/__init__.py diff --git a/template_content/smart_contracts/_helpers/build.py.jinja b/template_content/smart_contracts/_helpers/build.py.jinja new file mode 100644 index 0000000..fd1e9fa --- /dev/null +++ b/template_content/smart_contracts/_helpers/build.py.jinja @@ -0,0 +1,77 @@ +import logging +import subprocess +from pathlib import Path +from shutil import rmtree + +logger = logging.getLogger(__name__) +{% if deployment_language == 'python' -%} +deployment_extension = "py" +{% elif deployment_language == 'typescript' -%} +deployment_extension = "ts" +{% endif %} + +def _get_output_path(output_dir: Path, deployment_extension: str) -> Path: + return output_dir / Path( + "{contract_name}" + + ("_client" if deployment_extension == "py" else "Client") + + f".{deployment_extension}" + ) + + +def build(output_dir: Path, contract_path: Path) -> Path: + output_dir = output_dir.resolve() + if output_dir.exists(): + rmtree(output_dir) + output_dir.mkdir(exist_ok=True, parents=True) + logger.info(f"Exporting {contract_path} to {output_dir}") + + build_result = subprocess.run( + [ + "algokit", + "--no-color", + "compile", + "python", + contract_path.absolute(), + f"--out-dir={output_dir}", + "--output-arc32", + ], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + text=True, + ) + if build_result.returncode: + raise Exception(f"Could not build contract:\n{build_result.stdout}") + + app_spec_file_names = [file.name for file in output_dir.glob("*.arc32.json")] + + for app_spec_file_name in app_spec_file_names: + if app_spec_file_name is None: + raise Exception( + "Could not generate typed client, .arc32.json file not found" + ) + print(app_spec_file_name) + generate_result = subprocess.run( + [ + "algokit", + "generate", + "client", + output_dir, + "--output", + _get_output_path(output_dir, deployment_extension), + ], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + text=True, + ) + if generate_result.returncode: + if "No such command" in generate_result.stdout: + raise Exception( + "Could not generate typed client, requires AlgoKit 2.0.0 or " + "later. Please update AlgoKit" + ) + else: + raise Exception( + f"Could not generate typed client:\n{generate_result.stdout}" + ) + + return output_dir / app_spec_file_name diff --git a/template_content/smart_contracts/config.py.jinja b/template_content/smart_contracts/_helpers/config.py.jinja similarity index 100% rename from template_content/smart_contracts/config.py.jinja rename to template_content/smart_contracts/_helpers/config.py.jinja diff --git a/template_content/smart_contracts/helpers/{% if deployment_language == 'python' %}deploy.py{% endif %}.jinja b/template_content/smart_contracts/_helpers/{% if deployment_language == 'python' %}deploy.py{% endif %}.jinja similarity index 100% rename from template_content/smart_contracts/helpers/{% if deployment_language == 'python' %}deploy.py{% endif %}.jinja rename to template_content/smart_contracts/_helpers/{% if deployment_language == 'python' %}deploy.py{% endif %}.jinja diff --git a/template_content/smart_contracts/helpers/build.py.jinja b/template_content/smart_contracts/helpers/build.py.jinja deleted file mode 100644 index c723efb..0000000 --- a/template_content/smart_contracts/helpers/build.py.jinja +++ /dev/null @@ -1,66 +0,0 @@ -import logging -import subprocess -from pathlib import Path -from shutil import rmtree - -from smart_contracts.helpers.util import find_app_spec_file - -logger = logging.getLogger(__name__) -{% if deployment_language == 'python' -%} -deployment_extension = "py" -{% elif deployment_language == 'typescript' -%} -deployment_extension = "ts" -{% endif %} - -def build(output_dir: Path, contract_path: Path) -> Path: - output_dir = output_dir.resolve() - if output_dir.exists(): - rmtree(output_dir) - output_dir.mkdir(exist_ok=True, parents=True) - logger.info(f"Exporting {contract_path} to {output_dir}") - - build_result = subprocess.run( - [ - "algokit", - "--no-color", - "compile", - "python", - contract_path.absolute(), - f"--out-dir={output_dir}", - "--output-arc32", - ], - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - text=True, - ) - if build_result.returncode: - raise Exception(f"Could not build contract:\n{build_result.stdout}") - - app_spec_file_name = find_app_spec_file(output_dir) - if app_spec_file_name is None: - raise Exception("Could not generate typed client, .arc32.json file not found") - - generate_result = subprocess.run( - [ - "algokit", - "generate", - "client", - output_dir / app_spec_file_name, - "--output", - output_dir / f"client.{deployment_extension}", - ], - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - text=True, - ) - if generate_result.returncode: - if "No such command" in generate_result.stdout: - raise Exception( - "Could not generate typed client, requires AlgoKit 2.0.0 or " - "later. Please update AlgoKit" - ) - else: - raise Exception( - f"Could not generate typed client:\n{generate_result.stdout}" - ) - return output_dir / app_spec_file_name diff --git a/template_content/smart_contracts/helpers/util.py b/template_content/smart_contracts/helpers/util.py deleted file mode 100644 index 6cf7e5b..0000000 --- a/template_content/smart_contracts/helpers/util.py +++ /dev/null @@ -1,8 +0,0 @@ -from pathlib import Path - - -def find_app_spec_file(output_dir: Path) -> str | None: - for file in output_dir.iterdir(): - if file.is_file() and file.suffixes == [".arc32", ".json"]: - return file.name - return None diff --git a/template_content/smart_contracts/{{ contract_name }}/{% if deployment_language == 'python' %}deploy_config.py{% endif %}.jinja b/template_content/smart_contracts/{{ contract_name }}/{% if deployment_language == 'python' %}deploy_config.py{% endif %}.jinja index 61612db..a261e79 100644 --- a/template_content/smart_contracts/{{ contract_name }}/{% if deployment_language == 'python' %}deploy_config.py{% endif %}.jinja +++ b/template_content/smart_contracts/{{ contract_name }}/{% if deployment_language == 'python' %}deploy_config.py{% endif %}.jinja @@ -14,7 +14,7 @@ def deploy( app_spec: algokit_utils.ApplicationSpecification, deployer: algokit_utils.Account, ) -> None: - from smart_contracts.artifacts.{{ contract_name }}.client import ( + from smart_contracts.artifacts.{{ contract_name }}.{{ contract_name }}_client import ( {% include pathjoin('includes', 'contract_name_pascal.jinja') %}Client, ) diff --git a/template_content/smart_contracts/{{ contract_name }}/{% if deployment_language == 'typescript' %}deploy-config.ts{% endif %}.jinja b/template_content/smart_contracts/{{ contract_name }}/{% if deployment_language == 'typescript' %}deploy-config.ts{% endif %}.jinja index b5ff685..2a48d76 100644 --- a/template_content/smart_contracts/{{ contract_name }}/{% if deployment_language == 'typescript' %}deploy-config.ts{% endif %}.jinja +++ b/template_content/smart_contracts/{{ contract_name }}/{% if deployment_language == 'typescript' %}deploy-config.ts{% endif %}.jinja @@ -1,5 +1,5 @@ import * as algokit from '@algorandfoundation/algokit-utils' -import { {{ contract_name.split('_')|map('capitalize')|join }}Client } from '../artifacts/{{ contract_name }}/client' +import { {{ contract_name.split('_')|map('capitalize')|join }}Client } from '../artifacts/{{ contract_name }}/{{ contract_name.split('_')|map('capitalize')|join }}Client' // Below is a showcase of various deployment options you can use in TypeScript Client export async function deploy() { diff --git a/template_content/{% if code_tours %}.tours{% endif %}/getting-started-with-your-algokit-project.tour.jinja b/template_content/{% if code_tours %}.tours{% endif %}/getting-started-with-your-algokit-project.tour.jinja index 2ba5c47..f484b33 100644 --- a/template_content/{% if code_tours %}.tours{% endif %}/getting-started-with-your-algokit-project.tour.jinja +++ b/template_content/{% if code_tours %}.tours{% endif %}/getting-started-with-your-algokit-project.tour.jinja @@ -49,5 +49,10 @@ "description": "Uncomment the following lines to enable complementary utilities that will generate artifacts required for the [AlgoKit AVM Debugger](https://github.com/algorandfoundation/algokit-avm-vscode-debugger) VSCode plugin available on the [VSCode Extension Marketplace](https://marketplace.visualstudio.com/items?itemName=algorandfoundation.algokit-avm-vscode-debugger). A new folder will be automatically created in the `.algokit` directory with source maps of all TEAL contracts in this workspace, as well as traces that will appear in a folder at the root of the workspace. You can then use the traces as entry points to trigger the debug extension. Make sure to have the `.algokit.toml` file available at the root of the workspace.", "line": 15 } + { + "file": "smart_contracts/_helpers/__init__.py", + "description": "This folder contains helper scripts for contract management. These automate tasks like compiling, generating clients, and deploying. Usually, you won't need to edit these files, but advanced users can expand them for custom needs.", + "line": 1 + } ] } diff --git a/template_content/{% if use_python_pytest %}tests{% endif %}/{% if use_python_pytest %}{{ contract_name }}_client_test.py{% endif %}.jinja b/template_content/{% if use_python_pytest %}tests{% endif %}/{% if use_python_pytest %}{{ contract_name }}_client_test.py{% endif %}.jinja index bbd585a..e3b5098 100644 --- a/template_content/{% if use_python_pytest %}tests{% endif %}/{% if use_python_pytest %}{{ contract_name }}_client_test.py{% endif %}.jinja +++ b/template_content/{% if use_python_pytest %}tests{% endif %}/{% if use_python_pytest %}{{ contract_name }}_client_test.py{% endif %}.jinja @@ -5,7 +5,7 @@ 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 {% include pathjoin('includes', 'contract_name_pascal.jinja') %}Client +from smart_contracts.artifacts.{{ contract_name }}.{{ contract_name }}_client import {% include pathjoin('includes', 'contract_name_pascal.jinja') %}Client @pytest.fixture(scope="session") diff --git a/template_content/{% if use_typescript_jest %}tests{% endif %}/{% if use_typescript_jest %}{% include pathjoin('includes', 'contract_name_kebab.jinja') %}.spec.ts{% endif %}.jinja b/template_content/{% if use_typescript_jest %}tests{% endif %}/{% if use_typescript_jest %}{% include pathjoin('includes', 'contract_name_kebab.jinja') %}.spec.ts{% endif %}.jinja index 25c4aa5..5f54543 100644 --- a/template_content/{% if use_typescript_jest %}tests{% endif %}/{% if use_typescript_jest %}{% include pathjoin('includes', 'contract_name_kebab.jinja') %}.spec.ts{% endif %}.jinja +++ b/template_content/{% if use_typescript_jest %}tests{% endif %}/{% if use_typescript_jest %}{% include pathjoin('includes', 'contract_name_kebab.jinja') %}.spec.ts{% endif %}.jinja @@ -1,5 +1,5 @@ import { algorandFixture } from '@algorandfoundation/algokit-utils/testing' -import { {% include pathjoin('includes', 'contract_name_pascal.jinja') %}Client } from '../smart_contracts/artifacts/{{ contract_name }}/client' +import { {% include pathjoin('includes', 'contract_name_pascal.jinja') %}Client } from '../smart_contracts/artifacts/{{ contract_name }}/{{ contract_name.split('_')|map('capitalize')|join }}Client' import { Account, Algodv2, Indexer } from 'algosdk' import * as algokit from '@algorandfoundation/algokit-utils'