Skip to content

Commit

Permalink
creating example page
Browse files Browse the repository at this point in the history
  • Loading branch information
tomijaga committed Jan 10, 2025
1 parent 555e3c7 commit 735eb17
Show file tree
Hide file tree
Showing 67 changed files with 14,991 additions and 35 deletions.
39 changes: 22 additions & 17 deletions dfx.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
{
"version": 1,
"canisters": {
"actor_test" : {
"main": "tests/MemoryBuffer.ActorTest.mo",
"type": "motoko"
}
"version": 1,
"canisters": {
"actor_test": {
"main": "tests/MemoryBuffer.ActorTest.mo",
"type": "motoko"
},
"defaults": {
"build": {
"packtool": "mops sources",
"args": "--incremental-gc"
}
},
"networks": {
"local": {
"bind": "127.0.0.1:8000",
"type": "ephemeral"
}
"stress_test": {
"main": "tests/MemoryBTree/MemoryBTree.StressTest.Replica.mo",
"type": "motoko",
"args": "--max-stable-pages 1638400"
}
},
"defaults": {
"build": {
"packtool": "mops sources",
"args": "--incremental-gc"
}
},
"networks": {
"local": {
"bind": "127.0.0.1:4943",
"type": "ephemeral"
}
}
}
2 changes: 1 addition & 1 deletion example/MemoryBTree.mo
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ actor {
orders_sstore := MemoryBTree.upgrade(orders_sstore);

// If two orders are placed at the same timestamp, the second order will overwrite the first
// so for this test we assume that no two orders are placed at the same timestamp
// so for this test we assume that no two orders are placed at the same time
let orders = MemoryBTree.MemoryBTree<Time, Order>(orders_sstore, orders_btree_utils);

let product_prices = [39.99, 7.23, 12.99, 87.00, 5.99];
Expand Down
35 changes: 35 additions & 0 deletions example/txs/.github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Tests

on:
# push:
# branches: [ "main" ]
pull_request:

concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x]

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dfx
uses: dfinity/setup-dfx@main
- name: Start dfx
run: |
dfx cache install
dfx start --background
- run: npm run setup
- run: npm test
38 changes: 38 additions & 0 deletions example/txs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
!.vscode/settings.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

# Canisters
/src/declarations
.dfx
.vessel
.mops

# Environment variables
.env
.env.local
.env.development
.env.test
.env.production
31 changes: 31 additions & 0 deletions example/txs/.gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Online IDE configuration (safe to delete)

tasks:
- before: |
npm install &
export MO_DEV_HIDE_URLS=1 # hide Candid UI links
export PATH="$HOME/bin:$PATH"
echo 'export PATH="$HOME/bin:$PATH"' >> ~/.bashrc
sudo apt-get install -q -y libunwind-dev
DFXVM_INIT_YES=1 sh -ci "$(curl -fsSL https://internetcomputer.org/install.sh)"
source "$HOME/.local/share/dfx/env"
dfx start --background --clean
npm run setup
init: |
npm start
command: |
npm start
vscode:
extensions:
- dfinity-foundation.vscode-motoko

ports:
- name: Replica
port: 4943
visibility: public
onOpen: ignore
- name: Dev Server
port: 3000
visibility: public
onOpen: open-browser
1 change: 1 addition & 0 deletions example/txs/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/src/declarations
7 changes: 7 additions & 0 deletions example/txs/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"singleQuote": true,
"semi": true,
"tabWidth": 4,
"bracketSpacing": true,
"trailingComma": "all"
}
54 changes: 54 additions & 0 deletions example/txs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Vite + React + Motoko

### Get started directly in your browser:

[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/rvanasa/vite-react-motoko)

This template gives you everything you need to build a full-stack Web3 application on the [Internet Computer](https://internetcomputer.org/).

For an example of a real-world dapp built using this starter project, check out the [source code](https://github.com/dfinity/feedback) for DFINITY's [Developer Experience Feedback Board](https://dx.internetcomputer.org/).

## 📦 Create a New Project

Make sure that [Node.js](https://nodejs.org/en/) `>= 16` and [`dfx`](https://internetcomputer.org/docs/current/developer-docs/build/install-upgrade-remove) `>= 0.14` are installed on your system.

Run the following commands in a new, empty project directory:

```sh
npx degit rvanasa/vite-react-motoko # Download this starter project
dfx start --clean --background # Run dfx in the background
npm run setup # Install packages, deploy canisters, and generate type bindings

npm start # Start the development server
```

When ready, run `dfx deploy --network ic` to deploy your application to the Internet Computer.

## 🛠️ Technology Stack

- [Vite](https://vitejs.dev/): high-performance tooling for front-end web development
- [React](https://reactjs.org/): a component-based UI library
- [TypeScript](https://www.typescriptlang.org/): JavaScript extended with syntax for types
- [Sass](https://sass-lang.com/): an extended syntax for CSS stylesheets
- [Prettier](https://prettier.io/): code formatting for a wide range of supported languages
- [Motoko](https://github.com/dfinity/motoko#readme): a safe and simple programming language for the Internet Computer
- [Mops](https://mops.one): an on-chain community package manager for Motoko
- [mo-dev](https://github.com/dfinity/motoko-dev-server#readme): a live reload development server for Motoko
- [@ic-reactor](https://github.com/B3Pay/ic-reactor): A suite of JavaScript libraries for seamless frontend development on the Internet Computer

## 📚 Documentation

- [Vite developer docs](https://vitejs.dev/guide/)
- [React quick start guide](https://react.dev/learn)
- [Internet Computer docs](https://internetcomputer.org/docs/current/developer-docs/ic-overview)
- [`dfx.json` reference schema](https://internetcomputer.org/docs/current/references/dfx-json-reference/)
- [Motoko developer docs](https://internetcomputer.org/docs/current/developer-docs/build/cdks/motoko-dfinity/motoko/)
- [Mops usage instructions](https://j4mwm-bqaaa-aaaam-qajbq-cai.ic0.app/#/docs/install)
- [@ic-reactor/react](https://b3pay.github.io/ic-reactor/modules/react.html)

## 💡 Tips and Tricks

- Customize your project's code style by editing the `.prettierrc` file and then running `npm run format`.
- Reduce the latency of update calls by passing the `--emulator` flag to `dfx start`.
- Install a Motoko package by running `npx ic-mops add <package-name>`. Here is a [list of available packages](https://mops.one/).
- Split your frontend and backend console output by running `npm run frontend` and `npm run backend` in separate terminals.
Loading

0 comments on commit 735eb17

Please sign in to comment.