Skip to content

Commit 8426a74

Browse files
authored
Merge pull request #1110 from dfinity/severin/consolidate-ninja-projects
chore: migrate Ninja projects here
2 parents c1d8773 + e560645 commit 8426a74

File tree

367 files changed

+64223
-5301
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

367 files changed

+64223
-5301
lines changed

.github/CODEOWNERS

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,34 @@
55
/c/reverse/ @dfinity/growth
66

77
/hosting/godot-html5-template/ @dfinity/sdk
8+
/hosting/my_crypto_blog/ @dfinity/ninja-devs
89
/hosting/photo-storage/ @dfinity/sdk
10+
/hosting/react/ @dfinity/ninja-devs
911
/hosting/static-website/ @dfinity/sdk
1012
/hosting/unity-webgl-template/ @dfinity/sdk
1113

1214
/motoko/basic_bitcoin/ @dfinity/execution
1315
/motoko/basic_dao/ @dfinity/languages
16+
/motoko/backend_only/ @dfinity/ninja-devs
1417
/motoko/canister_logs/ @dfinity/execution
1518
/motoko/cert-var/ @dfinity/trust
1619
/motoko/classes/ @dfinity/languages
1720
/motoko/composite_query/ @dfinity/languages
1821
/motoko/counter/ @dfinity/languages
22+
/motoko/daily_planner/ @dfinity/ninja-devs
1923
/motoko/encrypted-notes-dapp-vetkd/ @dfinity/crypto-team
2024
/motoko/encrypted-notes-dapp/ @dfinity/crypto-team
25+
/motoko/evm_block_explorer/ @dfinity/ninja-devs
26+
/motoko/filevault/ @dfinity/ninja-devs
27+
/motoko/flying_ninja/ @dfinity/ninja-devs
2128
/motoko/hello_cycles/ @dfinity/languages
29+
/motoko/hello_world/ @dfinity/ninja-devs
2230
/motoko/ic-pos/ @dfinity/growth
2331
/motoko/icp_transfer/ @dfinity/growth
2432
/motoko/icrc2-swap/ @dfinity/growth
2533
/motoko/internet_identity_integration/ @dfinity/identity
2634
/motoko/life/ @dfinity/languages
35+
/motoko/llm_chatbot/ @dfinity/ninja-devs
2736
/motoko/minimal-counter-dapp/ @dfinity/growth
2837
/motoko/parallel_calls/ @dfinity/languages
2938
/motoko/pub-sub/ @dfinity/growth
@@ -34,32 +43,39 @@
3443
/motoko/superheroes/ @dfinity/growth
3544
/motoko/threshold-ecdsa/ @dfinity/crypto-team
3645
/motoko/threshold-schnorr/ @dfinity/crypto-team
46+
/motoko/tokenmania/ @dfinity/ninja-devs
3747
/motoko/token_transfer/ @dfinity/growth
3848
/motoko/token_transfer_from/ @dfinity/growth
3949
/motoko/vetkd/ @dfinity/crypto-team
4050
/motoko/whoami/ @dfinity/growth
51+
/motoko/who_am_i/ @dfinity/ninja-devs
4152

4253
/native-apps/unity_ii_applink/ @dfinity/sdk
4354
/native-apps/unity_ii_deeplink/ @dfinity/sdk
4455

4556
/rust/basic_bitcoin/ @dfinity/execution
4657
/rust/basic_dao/ @dfinity/testing-verification
4758
/rust/basic_ethereum/ @dfinity/cross-chain-team
59+
/rust/backend_only/ @dfinity/ninja-devs
4860
/rust/canister-info/ @dfinity/testing-verification
4961
/rust/canister-snapshots/ @dfinity/execution
5062
/rust/canister_logs/ @dfinity/execution
5163
/rust/composite_query/ @dfinity/execution
5264
/rust/counter/ @dfinity/growth
65+
/rust/daily_planner/ @dfinity/ninja-devs
5366
/rust/defi/ @dfinity/growth
5467
/rust/dip721-nft-container/ @dfinity/sdk
5568
/rust/encrypted-notes-dapp-vetkd/ @dfinity/crypto-team
5669
/rust/encrypted-notes-dapp/ @dfinity/crypto-team
70+
/rust/evm_block_explorer/ @dfinity/ninja-devs
5771
/rust/face-recognition/ @dfinity/execution
72+
/rust/flying_ninja/ @dfinity/ninja-devs
5873
/rust/guards/ @dfinity/cross-chain-team
59-
/rust/hello/ @dfinity/sdk
74+
/rust/hello_world/ @dfinity/ninja-devs
6075
/rust/icp_transfer/ @dfinity/growth
6176
/rust/image-classification/ @dfinity/execution
6277
/rust/inter-canister-calls/ @dfinity/ic-message-routing-owners
78+
/rust/llm_chatbot/ @dfinity/ninja-devs
6379
/rust/low_wasm_memory/ @dfinity/execution
6480
/rust/nft-wallet/ @dfinity/growth
6581
/rust/parallel_calls/ @dfinity/research
@@ -72,9 +88,11 @@
7288
/rust/simd/ @dfinity/execution
7389
/rust/threshold-ecdsa/ @dfinity/crypto-team
7490
/rust/threshold-schnorr/ @dfinity/crypto-team
91+
/rust/tokenmania/ @dfinity/ninja-devs
7592
/rust/token_transfer/ @dfinity/growth
7693
/rust/token_transfer_from/ @dfinity/growth
7794
/rust/vetkd/ @dfinity/crypto-team
95+
/rust/who_am_i/ @dfinity/ninja-devs
7896
/rust/x509/ @dfinity/crypto-team
7997

8098
/svelte/svelte-motoko-starter/ @dfinity/sdk
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Test examples
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
8+
concurrency:
9+
group: examples-pr-checks-${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
check-example-changes:
14+
name: Filter projects
15+
runs-on: ubuntu-22.04
16+
outputs:
17+
matrix: ${{ steps.set-matrix.outputs.matrix }}
18+
has_examples: ${{ steps.set-matrix.outputs.has_examples }}
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Fetch all branches
24+
run: git fetch origin
25+
26+
- name: Set matrix based on changes
27+
id: set-matrix
28+
run: |
29+
changed_files=$(git diff --name-only origin/main ${{ github.sha }})
30+
echo "Changed files: $changed_files"
31+
32+
examples=()
33+
declare -A example_paths=(
34+
["My Crypto Blog (Frontend)"]="hosting/my_crypto_blog"
35+
["React (Frontend)"]="hosting/react"
36+
["Motoko backend (Motoko)"]="motoko/backend_only"
37+
["Daily Planner (Motoko)"]="motoko/daily_planner"
38+
["EVM Block Explorer (Motoko)"]="motoko/evm_block_explorer"
39+
["FileVault (Motoko)"]="motoko/filevault"
40+
["Flying Ninja (Motoko)"]="motoko/flying_ninja"
41+
["Hello World (Motoko)"]="motoko/hello_world"
42+
["LLM Chatbot (Motoko)"]="motoko/llm_chatbot"
43+
["Tokenmania (Motoko)"]="motoko/tokenmania"
44+
["Who Am I (Motoko)"]="motoko/who_am_i"
45+
["Rust backend (Rust)"]="rust/backend_only"
46+
["Daily Planner (Rust)"]="rust/daily_planner"
47+
["EVM Block Explorer (Rust)"]="rust/evm_block_explorer"
48+
["Flying Ninja (Rust)"]="rust/flying_ninja"
49+
["Hello World (Rust)"]="rust/hello_world"
50+
["LLM Chatbot (Rust)"]="rust/llm_chatbot"
51+
["Tokenmania (Rust)"]="rust/tokenmania"
52+
["Who Am I (Rust)"]="rust/who_am_i"
53+
)
54+
for name in "${!example_paths[@]}"; do
55+
path=${example_paths[$name]}
56+
echo "Checking path: $path"
57+
58+
if echo "$changed_files" | grep -q "^$path/"; then
59+
examples+=("{\"name\": \"$name\", \"path\": \"$path\"}")
60+
echo "Added example: $name with path $path"
61+
fi
62+
done
63+
64+
if [ ${#examples[@]} -eq 0 ]; then
65+
echo "No examples detected. Setting has_examples to false."
66+
echo "has_examples=false" >> $GITHUB_OUTPUT
67+
echo "matrix={\"example\": []}" >> $GITHUB_OUTPUT
68+
else
69+
matrix="{\"example\": [$(IFS=, ; echo "${examples[*]}")]}"
70+
echo "Matrix generated: $matrix"
71+
echo "has_examples=true" >> $GITHUB_OUTPUT
72+
echo "matrix=$matrix" >> $GITHUB_OUTPUT
73+
fi
74+
75+
build-examples:
76+
name: Build
77+
needs: check-example-changes
78+
if: needs.check-example-changes.outputs.has_examples == 'true'
79+
runs-on: ubuntu-22.04
80+
container: ghcr.io/dfinity/icp-dev-env-slim:17
81+
strategy:
82+
matrix: ${{ fromJson(needs.check-example-changes.outputs.matrix) }}
83+
84+
steps:
85+
- name: Checkout
86+
uses: actions/checkout@v4
87+
88+
- name: Install dfx # This is a temporary workaround. Dfx is already installed in the container, but it does not start in the next step if we don't install it here again.
89+
uses: dfinity/setup-dfx@main
90+
91+
- name: Start dfx
92+
run: dfx start --background
93+
94+
- name: Build project
95+
working-directory: ${{ matrix.example.path }}
96+
run: |
97+
if [ -f "Makefile" ]; then
98+
make test
99+
else
100+
dfx deploy
101+
fi

.github/workflows/rust-hello-example.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.

hosting/my_crypto_blog/BUILD.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Continue building locally
2+
3+
Projects deployed through ICP Ninja are temporary; they will only be live for 20 minutes before they are removed. The command-line tool `dfx` can be used to continue building your ICP Ninja project locally and deploy it to the mainnet.
4+
5+
To migrate your ICP Ninja project off of the web browser and develop it locally, follow these steps.
6+
7+
### 1. Install developer tools.
8+
9+
You can install the developer tools natively or use Dev Containers.
10+
11+
#### Option 1: Natively install developer tools
12+
13+
> Installing `dfx` natively is currently only supported on macOS and Linux systems. On Windows, it is recommended to use the Dev Containers option.
14+
15+
1. Install `dfx` with the following command:
16+
17+
```
18+
19+
sh -ci "$(curl -fsSL https://internetcomputer.org/install.sh)"
20+
21+
```
22+
23+
> On Apple Silicon (e.g., Apple M1 chip), make sure you have Rosetta installed (`softwareupdate --install-rosetta`).
24+
25+
2. [Install NodeJS](https://nodejs.org/en/download/package-manager).
26+
27+
3. For Rust projects, you will also need to:
28+
29+
- Install [Rust](https://doc.rust-lang.org/cargo/getting-started/installation.html#install-rust-and-cargo): `curl https://sh.rustup.rs -sSf | sh`
30+
31+
- Install [candid-extractor](https://crates.io/crates/candid-extractor): `cargo install candid-extractor`
32+
33+
4. For Motoko projects, you will also need to:
34+
35+
- Install the Motoko package manager [Mops](https://docs.mops.one/quick-start#2-install-mops-cli): `npm i -g ic-mops`
36+
37+
Lastly, navigate into your project's directory that you downloaded from ICP Ninja.
38+
39+
#### Option 2: Dev Containers
40+
41+
Continue building your projects locally by installing the [Dev Container extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) for VS Code and [Docker](https://docs.docker.com/engine/install/).
42+
43+
Make sure Docker is running, then navigate into your project's directory that you downloaded from ICP Ninja and start the Dev Container by selecting `Dev-Containers: Reopen in Container` in VS Code's command palette (F1 or Ctrl/Cmd+Shift+P).
44+
45+
> Note that local development ports (e.g. the ports used by `dfx` or `vite`) are forwarded from the Dev Container to your local machine. In the VS code terminal, use Ctrl/Cmd+Click on the displayed local URLs to open them in your browser. To view the current port mappings, click the "Ports" tab in the VS Code terminal window.
46+
47+
### 2. Create a local developer identity.
48+
49+
To manage your project's canisters, it is recommended that you create a local [developer identity](https://internetcomputer.org/docs/building-apps/getting-started/identities) rather than use the `dfx` default identity that is not stored securely.
50+
51+
To create a new identity, run the commands:
52+
53+
```
54+
55+
dfx start --background
56+
57+
dfx identity new IDENTITY_NAME
58+
59+
dfx identity use IDENTITY_NAME
60+
61+
```
62+
63+
Replace `IDENTITY_NAME` with your preferred identity name. The first command `dfx start --background` starts the local `dfx` processes, then `dfx identity new` will create a new identity and return your identity's seed phase. Be sure to save this in a safe, secure location.
64+
65+
The third command `dfx identity use` will tell `dfx` to use your new identity as the active identity. Any canister smart contracts created after running `dfx identity use` will be owned and controlled by the active identity.
66+
67+
Your identity will have a principal ID associated with it. Principal IDs are used to identify different entities on ICP, such as users and canisters.
68+
69+
[Learn more about ICP developer identities](https://internetcomputer.org/docs/building-apps/getting-started/identities).
70+
71+
### 3. Deploy the project locally.
72+
73+
Deploy your project to your local developer environment with:
74+
75+
```
76+
npm install
77+
dfx deploy
78+
79+
```
80+
81+
Your project will be hosted on your local machine. The local canister URLs for your project will be shown in the terminal window as output of the `dfx deploy` command. You can open these URLs in your web browser to view the local instance of your project.
82+
83+
### 4. Obtain cycles.
84+
85+
To deploy your project to the mainnet for long-term public accessibility, first you will need [cycles](https://internetcomputer.org/docs/building-apps/getting-started/tokens-and-cycles). Cycles are used to pay for the resources your project uses on the mainnet, such as storage and compute.
86+
87+
> This cost model is known as ICP's [reverse gas model](https://internetcomputer.org/docs/building-apps/essentials/gas-cost), where developers pay for their project's gas fees rather than users pay for their own gas fees. This model provides an enhanced end user experience since they do not need to hold tokens or sign transactions when using a dapp deployed on ICP.
88+
89+
> Learn how much a project may cost by using the [pricing calculator](https://internetcomputer.org/docs/building-apps/essentials/cost-estimations-and-examples).
90+
91+
Cycles can be obtained through [converting ICP tokens into cycles using `dfx`](https://internetcomputer.org/docs/building-apps/developer-tools/dfx/dfx-cycles#dfx-cycles-convert).
92+
93+
### 5. Deploy to the mainnet.
94+
95+
Once you have cycles, run the command:
96+
97+
```
98+
99+
dfx deploy --network ic
100+
101+
```
102+
103+
After your project has been deployed to the mainnet, it will continuously require cycles to pay for the resources it uses. You will need to [top up](https://internetcomputer.org/docs/building-apps/canister-management/topping-up) your project's canisters or set up automatic cycles management through a service such as [CycleOps](https://cycleops.dev/).
104+
105+
> If your project's canisters run out of cycles, they will be removed from the network.
106+
107+
## Additional examples
108+
109+
Additional code examples and sample applications can be found in the [DFINITY examples repo](https://github.com/dfinity/examples).

hosting/my_crypto_blog/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# My crypto blog
2+
3+
![My Crypto Blog](my_crypto_blog.png)
4+
5+
This frontend-only asset canister allows you to serve static files without a backend canister.
6+
Asset canisters can be used to serve static frontend files, such as HTML, CSS, and JavaScript files, to users through a web browser.
7+
8+
## Project structure
9+
10+
The `/frontend` folder contains web assets for the application's user interface. The user interface is written using the React framework.
11+
12+
## Deploying from ICP Ninja
13+
14+
When viewing this project in ICP Ninja, you can deploy it directly to the mainnet for free by clicking "Deploy" in the upper right corner.
15+
To open this project in ICP Ninja, click [here](https://icp.ninja/i?url=https://github.com/dfinity/examples/tree/master/hosting/my_crypto_blog).
16+
17+
To **download** or **reset** the project files, click the menu option next to the deploy button.
18+
19+
## Build and deploy from the command-line
20+
21+
To migrate your ICP Ninja project off of the web browser and develop it locally, follow these steps. These steps are necessary if you want to deploy this project for long-term, production use on the mainnet.
22+
23+
### 1. Download your project from ICP Ninja using the 'Download files' button on the upper left corner under the pink ninja star icon.
24+
25+
### 2. Open the `BUILD.md` file for further instructions.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "ICP Dev Environment",
3+
"image": "ghcr.io/dfinity/icp-dev-env-slim:17",
4+
"forwardPorts": [4943, 5173],
5+
"portsAttributes": {
6+
"4943": {
7+
"label": "dfx",
8+
"onAutoForward": "ignore"
9+
},
10+
"5173": {
11+
"label": "vite",
12+
"onAutoForward": "openBrowser"
13+
}
14+
},
15+
"customizations": {
16+
"vscode": {
17+
"extensions": ["dfinity-foundation.vscode-motoko"]
18+
}
19+
}
20+
}

hosting/my_crypto_blog/dfx.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"canisters": {
3+
"frontend": {
4+
"frontend": {
5+
"entrypoint": "frontend/index.html"
6+
},
7+
"source": ["frontend/dist"],
8+
"type": "assets"
9+
}
10+
}
11+
}

0 commit comments

Comments
 (0)