This repository has been archived by the owner on Nov 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
92 changed files
with
21,569 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY | ||
_commit: 0.2.1-22-gd5c2296 | ||
_src_path: https://github.com/algorandfoundation/algokit-fullstack-template | ||
author_email: [email protected] | ||
author_name: Your-Name | ||
cloud_provider: none | ||
contract_name: dao | ||
ide_vscode: true | ||
preset_name: starter | ||
project_name: dao | ||
python_linter: none | ||
use_dispenser: false | ||
use_github_actions: true | ||
use_python_black: true | ||
use_python_mypy: false | ||
use_python_pip_audit: true | ||
use_python_pytest: true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[*] | ||
charset = utf-8 | ||
insert_final_newline = true | ||
end_of_line = lf | ||
indent_style = space | ||
indent_size = 2 | ||
tab_width = 2 | ||
max_line_length = 140 | ||
trim_trailing_whitespace = true | ||
single_quote = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text=auto eol=lf |
56 changes: 56 additions & 0 deletions
56
intermediate-en/session_3/dao/.github/workflows/frontend-cd.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: Frontend CD | ||
|
||
on: | ||
workflow_call: | ||
|
||
permissions: | ||
contents: read | ||
packages: read | ||
|
||
jobs: | ||
lint-and-build: | ||
name: CI dApp | ||
uses: ./.github/workflows/frontend-ci.yaml | ||
|
||
deploy: | ||
runs-on: ubuntu-latest | ||
name: Deploy to Netlify | ||
environment: Prod | ||
concurrency: "${{ github.workflow }}-prod" | ||
needs: | ||
- lint-and-build | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Download build artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: dist | ||
path: frontend/dist | ||
|
||
- name: Replace template vars | ||
uses: makerxstudio/shared-config/.github/actions/placeholder-transforms@main | ||
with: | ||
app-artifact-path: ./frontend/dist | ||
static-site-transforms: |- | ||
VITE_ALGOD_TOKEN:${{ secrets.VITE_ALGOD_TOKEN }} | ||
VITE_ALGOD_SERVER:${{ vars.VITE_ALGOD_SERVER }} | ||
VITE_ALGOD_PORT:${{ vars.VITE_ALGOD_PORT }} | ||
VITE_ALGOD_NETWORK:${{ vars.VITE_ALGOD_NETWORK }} | ||
VITE_INDEXER_SERVER:${{ vars.VITE_INDEXER_SERVER }} | ||
VITE_INDEXER_PORT:${{ vars.VITE_INDEXER_PORT }} | ||
VITE_INDEXER_TOKEN:${{ secrets.VITE_INDEXER_TOKEN }} | ||
VITE_ENVIRONMENT:${{ vars.VITE_ENVIRONMENT }} | ||
- name: Install netlify cli | ||
working-directory: ./frontend | ||
run: npm i netlify-cli | ||
|
||
- name: Publish to netlify | ||
working-directory: ./frontend | ||
run: netlify deploy --prod --dir "dist" | ||
env: | ||
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} | ||
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | ||
|
63 changes: 63 additions & 0 deletions
63
intermediate-en/session_3/dao/.github/workflows/frontend-ci.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Frontend CI | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
run-build: | ||
required: false | ||
type: boolean | ||
default: false | ||
|
||
jobs: | ||
checks: | ||
runs-on: "ubuntu-latest" | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
|
||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
|
||
- name: Install algokit | ||
run: pipx install algokit | ||
|
||
- name: Install dependencies | ||
working-directory: ./frontend | ||
run: npm ci | ||
|
||
- name: Run linters | ||
working-directory: ./frontend | ||
run: npm run lint | ||
|
||
- name: Run unit tests | ||
working-directory: ./frontend | ||
run: npm run test | ||
|
||
- name: Create placeholder .env file | ||
if: ${{ inputs.run-build }} | ||
uses: makerxstudio/shared-config/.github/actions/env-to-placeholders@main | ||
with: | ||
env-output-path: ./frontend/.env | ||
env-template-path: ./frontend/.env.template | ||
env-variable-prefix: VITE_ | ||
|
||
- name: Build | ||
if: ${{ inputs.run-build }} | ||
working-directory: ./frontend | ||
run: npm run build | ||
|
||
- name: Archive | ||
if: ${{ inputs.run-build }} | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: dist | ||
path: frontend/dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: Pull Request validation | ||
|
||
on: [pull_request] | ||
|
||
jobs: | ||
smart-contracts-ci: | ||
name: Smart Contracts CI | ||
uses: ./.github/workflows/smart-contracts-ci.yaml | ||
|
||
frontend-ci: | ||
name: Frontend CI | ||
uses: ./.github/workflows/frontend-ci.yaml |
27 changes: 27 additions & 0 deletions
27
intermediate-en/session_3/dao/.github/workflows/release.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths-ignore: | ||
- "docs/**" | ||
- "**.md" | ||
- ".vscode/**" | ||
- ".idea/**" | ||
|
||
permissions: | ||
contents: read | ||
packages: read | ||
|
||
jobs: | ||
backend-release: | ||
name: Backend Release | ||
secrets: inherit | ||
uses: ./.github/workflows/smart-contracts-cd.yaml | ||
|
||
frontend-release: | ||
name: Frontend Release | ||
secrets: inherit | ||
uses: ./.github/workflows/frontend-cd.yaml | ||
needs: backend-release |
51 changes: 51 additions & 0 deletions
51
intermediate-en/session_3/dao/.github/workflows/smart-contracts-cd.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Backend CD | ||
|
||
on: | ||
workflow_call: | ||
|
||
concurrency: release | ||
|
||
jobs: | ||
ci-check: | ||
name: Perform smart contract checks | ||
uses: ./.github/workflows/smart-contracts-ci.yaml | ||
|
||
deploy-testnet: | ||
runs-on: 'ubuntu-latest' | ||
needs: ci-check | ||
environment: Test | ||
steps: | ||
- name: Checkout source code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install poetry | ||
run: pipx install poetry | ||
|
||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
cache: 'poetry' | ||
|
||
- name: Install algokit | ||
run: pipx install algokit | ||
|
||
- name: Bootstrap dependencies | ||
working-directory: ./backend | ||
run: algokit bootstrap all | ||
|
||
- name: Configure git | ||
shell: bash | ||
working-directory: ./backend | ||
run: | | ||
# set git user and email as test invoke git | ||
git config --global user.email "[email protected]" && git config --global user.name "github-actions" | ||
- name: Deploy to testnet | ||
working-directory: ./backend | ||
run: algokit deploy testnet | ||
env: | ||
# This is the account that becomes the creator of the contract. | ||
# Since we are not using the optional dispenser account (via DISPENSER_MNEMONIC), | ||
# it must also be funded with enough Algos to deploy and fund the smart contracts created | ||
DEPLOYER_MNEMONIC: ${{ secrets.DEPLOYER_MNEMONIC }} |
75 changes: 75 additions & 0 deletions
75
intermediate-en/session_3/dao/.github/workflows/smart-contracts-ci.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
name: Backend CI | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
checks: | ||
runs-on: 'ubuntu-latest' | ||
steps: | ||
- name: Checkout source code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install poetry | ||
run: pipx install poetry | ||
|
||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
cache: 'poetry' | ||
|
||
- name: Install algokit | ||
run: pipx install algokit | ||
|
||
- name: Start LocalNet | ||
run: algokit localnet start | ||
|
||
- name: Bootstrap dependencies | ||
run: algokit bootstrap all | ||
working-directory: ./backend | ||
|
||
- name: Configure git | ||
shell: bash | ||
working-directory: ./backend | ||
run: | | ||
# set git user and email as test invoke git | ||
git config --global user.email "[email protected]" && git config --global user.name "github-actions" | ||
- name: Audit with pip-audit | ||
working-directory: ./backend | ||
run: | | ||
# audit non dev dependencies, no exclusions | ||
poetry export --without=dev > requirements.txt && poetry run pip-audit -r requirements.txt | ||
# audit all dependencies, with exclusions. | ||
# If a vulnerability is found in a dev dependency without an available fix, | ||
# it can be temporarily ignored by adding --ignore-vuln e.g. | ||
# --ignore-vuln "GHSA-hcpj-qp55-gfph" # GitPython vulnerability, dev only dependency | ||
poetry run pip-audit | ||
- name: Check formatting with Black | ||
working-directory: ./backend | ||
run: | | ||
# stop the build if there are files that don't meet formatting requirements | ||
poetry run black --check . | ||
- name: Run tests | ||
working-directory: ./backend | ||
shell: bash | ||
run: | | ||
set -o pipefail | ||
poetry run pytest --junitxml=pytest-junit.xml | ||
- name: Build smart contracts | ||
working-directory: ./backend | ||
run: poetry run python -m smart_contracts build | ||
|
||
- name: Check output stability of the smart contracts | ||
shell: bash | ||
working-directory: ./backend | ||
run: | | ||
# Add untracked files as empty so they come up in diff | ||
git add -N ./smart_contracts/artifacts | ||
# Error out if there are any changes in teal after generating output | ||
git diff --exit-code --minimal ./smart_contracts/artifacts || (echo "::error ::Smart contract artifacts have changed, ensure committed artifacts are up to date" && exit 1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# dao | ||
|
||
This starter full stack project has been generated using AlgoKit. See below for default getting started instructions. | ||
|
||
## Setup | ||
|
||
### Initial setup | ||
|
||
1. Clone this repository locally. | ||
2. Install pre-requisites: | ||
- Make sure to have [Docker](https://www.docker.com/) installed and running on your machine. | ||
- Install `AlgoKit` - [Link](https://github.com/algorandfoundation/algokit-cli#install): The minimum required version is `1.3.0`. Ensure you can execute `algokit --version` and get `1.3.0` or later. | ||
- Bootstrap your local environment; run `algokit bootstrap all` within this folder, which will install Poetry, run `npm install` and `poetry install` in the root directory to install NPM and Python packages respectively, set up a `.venv` folder with a Python virtual environment and also install all Python dependencies. | ||
- For TypeScript projects, it will also run `npm install` to install NPM packages. | ||
- For all projects, it will copy `.env.template` to `.env`. | ||
- Run `algokit localnet start` to start a local Algorand network in Docker. If you are using VS Code launch configurations provided by the template, this will be done automatically for you. | ||
3. Open the project and start debugging / developing on: | ||
- [Backend](backend/README.md) - Refer to the README for more information on how to work with smart contracts. | ||
- [Frontend](frontend/README.md) - Refer to the README for more information on how to work with the frontend application. | ||
|
||
|
||
### Subsequently | ||
|
||
1. If you update to the latest source code and there are new dependencies, you will need to run `algokit bootstrap all` again. | ||
2. Follow step 3 above. | ||
|
||
### Continuous Integration / Continuous Deployment (CI/CD) | ||
|
||
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. You can configure these actions to suit your project's needs, including CI checks, audits, linting, type checking, testing, and deployments to TestNet. | ||
|
||
For pushes to `main` branch, after the above checks pass, the following deployment actions are performed: | ||
- The smart contract(s) are deployed to TestNet using [AlgoNode](https://algonode.io). | ||
- The frontend application is deployed to a provider of your choice (Netflify, Vercel, etc.). See [frontend README](frontend/README.md) for more information. | ||
|
||
> Please note deployment of smart contracts is done 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). | ||
## Tools | ||
|
||
This project makes use of Python and React to build Algorand smart contracts and to provide a base project configuration to develop frontends for your Algorand dApps and interactions with smart contracts. The following tools are in use: | ||
|
||
- Algorand, AlgoKit, and AlgoKit Utils | ||
- Python dependencies including Poetry, Black, Ruff or Flake8, mypy, pytest, and pip-audit | ||
- React and related dependencies including AlgoKit Utils, Tailwind CSS, daisyUI, use-wallet, npm, jest, playwright, Prettier, ESLint, and Github Actions workflows for build validation | ||
|
||
It has also been configured to have a productive dev experience out of the box in [VS Code](https://code.visualstudio.com/), see the [backend .vscode](./backend/.vscode) and [frontend .vscode](./frontend/.vscode) folders for more details. | ||
|
||
## Integrating with smart contracts and application clients | ||
|
||
Refer to the [backend](backend/README.md) folder for overview of working with smart contracts, [frontend](frontend/README.md) for overview of the React project and the [frontend/contracts](frontend/src/contracts/README.md) folder for README on adding new smart contracts from backend as application clients on your frontend. The templates provided in these folders will help you get started. | ||
When you compile and generate smart contract artifacts, your frontend component will automatically generate typescript application clients from smart contract artifacts and move them to `frontend/src/contracts` folder, see [`generate:app-clients` in package.json](frontend/package.json). Afterwards, you are free to import and use them in your frontend application. | ||
|
||
The frontend starter also provides an example of interactions with your DaoClient in [`AppCalls.tsx`](frontend/src/components/AppCalls.tsx) component by default. | ||
|
||
## Next Steps | ||
|
||
You can take this project and customize it to build your own decentralized applications on Algorand. Make sure to understand how to use AlgoKit and how to write smart contracts for Algorand before you start. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[algokit] | ||
min_version = "v1.3.0b1" | ||
|
||
[deploy] | ||
command = "npm run deploy:ci" | ||
environment_secrets = [ | ||
"DEPLOYER_MNEMONIC", | ||
] | ||
|
||
[deploy.localnet] | ||
environment_secrets = [] |
Oops, something went wrong.