Skip to content

Commit 97b28fc

Browse files
committed
chore: udpated examples
1 parent 87b3b09 commit 97b28fc

File tree

10 files changed

+83
-79
lines changed

10 files changed

+83
-79
lines changed

examples/production/.github/workflows/production-cd.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
name: Validate production
1212
uses: ./.github/workflows/production-ci.yaml
1313
deploy-testnet:
14-
runs-on: 'ubuntu-latest'
14+
runs-on: "ubuntu-latest"
1515
needs: validate
1616
environment: contract-testnet
1717
steps:
@@ -28,13 +28,13 @@ jobs:
2828
- name: Set up Python 3.12
2929
uses: actions/setup-python@v5
3030
with:
31-
python-version: '3.12'
31+
python-version: "3.12"
3232

3333
- name: Install algokit
3434
run: pipx install algokit
3535

3636
- name: Bootstrap dependencies
37-
run: algokit project bootstrap all
37+
run: algokit project bootstrap all
3838

3939
- name: Configure git
4040
shell: bash
@@ -43,7 +43,7 @@ jobs:
4343
git config --global user.email "actions@github.com" && git config --global user.name "github-actions"
4444
4545
- name: Deploy to testnet
46-
run: algokit project deploy testnet
46+
run: algokit project deploy testnet
4747
env:
4848
# This is the account that becomes the creator of the contract
4949
DEPLOYER_MNEMONIC: ${{ secrets.DEPLOYER_MNEMONIC }}

examples/production/.github/workflows/production-ci.yaml

+17-11
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66

77
jobs:
88
validate:
9-
runs-on: 'ubuntu-latest'
9+
runs-on: "ubuntu-latest"
1010
steps:
1111
- name: Checkout source code
1212
uses: actions/checkout@v4
@@ -16,12 +16,12 @@ jobs:
1616
with:
1717
node-version: '22.x'
1818
cache: 'npm'
19-
cache-dependency-path: '**/package-lock.json'
19+
cache-dependency-path: "**/package-lock.json"
2020

2121
- name: Set up Python 3.12
2222
uses: actions/setup-python@v5
2323
with:
24-
python-version: '3.12'
24+
python-version: "3.12"
2525

2626
- name: Install algokit
2727
run: pipx install algokit
@@ -30,38 +30,44 @@ jobs:
3030
run: algokit localnet start
3131

3232
- name: Bootstrap dependencies
33-
run: algokit project bootstrap all
33+
run: algokit project bootstrap all
3434

3535
- name: Configure git
3636
shell: bash
3737
run: |
3838
# set git user and email as test invoke git
3939
git config --global user.email "actions@github.com" && git config --global user.name "github-actions"
4040
41+
4142
- name: Audit dependencies
42-
run: algokit project run audit
43+
run: algokit project run audit
44+
45+
4346

4447
- name: Lint and format
45-
run: algokit project run lint
48+
run: algokit project run lint
49+
50+
4651

4752
- name: Run tests
4853
shell: bash
4954
run: |
5055
set -o pipefail
51-
algokit project run test
56+
algokit project run test
57+
5258
5359
- name: Build smart contracts
54-
run: algokit project run build
60+
run: algokit project run build
5561

5662
- name: Scan TEAL files for issues
57-
run: algokit project run audit-teal
63+
run: algokit project run audit-teal
5864

5965
# # Uncomment to enable TEAL static analysis with snapshoting using Tealer package
6066
# # Would first require running locally using audit-teal command and committing the snapshots into source control
6167
# # Please note, tealer has a known bug that may result in large snapshot file sizes, track resolution here:
6268
# # https://github.com/crytic/tealer/issues/101
6369
# - name: Check output stability of the smart contracts
64-
# run: algokit project run ci-teal-diff
70+
# run: algokit project run ci-teal-diff
6571

6672
- name: Run deployer against LocalNet
67-
run: algokit project deploy localnet
73+
run: algokit project deploy localnet

examples/production/.vscode/launch.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
"runtimeArgs": ["run", "build"],
4646
"cwd": "${workspaceFolder}",
4747
"console": "integratedTerminal",
48-
"skipFiles": ["<node_internals>/**", "node_modules/**"]
49-
},
48+
"skipFiles": ["<node_internals>/**", "node_modules/**"],
49+
},
5050
{
5151
"type": "avm",
5252
"request": "launch",

examples/production/.vscode/settings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
"extensions": [".ts"]
1616
},
1717
"eslint.workingDirectories": ["./smart_contracts"]
18-
}
18+
}

examples/production/README.md

+32-36
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,15 @@ This project has been generated using AlgoKit. See below for default getting sta
1616
### Initial Setup
1717

1818
#### 1. Clone the Repository
19-
2019
Start by cloning this repository to your local machine.
2120

2221
#### 2. Install Pre-requisites
23-
2422
Ensure the following pre-requisites are installed and properly configured:
2523

2624
- **Docker**: Required for running a local Algorand network.
2725
- **AlgoKit CLI**: Essential for project setup and operations. Verify installation with `algokit --version`, expecting `2.6.0` or later.
2826

2927
#### 3. Bootstrap Your Local Environment
30-
3128
Run the following commands within the project folder:
3229

3330
- **Setup Project**: Execute `algokit project bootstrap all` to install dependencies and setup npm dependencies.
@@ -37,16 +34,14 @@ Run the following commands within the project folder:
3734
### Development Workflow
3835

3936
#### Terminal
40-
4137
Directly manage and interact with your project using AlgoKit commands:
4238

4339
1. **Build Contracts**: `algokit project run build` compiles all smart contracts. You can also specify a specific contract by passing the name of the contract folder as an extra argument.
44-
For example: `algokit project run build -- hello_world` will only build the `hello_world` contract.
40+
For example: `algokit project run build -- hello_world` will only build the `hello_world` contract.
4541
2. **Deploy**: Use `algokit project deploy localnet` to deploy contracts to the local network. You can also specify a specific contract by passing the name of the contract folder as an extra argument.
46-
For example: `algokit project deploy localnet -- hello_world` will only deploy the `hello_world` contract.
47-
48-
#### VS Code
42+
For example: `algokit project deploy localnet -- hello_world` will only deploy the `hello_world` contract.
4943

44+
#### VS Code
5045
For a seamless experience with breakpoint debugging and other features:
5146

5247
1. **Open Project**: In VS Code, open the repository root.
@@ -55,22 +50,20 @@ For a seamless experience with breakpoint debugging and other features:
5550
- Use `F5` to start debugging.
5651

5752
#### JetBrains IDEs
58-
5953
While primarily optimized for VS Code, JetBrains IDEs are supported:
6054

6155
1. **Open Project**: In your JetBrains IDE, open the repository root.
6256
2. **Automatic Setup**: The IDE should configure the Node.js environment.
6357
3. **Debugging**: Use `Shift+F10` or `Ctrl+R` to start debugging. Note: Windows users may encounter issues with pre-launch tasks due to a known bug. See [JetBrains forums](https://youtrack.jetbrains.com/issue/IDEA-277486/Shell-script-configuration-cannot-run-as-before-launch-task) for workarounds.
6458

6559
## AlgoKit Workspaces and Project Management
66-
6760
This project supports both standalone and monorepo setups through AlgoKit workspaces. Leverage [`algokit project run`](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/project/run.md) commands for efficient monorepo project orchestration and management across multiple projects within a workspace.
6861

6962
## AlgoKit Generators
7063

7164
This template provides a set of [algokit generators](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/generate.md) that allow you to further modify the project instantiated from the template to fit your needs, as well as giving you a base to build your own extensions to invoke via the `algokit generate` command.
7265

73-
### Generate Smart Contract
66+
### Generate Smart Contract
7467

7568
By default the template creates a single `HelloWorld` contract under hello_world folder in the `smart_contracts` directory. To add a new contract:
7669

@@ -82,7 +75,7 @@ By default the template creates a single `HelloWorld` contract under hello_world
8275
8376
### Generate '.env' files
8477

85-
By default the template instance does not contain any env files to deploy to different networks. 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}`.
78+
By default the template instance does not contain any env files to deploy to different networks. 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}`.
8679

8780
To generate a new `.env` or `.env.{target_network}` file, run `algokit generate env-file`
8881

@@ -92,6 +85,7 @@ This project is optimized to work with AlgoKit AVM Debugger extension. To activa
9285

9386
Refer to the commented header in the `index.ts` file in the `smart_contracts` folder.Since 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.
9487

88+
9589
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)
9690

9791
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.
@@ -104,43 +98,41 @@ To define custom `algokit project run` commands refer to [documentation](https:/
10498

10599
#### Setting up GitHub for CI/CD workflow and TestNet deployment
106100

107-
1. Every time you have a change to your smart contract, and when you first initialize the project you need to [build the contract](#initial-setup) and then commit the `smart_contracts/artifacts` folder so the [output stability](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/articles/output_stability.md) tests pass
108-
2. Decide what values you want to use for the `allowUpdate` and `allowDelete` parameters specified in [`deploy-config.ts`](./smart_contracts/hello_world/deploy-config.ts).
109-
When deploying to LocalNet these values are both set to `true` for convenience. But for non-LocalNet networks
110-
they are more conservative and use `false`
111-
These default values will allow the smart contract to be deployed initially, but will not allow the app to be updated or deleted if is changed and the build will instead fail.
112-
To help you decide it may be helpful to read the [AlgoKit Utils app deployment documentation](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/docs/capabilities/app-deploy.md) or the [AlgoKit smart contract deployment architecture](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/architecture-decisions/2023-01-12_smart-contract-deployment.md#upgradeable-and-deletable-contracts).
113-
3. Create a [Github Environment](https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#creating-an-environment) named `Test`.
114-
Note: If you have a private repository and don't have GitHub Enterprise then Environments won't work and you'll need to convert the GitHub Action to use a different approach. Ignore this step if you picked `Starter` preset.
115-
4. Create or obtain a mnemonic for an Algorand account for use on TestNet to deploy apps, referred to as the `DEPLOYER` account.
116-
5. Store the mnemonic as a [secret](https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#environment-secrets) `DEPLOYER_MNEMONIC`
117-
in the Test environment created in step 3.
118-
6. The account used to deploy the smart contract will require enough funds to create the app, and also fund it. There are two approaches available here:
119-
- Either, ensure the account is funded outside of CI/CD.
120-
In Testnet, funds can be obtained by using the [Algorand TestNet dispenser](https://bank.testnet.algorand.network/) and we recommend provisioning 50 ALGOs.
121-
- Or, fund the account as part of the CI/CD process by using a `DISPENSER_MNEMONIC` GitHub Environment secret to point to a separate `DISPENSER` account that you maintain ALGOs in (similarly, you need to provision ALGOs into this account using the [TestNet dispenser](https://bank.testnet.algorand.network/)).
101+
1. Every time you have a change to your smart contract, and when you first initialize the project you need to [build the contract](#initial-setup) and then commit the `smart_contracts/artifacts` folder so the [output stability](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/articles/output_stability.md) tests pass
102+
2. Decide what values you want to use for the `allowUpdate` and `allowDelete` parameters specified in [`deploy-config.ts`](./smart_contracts/hello_world/deploy-config.ts).
103+
When deploying to LocalNet these values are both set to `true` for convenience. But for non-LocalNet networks
104+
they are more conservative and use `false`
105+
These default values will allow the smart contract to be deployed initially, but will not allow the app to be updated or deleted if is changed and the build will instead fail.
106+
To help you decide it may be helpful to read the [AlgoKit Utils app deployment documentation](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/docs/capabilities/app-deploy.md) or the [AlgoKit smart contract deployment architecture](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/architecture-decisions/2023-01-12_smart-contract-deployment.md#upgradeable-and-deletable-contracts).
107+
3. Create a [Github Environment](https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#creating-an-environment) named `Test`.
108+
Note: If you have a private repository and don't have GitHub Enterprise then Environments won't work and you'll need to convert the GitHub Action to use a different approach. Ignore this step if you picked `Starter` preset.
109+
4. Create or obtain a mnemonic for an Algorand account for use on TestNet to deploy apps, referred to as the `DEPLOYER` account.
110+
5. Store the mnemonic as a [secret](https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#environment-secrets) `DEPLOYER_MNEMONIC`
111+
in the Test environment created in step 3.
112+
6. The account used to deploy the smart contract will require enough funds to create the app, and also fund it. There are two approaches available here:
113+
* Either, ensure the account is funded outside of CI/CD.
114+
In Testnet, funds can be obtained by using the [Algorand TestNet dispenser](https://bank.testnet.algorand.network/) and we recommend provisioning 50 ALGOs.
115+
* Or, fund the account as part of the CI/CD process by using a `DISPENSER_MNEMONIC` GitHub Environment secret to point to a separate `DISPENSER` account that you maintain ALGOs in (similarly, you need to provision ALGOs into this account using the [TestNet dispenser](https://bank.testnet.algorand.network/)).
122116

123117
#### Continuous Integration
124118

125119
For pull requests and pushes to `main` branch against this repository the following checks are automatically performed by GitHub Actions:
126-
127-
- NPM dependencies are audited using [better-npm-audit](https://github.com/jeemok/better-npm-audit#readme)
128-
- Code formatting is performed using [Prettier](https://prettier.io/)
129-
- Linting is checked using [ESLint](https://eslint.org/)
120+
- NPM dependencies are audited using [better-npm-audit](https://github.com/jeemok/better-npm-audit#readme)
121+
- Code formatting is performed using [Prettier](https://prettier.io/)
122+
- Linting is checked using [ESLint](https://eslint.org/)
130123
- The base framework for testing is [vitest](https://vitest.dev/), and the project includes two separate kinds of tests:
131124
- - `Algorand TypeScript` smart contract unit tests, that are run using [`algorand-typescript-testing`](https://github.com/algorandfoundation/algorand-typescript-testing), which are executed in a Node.js intepreter emulating major AVM behaviour
132125
- - End-to-end (e2e) `AppClient` tests that are run against `algokit localnet` and test the behaviour in a real network environment
133-
- Smart contract artifacts are built
134-
- Smart contract artifacts are checked for [output stability](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/articles/output_stability.md).
135-
- Smart contract is deployed to a AlgoKit LocalNet instance
126+
- Smart contract artifacts are built
127+
- Smart contract artifacts are checked for [output stability](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/articles/output_stability.md).
128+
- Smart contract is deployed to a AlgoKit LocalNet instance
136129

137130
> NOTE: By default smart contract artifacts are compiled with `--debug-level` set to 0, to change this, modify the compiler invocation under the `build` script in `package.json`
138131
139132
#### Continuous Deployment
140133

141134
For pushes to `main` branch, after the above checks pass, the following deployment actions are performed:
142-
143-
- The smart contract(s) are deployed to TestNet using [AlgoNode](https://algonode.io).
135+
- The smart contract(s) are deployed to TestNet using [AlgoNode](https://algonode.io).
144136

145137
> Please note deployment is also performed via `algokit deploy` command which can be invoked both via CI as seen on this project, or locally. For more information on how to use `algokit deploy` please see [AlgoKit documentation](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/deploy.md).
146138
@@ -159,6 +151,10 @@ This project makes use of Algorand TypeScript to build Algorand smart contracts.
159151
- [better-npm-audit](https://github.com/jeemok/better-npm-audit#readme): Tool for scanning JavaScript / TypeScript environments for packages with known vulnerabilities.
160152
- [pre-commit](https://pre-commit.com/): A framework for managing and maintaining multi-language pre-commit hooks, to enable pre-commit you need to run `pre-commit install` in the root of the repository. This will install the pre-commit hooks and run them against modified files when committing. If any of the hooks fail, the commit will be aborted. To run the hooks on all files, use `pre-commit run --all-files`.
161153

154+
162155
It has also been configured to have a productive dev experience out of the box in [VS Code](https://code.visualstudio.com/), see the [.vscode](./.vscode) folder.
163156

157+
158+
164159
It has also been configured to have a productive dev experience out of the box in [Jetbrains IDEs](https://www.jetbrains.com/ides/), see the [.idea](./.idea) folder.
160+

examples/production/eslint.config.mjs

+12-8
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@ import eslint from '@eslint/js'
22
import tseslint from 'typescript-eslint'
33
import globals from 'globals'
44

5-
export default tseslint.config(eslint.configs.recommended, tseslint.configs.recommended, {
6-
languageOptions: {
7-
globals: {
8-
...globals.node,
5+
export default tseslint.config(
6+
eslint.configs.recommended,
7+
tseslint.configs.recommended,
8+
{
9+
languageOptions: {
10+
globals: {
11+
...globals.node,
12+
},
13+
},
14+
rules: {
15+
'@typescript-eslint/explicit-member-accessibility': 'warn',
916
},
1017
},
11-
rules: {
12-
'@typescript-eslint/explicit-member-accessibility': 'warn',
13-
},
14-
})
18+
);

examples/production/smart_contracts/hello_world/deploy-config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export async function deploy() {
2323
})
2424
}
2525

26-
const method = 'hello'
26+
const method = 'hello'
2727
const response = await appClient.send.hello({
2828
args: { name: 'world' },
2929
})

examples/production/smart_contracts/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ async function getDeployers() {
3939
}
4040

4141
// execute all the deployers
42-
;(async () => {
42+
(async () => {
4343
const contractName = process.argv.length > 2 ? process.argv[2] : undefined
4444
const contractDeployers = await getDeployers()
45-
45+
4646
const filteredDeployers = contractName
47-
? contractDeployers.filter((deployer) => deployer.name === contractName)
47+
? contractDeployers.filter(deployer => deployer.name === contractName)
4848
: contractDeployers
4949

5050
if (contractName && filteredDeployers.length === 0) {

examples/production/vitest.config.mts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { defineConfig } from 'vitest/config'
44

55
export default defineConfig({
66
esbuild: {},
7-
test: {
7+
test: {
88
testTimeout: 10000,
99
coverage: {
1010
provider: 'v8',

0 commit comments

Comments
 (0)