Skip to content

Commit 46f7ff1

Browse files
committed
chore: use icp-cli for the candid ui
1 parent f97db28 commit 46f7ff1

13 files changed

Lines changed: 1861 additions & 4303 deletions

File tree

tools/ui/.gitignore

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@
77
.DS_Store
88
**/.DS_Store
99

10-
# dfx temporary files
11-
.dfx/
10+
# icp-cli ephemeral state (local network + build cache).
11+
# Persistent data such as mainnet canister id mappings lives in .icp/data/
12+
# and IS committed.
13+
.icp/cache/
1214

1315
# frontend code
1416
node_modules/
1517
dist/
1618
ts-out/
19+
20+
.dfx
21+
.icp/cache
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"didjs": "a4gq6-oaaaa-aaaab-qaa4q-cai"
3+
}

tools/ui/Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tools/ui/README.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,27 @@ The frontend `ui` fetches the Candid interface from the running canister (curren
77

88
## Build
99

10-
You need `dfx`, `cargo`, `npm` and `wasm-opt` for building the canister.
10+
You need [`icp`](https://cli.internetcomputer.org), `cargo`, `npm`, `wasm-opt` and
11+
`ic-wasm` for building the canister. The frontend is bundled with [Vite](https://vite.dev).
1112

1213
```bash
1314
cd ui/
1415
npm install
15-
dfx start --background
16-
dfx canister create --all
17-
dfx build
18-
dfx canister install --all
16+
icp network start -d # start a local replica in the background
17+
icp deploy # build + deploy the didjs canister locally
1918
```
2019

20+
To deploy to mainnet (the `ic` environment), which targets the existing
21+
`a4gq6-oaaaa-aaaab-qaa4q-cai` canister:
22+
23+
```bash
24+
icp deploy -e ic
25+
```
26+
27+
Project configuration lives in `icp.yaml`. Canister id mappings are stored under
28+
`.icp/`: the mainnet mapping (`.icp/data/mappings/ic.ids.json`) is committed, while
29+
local replica state under `.icp/cache/` is ephemeral and git-ignored.
30+
2131
## Usage
2232

2333
Open the `ui` canister in a browser and supply the id parameter in the URL to render a specific canister,

tools/ui/canister_ids.json

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

tools/ui/dfx.json

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

tools/ui/icp.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
canisters:
2+
- name: didjs
3+
build:
4+
steps:
5+
- type: script
6+
commands:
7+
- npm run build
8+
- cargo build --target wasm32-unknown-unknown --profile canister --package didjs
9+
- wasm-opt --strip-debug -Oz target/wasm32-unknown-unknown/canister/didjs.wasm -o target/wasm32-unknown-unknown/canister/didjs_opt.wasm
10+
- ic-wasm target/wasm32-unknown-unknown/canister/didjs_opt.wasm -o target/wasm32-unknown-unknown/canister/didjs_opt.wasm metadata candid:service -f src/didjs/didjs.did -v public
11+
- cp target/wasm32-unknown-unknown/canister/didjs_opt.wasm "$ICP_WASM_OUTPUT_PATH"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,5 +137,6 @@ <h1 id="title">Candid UI</h1>
137137
outputButton.click();
138138
}
139139
</script>
140+
<script type="module" src="/src/index.ts"></script>
140141
</body>
141142
</html>

0 commit comments

Comments
 (0)