diff --git a/tools/ui/.gitignore b/tools/ui/.gitignore index b95879510..11f5b07bf 100644 --- a/tools/ui/.gitignore +++ b/tools/ui/.gitignore @@ -7,10 +7,15 @@ .DS_Store **/.DS_Store -# dfx temporary files -.dfx/ +# icp-cli ephemeral state (local network + build cache). +# Persistent data such as mainnet canister id mappings lives in .icp/data/ +# and IS committed. +.icp/cache/ # frontend code node_modules/ dist/ ts-out/ + +.dfx +.icp/cache diff --git a/tools/ui/.icp/data/mappings/ic.ids.json b/tools/ui/.icp/data/mappings/ic.ids.json new file mode 100644 index 000000000..18e5489dd --- /dev/null +++ b/tools/ui/.icp/data/mappings/ic.ids.json @@ -0,0 +1,3 @@ +{ + "didjs": "a4gq6-oaaaa-aaaab-qaa4q-cai" +} diff --git a/tools/ui/Cargo.lock b/tools/ui/Cargo.lock index 27cff3e08..9a063c590 100644 --- a/tools/ui/Cargo.lock +++ b/tools/ui/Cargo.lock @@ -132,7 +132,7 @@ checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3" [[package]] name = "candid" -version = "0.10.20" +version = "0.10.29" dependencies = [ "anyhow", "binread", @@ -153,7 +153,7 @@ dependencies = [ [[package]] name = "candid_derive" -version = "0.10.20" +version = "0.10.29" dependencies = [ "lazy_static", "proc-macro2", @@ -465,7 +465,7 @@ checksum = "8de254dd67bbd58073e23dc1c8553ba12fa1dc610a19de94ad2bbcd0460c067f" [[package]] name = "ic_principal" -version = "0.1.1" +version = "0.1.3" dependencies = [ "arbitrary", "crc32fast", diff --git a/tools/ui/README.md b/tools/ui/README.md index a648abe7b..40c416170 100644 --- a/tools/ui/README.md +++ b/tools/ui/README.md @@ -7,17 +7,27 @@ The frontend `ui` fetches the Candid interface from the running canister (curren ## Build -You need `dfx`, `cargo`, `npm` and `wasm-opt` for building the canister. +You need [`icp`](https://cli.internetcomputer.org), `cargo`, `npm`, `wasm-opt` and +`ic-wasm` for building the canister. The frontend is bundled with [Vite](https://vite.dev). ```bash cd ui/ npm install -dfx start --background -dfx canister create --all -dfx build -dfx canister install --all +icp network start -d # start a local replica in the background +icp deploy # build + deploy the didjs canister locally ``` +To deploy to mainnet (the `ic` environment), which targets the existing +`a4gq6-oaaaa-aaaab-qaa4q-cai` canister: + +```bash +icp deploy -e ic +``` + +Project configuration lives in `icp.yaml`. Canister id mappings are stored under +`.icp/`: the mainnet mapping (`.icp/data/mappings/ic.ids.json`) is committed, while +local replica state under `.icp/cache/` is ephemeral and git-ignored. + ## Usage Open the `ui` canister in a browser and supply the id parameter in the URL to render a specific canister, diff --git a/tools/ui/canister_ids.json b/tools/ui/canister_ids.json deleted file mode 100644 index 016284e12..000000000 --- a/tools/ui/canister_ids.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "didjs": { - "ic": "a4gq6-oaaaa-aaaab-qaa4q-cai" - } -} \ No newline at end of file diff --git a/tools/ui/dfx.json b/tools/ui/dfx.json deleted file mode 100644 index 9125fc637..000000000 --- a/tools/ui/dfx.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "canisters": { - "didjs": { - "type": "custom", - "candid": "src/didjs/didjs.did", - "wasm": "target/wasm32-unknown-unknown/canister/didjs.wasm", - "build": [ - "npm run build", - "cargo build --target wasm32-unknown-unknown --profile canister --package didjs", - "wasm-opt --strip-debug -Oz target/wasm32-unknown-unknown/canister/didjs.wasm -o target/wasm32-unknown-unknown/canister/didjs_opt.wasm" - ], - "metadata": [ - { - "name": "candid:service" - } - ] - } - }, - "version": 1 -} diff --git a/tools/ui/icp.yaml b/tools/ui/icp.yaml new file mode 100644 index 000000000..d00091fde --- /dev/null +++ b/tools/ui/icp.yaml @@ -0,0 +1,11 @@ +canisters: + - name: didjs + build: + steps: + - type: script + commands: + - npm run build + - cargo build --target wasm32-unknown-unknown --profile canister --package didjs + - wasm-opt --strip-debug -Oz target/wasm32-unknown-unknown/canister/didjs.wasm -o target/wasm32-unknown-unknown/canister/didjs_opt.wasm + - 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 + - cp target/wasm32-unknown-unknown/canister/didjs_opt.wasm "$ICP_WASM_OUTPUT_PATH" diff --git a/tools/ui/src/candid.html b/tools/ui/index.html similarity index 99% rename from tools/ui/src/candid.html rename to tools/ui/index.html index cd681f3de..12fb4aac2 100644 --- a/tools/ui/src/candid.html +++ b/tools/ui/index.html @@ -137,5 +137,6 @@