Skip to content

Commit 20eba3c

Browse files
feat: puya debugger support; algokit v7 updates (#71)
* feat: migrating to latest beta prereleases of utils, utils-debug and generator * chore: disabling mypy in tests and artifacts folders for python generator cases * chore: pinning mypy to 1.11.0; to be resolved in separate pr * chore: temporary setting puya installation from puya debugging branch * chore: temporary setting per branch install of algokit-utils-py with puya debugging * docs: tweak to ensure debugging docs are included on starter presets too * chore: refresh puya installation * chore: update to the latest packages * chore: add support for utils v7 --------- Co-authored-by: Neil Campbell <neil.campbell@makerx.com.au>
1 parent 60fddfb commit 20eba3c

File tree

38 files changed

+273
-236
lines changed

38 files changed

+273
-236
lines changed

.github/workflows/check-python.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ jobs:
4444
# set git user and email as test invoke git
4545
git config --global user.email "actions@github.com" && git config --global user.name "github-actions"
4646
47+
- name: Setup Node.js 20.x
48+
uses: actions/setup-node@v4
49+
with:
50+
node-version: "20.x"
51+
4752
- name: Run tests
4853
shell: bash
4954
run: |

examples/generators/production_python_smart_contract_python/README.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,7 @@ By default the template creates a single `HelloWorld` contract under hello_world
7777

7878
By default the template instance does not contain any env files. Using [`algokit project deploy`](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/project/deploy.md) against `localnet` | `testnet` | `mainnet` will use default values for `algod` and `indexer` unless overwritten via `.env` or `.env.{target_network}`.
7979

80-
To generate a new `.env` or `.env.{target_network}` file, run `algokit generate env-file`### Continuous Integration / Continuous Deployment (CI/CD)
81-
82-
This project uses [GitHub Actions](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions) to define CI/CD workflows, which are located in the [.github/workflows](`.github/workflows`) folder.
83-
84-
> Please note, if you instantiated the project with --workspace flag in `algokit init` it will automatically attempt to move the contents of the `.github` folder to the root of the workspace.
85-
86-
### AlgoKit Workspaces
87-
88-
To define custom `algokit project run` commands refer to [documentation](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/project/run.md). This allows orchestration of commands spanning across multiple projects within an algokit workspace based project (monorepo).
80+
To generate a new `.env` or `.env.{target_network}` file, run `algokit generate env-file`
8981

9082
### Debugging Smart Contracts
9183

@@ -94,7 +86,15 @@ Refer to the commented header in the `__main__.py` file in the `smart_contracts`
9486

9587
If you have opted in to include VSCode launch configurations in your project, you can also use the `Debug TEAL via AlgoKit AVM Debugger` launch configuration to interactively select an available trace file and launch the debug session for your smart contract.
9688

97-
For information on using and setting up the `AlgoKit AVM Debugger` VSCode extension refer [here](https://github.com/algorandfoundation/algokit-avm-vscode-debugger). To install the extension from the VSCode Marketplace, use the following link: [AlgoKit AVM Debugger extension](https://marketplace.visualstudio.com/items?itemName=algorandfoundation.algokit-avm-vscode-debugger).
89+
For information on using and setting up the `AlgoKit AVM Debugger` VSCode extension refer [here](https://github.com/algorandfoundation/algokit-avm-vscode-debugger). To install the extension from the VSCode Marketplace, use the following link: [AlgoKit AVM Debugger extension](https://marketplace.visualstudio.com/items?itemName=algorandfoundation.algokit-avm-vscode-debugger).### Continuous Integration / Continuous Deployment (CI/CD)
90+
91+
This project uses [GitHub Actions](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions) to define CI/CD workflows, which are located in the [.github/workflows](`.github/workflows`) folder.
92+
93+
> Please note, if you instantiated the project with --workspace flag in `algokit init` it will automatically attempt to move the contents of the `.github` folder to the root of the workspace.
94+
95+
### AlgoKit Workspaces
96+
97+
To define custom `algokit project run` commands refer to [documentation](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/project/run.md). This allows orchestration of commands spanning across multiple projects within an algokit workspace based project (monorepo).
9898

9999
#### Setting up GitHub for CI/CD workflow and TestNet deployment
100100

examples/generators/production_python_smart_contract_python/pyproject.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ readme = "README.md"
77

88
[tool.poetry.dependencies]
99
python = "^3.12"
10-
algokit-utils = "^2.3.0"
10+
algokit-utils = { git = "https://github.com/algorandfoundation/algokit-utils-py.git", branch = "feat/puya-debugging" }
1111
python-dotenv = "^1.0.0"
1212
algorand-python = "^2.0.0"
1313
algorand-python-testing = "^0.4.0"
@@ -21,7 +21,7 @@ pytest = "*"
2121
pytest-cov = "*"
2222
pip-audit = "*"
2323
pre-commit = "*"
24-
puyapy = "*"
24+
puyapy = { git = "https://github.com/algorandfoundation/puya.git", branch = "main" }
2525

2626
[build-system]
2727
requires = ["poetry-core"]
@@ -57,7 +57,7 @@ warn_redundant_casts = true
5757
warn_unused_ignores = true
5858
warn_return_any = true
5959
strict_equality = true
60-
strict_concatenate = true
60+
extra_checks = true
6161
disallow_any_unimported = true
6262
disallow_any_expr = true
6363
disallow_any_decorated = true

examples/generators/production_python_smart_contract_python/smart_contracts/_helpers/build.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def build(output_dir: Path, contract_path: Path) -> Path:
3131
contract_path.absolute(),
3232
f"--out-dir={output_dir}",
3333
"--output-arc32",
34-
"--debug-level=0",
34+
"--output-source-map",
3535
],
3636
stdout=subprocess.PIPE,
3737
stderr=subprocess.STDOUT,
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
import * as algokit from '@algorandfoundation/algokit-utils'
2-
import { {{ contract_name.split('_')|map('capitalize')|join }}Client } from '../artifacts/{{ contract_name }}/{{ contract_name.split('_')|map('capitalize')|join }}Client'
2+
import { {{ contract_name.split('_')|map('capitalize')|join }}Factory } from '../artifacts/{{ contract_name }}/{{ contract_name.split('_')|map('capitalize')|join }}Client'
33

44
// Below is a showcase of various deployment options you can use in TypeScript Client
55
export async function deploy() {
66
console.log('=== Deploying {{ contract_name.split('_')|map('capitalize')|join }} ===')
77

88
const algorand = algokit.AlgorandClient.fromEnvironment()
99
const deployer = await algorand.account.fromEnvironment('DEPLOYER')
10-
11-
const appClient = algorand.client.getTypedAppClientByCreatorAndName({{ contract_name.split('_')|map('capitalize')|join }}Client, {
12-
sender: deployer,
13-
creatorAddress: deployer.addr,
14-
})
1510

16-
const app = await appClient.deploy({
17-
onSchemaBreak: 'append',
18-
onUpdate: 'append',
11+
const factory = algorand.client.getTypedAppFactory({{ contract_name.split('_')|map('capitalize')|join }}Factory, {
12+
defaultSender: deployer.addr,
1913
})
2014

15+
const { appClient, result } = await factory.deploy({ onUpdate: 'append', onSchemaBreak: 'append' })
16+
2117
// If app was just created fund the app account
22-
if (['create', 'replace'].includes(app.operationPerformed)) {
18+
if (['create', 'replace'].includes(result.operationPerformed)) {
2319
await algorand.send.payment({
24-
amount: algokit.algos(1),
20+
amount: (1).algo(),
2521
sender: deployer.addr,
2622
receiver: app.appAddress,
2723
})
2824
}
2925

30-
const method = 'hello'
31-
const response = await appClient.hello({ name: 'world' })
32-
console.log(`Called ${method} on ${app.name} (${app.appId}) with name = world, received: ${response.return}`)
26+
const method = 'hello'
27+
const response = await appClient.send.hello({
28+
args: { name: 'world' },
29+
})
30+
console.log(
31+
`Called ${method} on ${appClient.appClient.appName} (${appClient.appClient.appId}) with name = world, received: ${response.return}`,
32+
)
3333
}

examples/generators/production_python_smart_contract_typescript/README.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,7 @@ By default the template creates a single `HelloWorld` contract under hello_world
7878

7979
By default the template instance does not contain any env files. Using [`algokit project deploy`](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/project/deploy.md) against `localnet` | `testnet` | `mainnet` will use default values for `algod` and `indexer` unless overwritten via `.env` or `.env.{target_network}`.
8080

81-
To generate a new `.env` or `.env.{target_network}` file, run `algokit generate env-file`### Continuous Integration / Continuous Deployment (CI/CD)
82-
83-
This project uses [GitHub Actions](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions) to define CI/CD workflows, which are located in the [.github/workflows](`.github/workflows`) folder.
84-
85-
> Please note, if you instantiated the project with --workspace flag in `algokit init` it will automatically attempt to move the contents of the `.github` folder to the root of the workspace.
86-
87-
### AlgoKit Workspaces
88-
89-
To define custom `algokit project run` commands refer to [documentation](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/project/run.md). This allows orchestration of commands spanning across multiple projects within an algokit workspace based project (monorepo).
81+
To generate a new `.env` or `.env.{target_network}` file, run `algokit generate env-file`
9082

9183
### Debugging Smart Contracts
9284

@@ -95,7 +87,15 @@ Refer to the commented header in the `index.ts` file in the `smart_contracts` fo
9587

9688
If you have opted in to include VSCode launch configurations in your project, you can also use the `Debug TEAL via AlgoKit AVM Debugger` launch configuration to interactively select an available trace file and launch the debug session for your smart contract.
9789

98-
For information on using and setting up the `AlgoKit AVM Debugger` VSCode extension refer [here](https://github.com/algorandfoundation/algokit-avm-vscode-debugger). To install the extension from the VSCode Marketplace, use the following link: [AlgoKit AVM Debugger extension](https://marketplace.visualstudio.com/items?itemName=algorandfoundation.algokit-avm-vscode-debugger).
90+
For information on using and setting up the `AlgoKit AVM Debugger` VSCode extension refer [here](https://github.com/algorandfoundation/algokit-avm-vscode-debugger). To install the extension from the VSCode Marketplace, use the following link: [AlgoKit AVM Debugger extension](https://marketplace.visualstudio.com/items?itemName=algorandfoundation.algokit-avm-vscode-debugger).### Continuous Integration / Continuous Deployment (CI/CD)
91+
92+
This project uses [GitHub Actions](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions) to define CI/CD workflows, which are located in the [.github/workflows](`.github/workflows`) folder.
93+
94+
> Please note, if you instantiated the project with --workspace flag in `algokit init` it will automatically attempt to move the contents of the `.github` folder to the root of the workspace.
95+
96+
### AlgoKit Workspaces
97+
98+
To define custom `algokit project run` commands refer to [documentation](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/project/run.md). This allows orchestration of commands spanning across multiple projects within an algokit workspace based project (monorepo).
9999

100100
#### Setting up GitHub for CI/CD workflow and TestNet deployment
101101

examples/generators/production_python_smart_contract_typescript/package.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@
1010
"format": "prettier --write ."
1111
},
1212
"engines": {
13-
"node": ">=18.0",
13+
"node": ">=20.0",
1414
"npm": ">=9.0"
1515
},
1616
"dependencies": {
17-
"@algorandfoundation/algokit-utils": "^6.0.2",
18-
"algosdk": "^2.7.0"
17+
"@algorandfoundation/algokit-utils": "^7.0.0",
18+
"@algorandfoundation/algokit-utils-debug": "^1.0.2",
19+
"algosdk": ">=2.9.0 <3.0"
1920
},
2021
"devDependencies": {
21-
"@algorandfoundation/algokit-client-generator": "^3.0.3",
22+
"@algorandfoundation/algokit-client-generator": "^4.0.0",
2223
"@types/jest": "^29.5.11",
2324
"dotenv": "^16.0.3",
2425
"prettier": "^2.8.4",

examples/generators/production_python_smart_contract_typescript/pyproject.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ readme = "README.md"
77

88
[tool.poetry.dependencies]
99
python = "^3.12"
10-
algokit-utils = "^2.3.0"
10+
algokit-utils = { git = "https://github.com/algorandfoundation/algokit-utils-py.git", branch = "feat/puya-debugging" }
1111
python-dotenv = "^1.0.0"
1212
algorand-python = "^2.0.0"
1313
algorand-python-testing = "^0.4.0"
@@ -18,7 +18,7 @@ ruff = "^0.1.6"
1818
mypy = "1.11.0"
1919
pip-audit = "*"
2020
pre-commit = "*"
21-
puyapy = "*"
21+
puyapy = { git = "https://github.com/algorandfoundation/puya.git", branch = "main" }
2222

2323
[build-system]
2424
requires = ["poetry-core"]
@@ -51,7 +51,7 @@ warn_redundant_casts = true
5151
warn_unused_ignores = true
5252
warn_return_any = true
5353
strict_equality = true
54-
strict_concatenate = true
54+
extra_checks = true
5555
disallow_any_unimported = true
5656
disallow_any_expr = true
5757
disallow_any_decorated = true

examples/generators/production_python_smart_contract_typescript/smart_contracts/_helpers/build.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def build(output_dir: Path, contract_path: Path) -> Path:
3131
contract_path.absolute(),
3232
f"--out-dir={output_dir}",
3333
"--output-arc32",
34-
"--debug-level=0",
34+
"--output-source-map",
3535
],
3636
stdout=subprocess.PIPE,
3737
stderr=subprocess.STDOUT,
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
import * as algokit from '@algorandfoundation/algokit-utils'
2-
import { CoolContractClient } from '../artifacts/cool_contract/CoolContractClient'
2+
import { CoolContractFactory } from '../artifacts/cool_contract/CoolContractClient'
33

44
// Below is a showcase of various deployment options you can use in TypeScript Client
55
export async function deploy() {
66
console.log('=== Deploying CoolContract ===')
77

88
const algorand = algokit.AlgorandClient.fromEnvironment()
99
const deployer = await algorand.account.fromEnvironment('DEPLOYER')
10-
11-
const appClient = algorand.client.getTypedAppClientByCreatorAndName(CoolContractClient, {
12-
sender: deployer,
13-
creatorAddress: deployer.addr,
14-
})
1510

16-
const app = await appClient.deploy({
17-
onSchemaBreak: 'append',
18-
onUpdate: 'append',
11+
const factory = algorand.client.getTypedAppFactory(CoolContractFactory, {
12+
defaultSender: deployer.addr,
1913
})
2014

15+
const { appClient, result } = await factory.deploy({ onUpdate: 'append', onSchemaBreak: 'append' })
16+
2117
// If app was just created fund the app account
22-
if (['create', 'replace'].includes(app.operationPerformed)) {
18+
if (['create', 'replace'].includes(result.operationPerformed)) {
2319
await algorand.send.payment({
24-
amount: algokit.algos(1),
20+
amount: (1).algo(),
2521
sender: deployer.addr,
2622
receiver: app.appAddress,
2723
})
2824
}
2925

30-
const method = 'hello'
31-
const response = await appClient.hello({ name: 'world' })
32-
console.log(`Called ${method} on ${app.name} (${app.appId}) with name = world, received: ${response.return}`)
26+
const method = 'hello'
27+
const response = await appClient.send.hello({
28+
args: { name: 'world' },
29+
})
30+
console.log(
31+
`Called ${method} on ${appClient.appClient.appName} (${appClient.appClient.appId}) with name = world, received: ${response.return}`,
32+
)
3333
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as algokit from '@algorandfoundation/algokit-utils'
2-
import { HelloWorldClient } from '../artifacts/hello_world/HelloWorldClient'
2+
import { HelloWorldFactory } from '../artifacts/hello_world/HelloWorldClient'
33

44
// Below is a showcase of various deployment options you can use in TypeScript Client
55
export async function deploy() {
@@ -8,26 +8,26 @@ export async function deploy() {
88
const algorand = algokit.AlgorandClient.fromEnvironment()
99
const deployer = await algorand.account.fromEnvironment('DEPLOYER')
1010

11-
const appClient = algorand.client.getTypedAppClientByCreatorAndName(HelloWorldClient, {
12-
sender: deployer,
13-
creatorAddress: deployer.addr,
11+
const factory = algorand.client.getTypedAppFactory(HelloWorldFactory, {
12+
defaultSender: deployer.addr,
1413
})
1514

16-
const app = await appClient.deploy({
17-
onSchemaBreak: 'append',
18-
onUpdate: 'append',
19-
})
15+
const { appClient, result } = await factory.deploy({ onUpdate: 'append', onSchemaBreak: 'append' })
2016

2117
// If app was just created fund the app account
22-
if (['create', 'replace'].includes(app.operationPerformed)) {
18+
if (['create', 'replace'].includes(result.operationPerformed)) {
2319
await algorand.send.payment({
24-
amount: algokit.algos(1),
20+
amount: (1).algo(),
2521
sender: deployer.addr,
26-
receiver: app.appAddress,
22+
receiver: appClient.appAddress,
2723
})
2824
}
2925

30-
const method = 'hello'
31-
const response = await appClient.hello({ name: 'world' })
32-
console.log(`Called ${method} on ${app.name} (${app.appId}) with name = world, received: ${response.return}`)
26+
const method = 'hello'
27+
const response = await appClient.send.hello({
28+
args: { name: 'world' },
29+
})
30+
console.log(
31+
`Called ${method} on ${appClient.appClient.appName} (${appClient.appClient.appId}) with name = world, received: ${response.return}`,
32+
)
3333
}

examples/generators/production_python_smart_contract_typescript/smart_contracts/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as fs from 'fs'
22
import * as path from 'path'
33
import { consoleLogger } from '@algorandfoundation/algokit-utils/types/logging'
44
import * as algokit from '@algorandfoundation/algokit-utils'
5+
// import { registerDebugEventHandlers } from '@algorandfoundation/algokit-utils-debug' // Uncomment to enable persisting artifacts required by AlgoKit AVM Debugger
56

67
// Uncomment the debug and traceAll options to enable auto generation of AVM Debugger compliant sourceMap and simulation trace file.
78
// Learn more about using AlgoKit AVM Debugger to debug your TEAL source codes and inspect various kinds of Algorand transactions in atomic groups -> https://github.com/algorandfoundation/algokit-avm-vscode-Debugger
@@ -11,6 +12,7 @@ algokit.Config.configure({
1112
// debug: true,
1213
// traceAll: true,
1314
})
15+
// registerDebugEventHandlers() // Uncomment to enable persisting artifacts required by AlgoKit AVM Debugger
1416

1517
// base directory
1618
const baseDir = path.resolve(__dirname)

0 commit comments

Comments
 (0)