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 68f8bc3..ac114cc 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 @@ -5,43 +5,26 @@ import { {{ contract_name.split('_')|map('capitalize')|join }}Client } from '../ export async function deploy() { console.log('=== Deploying {{ contract_name.split('_')|map('capitalize')|join }} ===') - const algod = algokit.getAlgoClient() - const indexer = algokit.getAlgoIndexerClient() - const deployer = await algokit.mnemonicAccountFromEnvironment({ name: 'DEPLOYER', fundWith: algokit.algos(3) }, algod) - await algokit.ensureFunded( - { - accountToFund: deployer, - minSpendingBalance: algokit.algos(2), - minFundingIncrement: algokit.algos(2), - }, - algod, - ) - const appClient = new {{ contract_name.split('_')|map('capitalize')|join }}Client( - { - resolveBy: 'creatorAndName', - findExistingUsing: indexer, - sender: deployer, - creatorAddress: deployer.addr, - }, - algod, - ) + const algorand = algokit.AlgorandClient.fromEnvironment() + const deployer = await algorand.account.fromEnvironment('DEPLOYER') + + const appClient = algorand.client.getTypedAppClientByCreatorAndName({{ contract_name.split('_')|map('capitalize')|join }}Client, { + sender: deployer, + creatorAddress: deployer.addr, + }) const app = await appClient.deploy({ onSchemaBreak: 'append', onUpdate: 'append', }) - // If app was just created fund the app account if (['create', 'replace'].includes(app.operationPerformed)) { - algokit.transferAlgos( - { - amount: algokit.algos(1), - from: deployer, - to: app.appAddress, - }, - algod, - ) + await algorand.send.payment({ + amount: algokit.algos(1), + sender: deployer.addr, + receiver: app.appAddress, + }) } const method = 'hello' 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 893e0d7..a5dc036 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 @@ -5,43 +5,26 @@ import { CoolContractClient } from '../artifacts/cool_contract/CoolContractClien export async function deploy() { console.log('=== Deploying CoolContract ===') - const algod = algokit.getAlgoClient() - const indexer = algokit.getAlgoIndexerClient() - const deployer = await algokit.mnemonicAccountFromEnvironment({ name: 'DEPLOYER', fundWith: algokit.algos(3) }, algod) - await algokit.ensureFunded( - { - accountToFund: deployer, - minSpendingBalance: algokit.algos(2), - minFundingIncrement: algokit.algos(2), - }, - algod, - ) - const appClient = new CoolContractClient( - { - resolveBy: 'creatorAndName', - findExistingUsing: indexer, - sender: deployer, - creatorAddress: deployer.addr, - }, - algod, - ) + const algorand = algokit.AlgorandClient.fromEnvironment() + const deployer = await algorand.account.fromEnvironment('DEPLOYER') + + const appClient = algorand.client.getTypedAppClientByCreatorAndName(CoolContractClient, { + sender: deployer, + creatorAddress: deployer.addr, + }) const app = await appClient.deploy({ onSchemaBreak: 'append', onUpdate: 'append', }) - // If app was just created fund the app account if (['create', 'replace'].includes(app.operationPerformed)) { - algokit.transferAlgos( - { - amount: algokit.algos(1), - from: deployer, - to: app.appAddress, - }, - algod, - ) + await algorand.send.payment({ + amount: algokit.algos(1), + sender: deployer.addr, + receiver: app.appAddress, + }) } const method = 'hello' 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 2a46d19..5df7a31 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 @@ -5,43 +5,26 @@ import { HelloWorldClient } from '../artifacts/hello_world/HelloWorldClient' export async function deploy() { console.log('=== Deploying HelloWorld ===') - const algod = algokit.getAlgoClient() - const indexer = algokit.getAlgoIndexerClient() - const deployer = await algokit.mnemonicAccountFromEnvironment({ name: 'DEPLOYER', fundWith: algokit.algos(3) }, algod) - await algokit.ensureFunded( - { - accountToFund: deployer, - minSpendingBalance: algokit.algos(2), - minFundingIncrement: algokit.algos(2), - }, - algod, - ) - const appClient = new HelloWorldClient( - { - resolveBy: 'creatorAndName', - findExistingUsing: indexer, - sender: deployer, - creatorAddress: deployer.addr, - }, - algod, - ) + const algorand = algokit.AlgorandClient.fromEnvironment() + const deployer = await algorand.account.fromEnvironment('DEPLOYER') + + const appClient = algorand.client.getTypedAppClientByCreatorAndName(HelloWorldClient, { + sender: deployer, + creatorAddress: deployer.addr, + }) const app = await appClient.deploy({ onSchemaBreak: 'append', onUpdate: 'append', }) - // If app was just created fund the app account if (['create', 'replace'].includes(app.operationPerformed)) { - algokit.transferAlgos( - { - amount: algokit.algos(1), - from: deployer, - to: app.appAddress, - }, - algod, - ) + await algorand.send.payment({ + amount: algokit.algos(1), + sender: deployer.addr, + receiver: app.appAddress, + }) } const method = 'hello' 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 68f8bc3..ac114cc 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 @@ -5,43 +5,26 @@ import { {{ contract_name.split('_')|map('capitalize')|join }}Client } from '../ export async function deploy() { console.log('=== Deploying {{ contract_name.split('_')|map('capitalize')|join }} ===') - const algod = algokit.getAlgoClient() - const indexer = algokit.getAlgoIndexerClient() - const deployer = await algokit.mnemonicAccountFromEnvironment({ name: 'DEPLOYER', fundWith: algokit.algos(3) }, algod) - await algokit.ensureFunded( - { - accountToFund: deployer, - minSpendingBalance: algokit.algos(2), - minFundingIncrement: algokit.algos(2), - }, - algod, - ) - const appClient = new {{ contract_name.split('_')|map('capitalize')|join }}Client( - { - resolveBy: 'creatorAndName', - findExistingUsing: indexer, - sender: deployer, - creatorAddress: deployer.addr, - }, - algod, - ) + const algorand = algokit.AlgorandClient.fromEnvironment() + const deployer = await algorand.account.fromEnvironment('DEPLOYER') + + const appClient = algorand.client.getTypedAppClientByCreatorAndName({{ contract_name.split('_')|map('capitalize')|join }}Client, { + sender: deployer, + creatorAddress: deployer.addr, + }) const app = await appClient.deploy({ onSchemaBreak: 'append', onUpdate: 'append', }) - // If app was just created fund the app account if (['create', 'replace'].includes(app.operationPerformed)) { - algokit.transferAlgos( - { - amount: algokit.algos(1), - from: deployer, - to: app.appAddress, - }, - algod, - ) + await algorand.send.payment({ + amount: algokit.algos(1), + sender: deployer.addr, + receiver: app.appAddress, + }) } const method = 'hello' 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 893e0d7..a5dc036 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 @@ -5,43 +5,26 @@ import { CoolContractClient } from '../artifacts/cool_contract/CoolContractClien export async function deploy() { console.log('=== Deploying CoolContract ===') - const algod = algokit.getAlgoClient() - const indexer = algokit.getAlgoIndexerClient() - const deployer = await algokit.mnemonicAccountFromEnvironment({ name: 'DEPLOYER', fundWith: algokit.algos(3) }, algod) - await algokit.ensureFunded( - { - accountToFund: deployer, - minSpendingBalance: algokit.algos(2), - minFundingIncrement: algokit.algos(2), - }, - algod, - ) - const appClient = new CoolContractClient( - { - resolveBy: 'creatorAndName', - findExistingUsing: indexer, - sender: deployer, - creatorAddress: deployer.addr, - }, - algod, - ) + const algorand = algokit.AlgorandClient.fromEnvironment() + const deployer = await algorand.account.fromEnvironment('DEPLOYER') + + const appClient = algorand.client.getTypedAppClientByCreatorAndName(CoolContractClient, { + sender: deployer, + creatorAddress: deployer.addr, + }) const app = await appClient.deploy({ onSchemaBreak: 'append', onUpdate: 'append', }) - // If app was just created fund the app account if (['create', 'replace'].includes(app.operationPerformed)) { - algokit.transferAlgos( - { - amount: algokit.algos(1), - from: deployer, - to: app.appAddress, - }, - algod, - ) + await algorand.send.payment({ + amount: algokit.algos(1), + sender: deployer.addr, + receiver: app.appAddress, + }) } const method = 'hello' 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 2a46d19..5df7a31 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 @@ -5,43 +5,26 @@ import { HelloWorldClient } from '../artifacts/hello_world/HelloWorldClient' export async function deploy() { console.log('=== Deploying HelloWorld ===') - const algod = algokit.getAlgoClient() - const indexer = algokit.getAlgoIndexerClient() - const deployer = await algokit.mnemonicAccountFromEnvironment({ name: 'DEPLOYER', fundWith: algokit.algos(3) }, algod) - await algokit.ensureFunded( - { - accountToFund: deployer, - minSpendingBalance: algokit.algos(2), - minFundingIncrement: algokit.algos(2), - }, - algod, - ) - const appClient = new HelloWorldClient( - { - resolveBy: 'creatorAndName', - findExistingUsing: indexer, - sender: deployer, - creatorAddress: deployer.addr, - }, - algod, - ) + const algorand = algokit.AlgorandClient.fromEnvironment() + const deployer = await algorand.account.fromEnvironment('DEPLOYER') + + const appClient = algorand.client.getTypedAppClientByCreatorAndName(HelloWorldClient, { + sender: deployer, + creatorAddress: deployer.addr, + }) const app = await appClient.deploy({ onSchemaBreak: 'append', onUpdate: 'append', }) - // If app was just created fund the app account if (['create', 'replace'].includes(app.operationPerformed)) { - algokit.transferAlgos( - { - amount: algokit.algos(1), - from: deployer, - to: app.appAddress, - }, - algod, - ) + await algorand.send.payment({ + amount: algokit.algos(1), + sender: deployer.addr, + receiver: app.appAddress, + }) } const method = 'hello' 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 68f8bc3..ac114cc 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 %} @@ -5,43 +5,26 @@ import { {{ contract_name.split('_')|map('capitalize')|join }}Client } from '../ export async function deploy() { console.log('=== Deploying {{ contract_name.split('_')|map('capitalize')|join }} ===') - const algod = algokit.getAlgoClient() - const indexer = algokit.getAlgoIndexerClient() - const deployer = await algokit.mnemonicAccountFromEnvironment({ name: 'DEPLOYER', fundWith: algokit.algos(3) }, algod) - await algokit.ensureFunded( - { - accountToFund: deployer, - minSpendingBalance: algokit.algos(2), - minFundingIncrement: algokit.algos(2), - }, - algod, - ) - const appClient = new {{ contract_name.split('_')|map('capitalize')|join }}Client( - { - resolveBy: 'creatorAndName', - findExistingUsing: indexer, - sender: deployer, - creatorAddress: deployer.addr, - }, - algod, - ) + const algorand = algokit.AlgorandClient.fromEnvironment() + const deployer = await algorand.account.fromEnvironment('DEPLOYER') + + const appClient = algorand.client.getTypedAppClientByCreatorAndName({{ contract_name.split('_')|map('capitalize')|join }}Client, { + sender: deployer, + creatorAddress: deployer.addr, + }) const app = await appClient.deploy({ onSchemaBreak: 'append', onUpdate: 'append', }) - // If app was just created fund the app account if (['create', 'replace'].includes(app.operationPerformed)) { - algokit.transferAlgos( - { - amount: algokit.algos(1), - from: deployer, - to: app.appAddress, - }, - algod, - ) + await algorand.send.payment({ + amount: algokit.algos(1), + sender: deployer.addr, + receiver: app.appAddress, + }) } const method = 'hello' 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 2a48d76..ba3fc68 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 @@ -5,43 +5,26 @@ import { {{ contract_name.split('_')|map('capitalize')|join }}Client } from '../ export async function deploy() { console.log('=== Deploying {{ contract_name.split('_')|map('capitalize')|join }} ===') - const algod = algokit.getAlgoClient() - const indexer = algokit.getAlgoIndexerClient() - const deployer = await algokit.mnemonicAccountFromEnvironment({ name: 'DEPLOYER', fundWith: algokit.algos(3) }, algod) - await algokit.ensureFunded( - { - accountToFund: deployer, - minSpendingBalance: algokit.algos(2), - minFundingIncrement: algokit.algos(2), - }, - algod, - ) - const appClient = new {% include pathjoin('includes', 'contract_name_pascal.jinja') %}Client( - { - resolveBy: 'creatorAndName', - findExistingUsing: indexer, - sender: deployer, - creatorAddress: deployer.addr, - }, - algod, - ) + const algorand = algokit.AlgorandClient.fromEnvironment() + const deployer = await algorand.account.fromEnvironment('DEPLOYER') + + const appClient = algorand.client.getTypedAppClientByCreatorAndName({% include pathjoin('includes', 'contract_name_pascal.jinja') %}Client, { + sender: deployer, + creatorAddress: deployer.addr, + }) const app = await appClient.deploy({ onSchemaBreak: 'append', onUpdate: 'append', }) - // If app was just created fund the app account if (['create', 'replace'].includes(app.operationPerformed)) { - algokit.transferAlgos( - { - amount: algokit.algos(1), - from: deployer, - to: app.appAddress, - }, - algod, - ) + await algorand.send.payment({ + amount: algokit.algos(1), + sender: deployer.addr, + receiver: app.appAddress, + }) } const method = 'hello' diff --git a/tests/test_generators.py b/tests/test_generators.py index 36d15b2..d3314e3 100644 --- a/tests/test_generators.py +++ b/tests/test_generators.py @@ -22,6 +22,7 @@ BUILD_ARGS = ["algokit", "project", "run", "build"] TEST_ARGS = ["algokit", "project", "run", "test"] LINT_ARGS = ["algokit", "project", "run", "lint"] +DEPLOY_ARGS = ["algokit", "project", "deploy", "localnet"] def _load_copier_yaml(path: Path) -> dict[str, str | bool | dict]: @@ -127,7 +128,7 @@ def check_codebase(working_dir: Path, test_name: str) -> subprocess.CompletedPro processed_questions = _load_copier_yaml(copier_answers) if processed_questions["preset_name"] == "production": - check_args += [LINT_ARGS, TEST_ARGS] + check_args += [LINT_ARGS, TEST_ARGS, DEPLOY_ARGS] for check_arg in check_args: result = subprocess.run(