Skip to content

Commit

Permalink
chore: tweaking codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
aorumbayev committed Dec 4, 2023
1 parent c3b48d8 commit ffcc6ea
Show file tree
Hide file tree
Showing 47 changed files with 1,355 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"files.associations": {
"**/*.jinja": "jinja"
},
"python.testing.pytestArgs": ["tests"],
"python.testing.pytestArgs": ["."],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"files.eol": "\n"
Expand Down
20 changes: 9 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
<div align="center">
<a href="https://github.com/algorandfoundation/algokit-react-frontend-template"><img src="https://bafybeibsg44yt327gd7jxfsetk6tw6zcxqnrb5hlqsnowlolncnw3qxhjm.ipfs.nftstorage.link/" width=60%></a>
<a href="https://github.com/subtopia-algo/algokit-subtopia-template"><img src="https://bafybeidbdaq576qdekealqyfpgqzfdxobc5zifrko3b4afib3ezr3g3gyy.ipfs.nftstorage.link/" width=60%></a>
</div>

<p align="center">
<a target="_blank" href="https://github.com/algorandfoundation/algokit-cli"><img src="https://img.shields.io/badge/docs-repository-00dc94?logo=github&style=flat.svg" /></a>
<a target="_blank" href="https://developer.algorand.org/algokit/"><img src="https://img.shields.io/badge/learn-AlgoKit-00dc94?logo=algorand&mac=flat.svg" /></a>
<a target="_blank" href="https://github.com/algorandfoundation/algokit-react-frontend-template"><img src="https://img.shields.io/github/stars/algorandfoundation/algokit-react-frontend-template?color=00dc94&logo=star&style=flat" /></a>
<a target="_blank" href="https://developer.algorand.org/algokit/"><img src="https://vbr.wocr.tk/badge?page_id=algorandfoundation%2Falgokit-react-frontend-template&color=%2300dc94&style=flat" /></a>
<a href="https://www.npmjs.com/package/subtopia-js-sdk"><img src="https://badge.fury.io/js/subtopia-js-sdk.svg" alt="npm version"></a>
<a href="https://subtopia.io"><img src="https://img.shields.io/badge/platform-link-cyan.svg" /></a>
<a href="https://github.com/algorandfoundation/algokit-cli"><img src="https://img.shields.io/badge/Powered by-AlgoKit-black.svg" /></a>
</p>

---

This template provides a baseline React web app for developing integrating with any [ARC32](https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0032.md) compliant Algorand smart contracts.

To use it [install AlgoKit](https://github.com/algorandfoundation/algokit-cli#readme) and then either pass in `-t react` to `algokit init` or select the `react` template interactively during `algokit init`.

This is one of the official frontend templates used by AlgoKit to initialise an Algorand enabled React web app ready for integrating with your smart contracts. It's made by relying on a [Copier templates](https://copier.readthedocs.io/en/stable/).
This template is a starter template for building an Algorand based dApp on React with [`subtopia-js-sdk`](https://github.com/subtopia-algo/subtopia-js) integration. The template is based on the official [`algokit-react-template`](https://github.com/algorandfoundation/algokit-react-frontend-template).

## Features

This template supports the following features:
The template offers two presets, the recommended preset includes all of the above, a custom preset allows you to select which features you want to include in your project.

The full list of features includes the following:

- Subtopia SDK integration for interacting with the Subtopia protocol. Includes a sample TestNet based subscription integrated.
- React web app with [Tailwind CSS](https://tailwindcss.com/) and [TypeScript](https://www.typescriptlang.org/)
- Styled framework agnostic CSS components using [DaisyUI](https://daisyui.com/).
- Starter jest unit tests for typescript functions. Can be disabled if not needed.
Expand Down
2 changes: 1 addition & 1 deletion copier.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ use_daisy_ui:
type: bool
help: Do you want to use a daisyUI? Framework agnostic CSS component library for building modern websites and web applications fast.
default: yes
when: '{{ use_tailwind != false && preset == "custom" }}'
when: '{{ use_tailwind != false and preset == "custom" }}'

use_jest:
type: bool
Expand Down
2 changes: 2 additions & 0 deletions tests_generated/test_default_preset/.algokit.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[algokit]
min_version = "v1.3.0b1"
13 changes: 13 additions & 0 deletions tests_generated/test_default_preset/.copier-answers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: <commit>
_src_path: <src>
algod_port: 4001
algod_server: http://localhost
algod_token: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
cloud_provider: none
indexer_port: 8980
indexer_server: http://localhost
indexer_token: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
preset: default
project_name: test_default_preset

9 changes: 9 additions & 0 deletions tests_generated/test_default_preset/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[*]
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
67 changes: 67 additions & 0 deletions tests_generated/test_default_preset/.env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# ======================
# LocalNet configuration
# uncomment below to use
# ======================

VITE_ENVIRONMENT=local

# Algod
VITE_ALGOD_TOKEN=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
VITE_ALGOD_SERVER=http://localhost
VITE_ALGOD_PORT=4001
VITE_ALGOD_NETWORK=""

# Indexer
VITE_INDEXER_TOKEN=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
VITE_INDEXER_SERVER=http://localhost
VITE_INDEXER_PORT=8980

# KMD
# Please note:
# 1. This is only needed for LocalNet since
# by default KMD provider is ignored on other networks.
# 2. AlgoKit LocalNet starts with a single wallet called 'unencrypted-default-wallet',
# with heaps of tokens available for testing.
VITE_KMD_TOKEN=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
VITE_KMD_SERVER=http://localhost
VITE_KMD_PORT=4002
VITE_KMD_WALLET="unencrypted-default-wallet"
VITE_KMD_PASSWORD=""

# # ======================
# # TestNet configuration:
# # uncomment below to use
# # ======================

# VITE_ENVIRONMENT=local

# # Algod
# VITE_ALGOD_TOKEN=""
# VITE_ALGOD_SERVER="https://testnet-api.algonode.cloud"
# VITE_ALGOD_PORT=""
# VITE_ALGOD_NETWORK="testnet"

# # Indexer
# VITE_INDEXER_TOKEN=""
# VITE_INDEXER_SERVER="https://testnet-idx.algonode.cloud"
# VITE_INDEXER_PORT=""


# # ======================
# # MainNet configuration:
# # uncomment below to use
# # ======================

# VITE_ENVIRONMENT=production

# # Algod
# VITE_ALGOD_TOKEN=""
# VITE_ALGOD_SERVER="https://mainnet-api.algonode.cloud"
# VITE_ALGOD_PORT=""
# VITE_ALGOD_NETWORK="mainnet"

# # Indexer
# VITE_INDEXER_TOKEN=""
# VITE_INDEXER_SERVER="https://mainnet-idx.algonode.cloud"
# VITE_INDEXER_PORT=""

27 changes: 27 additions & 0 deletions tests_generated/test_default_preset/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"root": true,
"env": {
"node": true
},
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "prettier"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"rules": {
"prettier/prettier": "warn",
"no-console": "warn",
"@typescript-eslint/no-unused-vars": [
"warn",
{
"ignoreRestSiblings": true,
"argsIgnorePattern": "^_",
"destructuredArrayIgnorePattern": "^_"
}
],
"prefer-template": "error"
}
}
1 change: 1 addition & 0 deletions tests_generated/test_default_preset/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
54 changes: 54 additions & 0 deletions tests_generated/test_default_preset/.github/workflows/checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Check code base

on:
workflow_call:
inputs:
run-build:
required: false
type: boolean
default: false
push:
branches:
- main

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: Install dependencies
run: npm ci

- name: Run linters
run: npm run lint

- name: Run unit tests
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: './.env'
env-template-path: './.env.template'
env-variable-prefix: VITE_

- name: Build
if: ${{ inputs.run-build }}
run: npm run build

- name: Archive
if: ${{ inputs.run-build }}
uses: actions/upload-artifact@v3
with:
name: dist
path: dist/
8 changes: 8 additions & 0 deletions tests_generated/test_default_preset/.github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: Pull Request validation

on: [pull_request]

jobs:
pr-check:
name: Perform Checks
uses: ./.github/workflows/checks.yaml
61 changes: 61 additions & 0 deletions tests_generated/test_default_preset/.github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Release

on:
push:
branches:
- main
paths-ignore:
- "docs/**"
- "**.md"
- ".vscode/**"
- ".idea/**"

permissions:
contents: read
packages: read

jobs:
lint-and-build:
name: CI dApp
uses: ./.github/workflows/checks.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: dist

- name: Replace template vars
uses: makerxstudio/shared-config/.github/actions/placeholder-transforms@main
with:
app-artifact-path: './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
run: npm i netlify-cli

- name: Publish to netlify
run: netlify deploy --prod --dir "dist"
env:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}

35 changes: 35 additions & 0 deletions tests_generated/test_default_preset/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build


# dotenv environment variable files
.env
env/

# misc
/dist
.DS_Store


npm-debug.log*
yarn-debug.log*
yarn-error.log*
/test-results/
/playwright-report/
/playwright/.cache/

# PyCharm
.idea
!.idea/
.idea/*
!.idea/runConfigurations/
12 changes: 12 additions & 0 deletions tests_generated/test_default_preset/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# don't ever format node_modules
node_modules
# don't lint format output (make sure it's set to your correct build folder name)
dist
build
# don't format nyc coverage output
coverage
# don't format generated types
**/generated/types.d.ts
**/generated/types.ts
# don't format ide files
.idea
10 changes: 10 additions & 0 deletions tests_generated/test_default_preset/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
singleQuote: true,
jsxSingleQuote: false,
semi: false,
tabWidth: 2,
trailingComma: 'all',
printWidth: 140,
endOfLine: 'lf',
arrowParens: 'always',
}
14 changes: 14 additions & 0 deletions tests_generated/test_default_preset/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"recommendations": [
"EditorConfig.EditorConfig",
"dotenv.dotenv-vscode",
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint",
"krysenlo.vite-plugin-eslint-problemmatcher",
"ms-playwright.playwright",
"Orta.vscode-jest",
"bradlc.vscode-tailwindcss",
"csstools.postcss",
]
}

Loading

0 comments on commit ffcc6ea

Please sign in to comment.