Skip to content

Commit a58644e

Browse files
Web3NLclaude
andcommitted
fix: consolidate icp.yaml at repo root for shared network state
- Move icp.yaml back to root combining canisters + examples canisters (paths updated to reference canisters/ and examples/ subdirs) - Remove canisters/icp.yaml and examples/icp.yaml - Remove icp_canisters/icp_examples helpers; all scripts use bare icp - Centralize REPO_ROOT in constants.sh, sourced by all scripts - Simplify .gitignore: ignore all .icp dirs, untrack mainnet.ids.json The icp CLI stores a global port descriptor at ~/Library/Caches/org.dfinity.icp-cli/port-descriptors/<port>.json mapping ports to project directories. Split icp.yaml files cannot share a network across projects without symlinks. A single root icp.yaml is the correct solution. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 5c33149 commit a58644e

11 files changed

Lines changed: 54 additions & 82 deletions

.gitignore

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,7 @@ build/
5555

5656
# dfx / icp-cli files
5757
.dfx
58-
.icp/*
59-
!.icp/data/
60-
.icp/data/*
61-
!.icp/data/mappings/
62-
.icp/data/mappings/*
63-
!.icp/data/mappings/*.ids.json
58+
.icp
6459

6560
# Claude
6661
.claude

.icp/data/mappings/mainnet.ids.json

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

examples/icp.yaml

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

canisters/icp.yaml renamed to icp.yaml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,31 @@ canisters:
55
recipe:
66
type: "@dfinity/asset-canister@v2.1.0"
77
configuration:
8-
dir: my-canister-app/build
8+
dir: canisters/my-canister-app/build
99

1010
- name: wasm-registry
1111
recipe:
1212
type: "@dfinity/rust@v3.0.0"
1313
configuration:
1414
package: wasm-registry
1515
shrink: true
16-
candid: wasm-registry/wasm-registry.did
16+
candid: canisters/wasm-registry/wasm-registry.did
17+
18+
- name: my-hello-world
19+
recipe:
20+
type: "@dfinity/rust@v3.0.0"
21+
configuration:
22+
package: my-hello-world
23+
shrink: true
24+
candid: examples/my-hello-world/src/backend/my-hello-world.did
25+
26+
- name: my-notepad
27+
recipe:
28+
type: "@dfinity/rust@v3.0.0"
29+
configuration:
30+
package: my-notepad
31+
shrink: true
32+
candid: examples/my-notepad/src/backend/my-notepad.did
1733

1834
networks:
1935
- name: local
@@ -26,7 +42,7 @@ networks:
2642
environments:
2743
- name: local
2844
network: local
29-
canisters: [my-canister-app, wasm-registry]
45+
canisters: [my-canister-app, wasm-registry, my-hello-world, my-notepad]
3046

3147
- name: mainnet
3248
network: ic

scripts/constants.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#!/bin/bash
22
# Shared constants for build/test scripts
33

4+
# Repository root (constants.sh lives in scripts/)
5+
export REPO_ROOT
6+
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
7+
48
# Cycle amounts
59
export CANISTER_INITIAL_CYCLES="1000000000000"
610

@@ -12,8 +16,8 @@ export WASM_REGISTRY_CANISTER="wasm-registry"
1216
export DAPP_ORIGIN_VITE="http://localhost:5173"
1317

1418
# Resolve DAPP_ORIGIN_CANISTER from test.env if it exists (set during setup)
15-
if [ -f "tests/test.env" ]; then
16-
HELLO_WORLD_ID=$(grep VITE_MY_HELLO_WORLD_CANISTER_ID tests/test.env | cut -d '=' -f2 || true)
19+
if [ -f "$REPO_ROOT/tests/test.env" ]; then
20+
HELLO_WORLD_ID=$(grep VITE_MY_HELLO_WORLD_CANISTER_ID "$REPO_ROOT/tests/test.env" | cut -d '=' -f2 || true)
1721
if [ -n "$HELLO_WORLD_ID" ]; then
1822
export DAPP_ORIGIN_CANISTER="http://${HELLO_WORLD_ID}.localhost:8080"
1923
fi

scripts/deploy-app.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fi
2828

2929
# Deploy the app (ICP_NETWORK=ic triggers production build)
3030
echo "🚢 Deploying to IC..."
31-
(cd canisters && ICP_NETWORK=ic icp deploy my-canister-app -e mainnet --identity web3nl)
31+
ICP_NETWORK=ic icp deploy my-canister-app -e mainnet --identity web3nl
3232

3333
# Get current commit hash after successful deploy
3434
COMMIT_HASH=$(git rev-parse HEAD)

scripts/run-test-e2e.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ DASHBOARD_VITE_SERVER=true npx playwright test \
1515
# Swap II principal to canister-served origin for the second batch
1616
PRINCIPAL_CANISTER=$(cat test-output/derived-ii-principal-canister.txt)
1717
echo "Switching II principal to canister-served origin for second test batch..."
18-
REPO_ROOT="$(dirname "$0")/.."
19-
(cd "$REPO_ROOT/examples" && icp canister call "$HELLO_WORLD_CANISTER" manage_ii_principal "(variant { Set = principal \"$PRINCIPAL_CANISTER\" })" -e local --identity ident-1)
18+
icp canister call "$HELLO_WORLD_CANISTER" manage_ii_principal "(variant { Set = principal \"$PRINCIPAL_CANISTER\" })" -e local --identity ident-1
2019

2120
# Batch 2: Canister-served dashboard + hello-world frontend
2221
npx playwright test \

scripts/setup-dashboard-dev-env.sh

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@ set -euo pipefail
55
source "$(dirname "$0")/constants.sh"
66

77
# Ensure we're in the project root directory
8-
ROOT="$(dirname "$0")/.."
9-
cd "$ROOT"
10-
11-
# Helper functions to run icp commands in the correct project context
12-
icp_examples() { (cd examples && icp "$@"); }
13-
icp_canisters() { (cd canisters && icp "$@"); }
8+
cd "$REPO_ROOT"
149

1510
echo "Setting up dashboard development environment..."
1611

@@ -19,11 +14,11 @@ echo "Deploying $HELLO_WORLD_CANISTER canister..."
1914
# Build hello-world frontend with test env vars (identity provider URL)
2015
# before the Rust canister embeds it via include_dir!
2116
npm run build --workspace=my-hello-world-frontend
22-
icp_examples deploy "$HELLO_WORLD_CANISTER" -e local --identity ident-1 --cycles "$CANISTER_INITIAL_CYCLES"
17+
icp deploy "$HELLO_WORLD_CANISTER" -e local --identity ident-1 --cycles "$CANISTER_INITIAL_CYCLES"
2318
./scripts/copy-example-wasm.sh
2419

2520
# Update test.env with the hello-world canister ID
26-
HELLO_WORLD_ID=$(icp_examples canister status my-hello-world -e local --id-only)
21+
HELLO_WORLD_ID=$(icp canister status my-hello-world -e local --id-only)
2722
if ! grep -q "VITE_MY_HELLO_WORLD_CANISTER_ID" tests/test.env 2>/dev/null; then
2823
echo "VITE_MY_HELLO_WORLD_CANISTER_ID=${HELLO_WORLD_ID}" >> tests/test.env
2924
fi
@@ -42,17 +37,17 @@ echo "Reading principals from both files..."
4237
PRINCIPAL_VITE=$(cat test-output/derived-ii-principal-vite.txt)
4338
PRINCIPAL_CANISTER=$(cat test-output/derived-ii-principal-canister.txt)
4439

45-
IDENT1=$(icp_canisters identity principal --identity ident-1)
40+
IDENT1=$(icp identity principal --identity ident-1)
4641

4742
echo "Setting controllers for $HELLO_WORLD_CANISTER canister..."
48-
icp_examples canister settings update "$HELLO_WORLD_CANISTER" -e local --identity ident-1 \
43+
icp canister settings update "$HELLO_WORLD_CANISTER" -e local --identity ident-1 \
4944
--set-controller "$CANISTER_ID" \
5045
--set-controller "$PRINCIPAL_VITE" \
5146
--set-controller "$PRINCIPAL_CANISTER" \
5247
--set-controller "$IDENT1" \
5348
-f
5449

5550
echo "Setting authorized Internet Identity principal (Vite origin for first e2e batch)..."
56-
icp_examples canister call "$HELLO_WORLD_CANISTER" manage_ii_principal "(variant { Set = principal \"$PRINCIPAL_VITE\" })" -e local --identity ident-1
51+
icp canister call "$HELLO_WORLD_CANISTER" manage_ii_principal "(variant { Set = principal \"$PRINCIPAL_VITE\" })" -e local --identity ident-1
5752

5853
echo "✓ Dashboard development environment setup complete"

scripts/upload-wasm-to-registry.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,13 @@ echo "Uploading $NAME v$VERSION ($FILE_SIZE bytes) to wasm-registry..."
3333
# Encode argument as Candid binary hex written to a temp file
3434
# (hex string is ~1.6MB which exceeds ARG_MAX for command-line args)
3535
SCRIPT_DIR="$(dirname "$0")"
36+
3637
TMPFILE=$(mktemp)
3738
echo "Encoding Candid argument to $TMPFILE..."
3839
node "$SCRIPT_DIR/encode-upload-arg.mjs" "$NAME" "$DESCRIPTION" "$VERSION" "$WASM_GZ_PATH" > "$TMPFILE"
3940

4041
echo "Calling wasm-registry upload_wasm..."
41-
# Run from canisters/ where the wasm-registry icp.yaml lives
42-
REPO_ROOT="$(dirname "$0")/.."
43-
(cd "$REPO_ROOT/canisters" && icp canister call wasm-registry upload_wasm "$TMPFILE" "${EXTRA_ARGS[@]}")
42+
icp canister call wasm-registry upload_wasm "$TMPFILE" "${EXTRA_ARGS[@]}"
4443
rm -f "$TMPFILE"
4544

4645
echo "Upload complete!"

scripts/write-test-env.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ set -euo pipefail
55
# The NNS II (rdmx6-jaaaa-aaaaa-aaadq-cai) is provisioned automatically by
66
# the local network (nns: true, ii: true in icp.yaml).
77

8-
# Ensure we're in the project root directory
9-
cd "$(dirname "$0")/.."
8+
# Source shared constants
9+
source "$(dirname "$0")/constants.sh"
10+
11+
cd "$REPO_ROOT"
1012

1113
II_CANISTER_ID="rdmx6-jaaaa-aaaaa-aaadq-cai"
12-
HELLO_WORLD_ID=$((cd examples && icp canister status my-hello-world -e local --id-only) 2>/dev/null || echo "")
13-
APP_CANISTER_ID=$((cd canisters && icp canister status my-canister-app -e local --id-only) 2>/dev/null || echo "")
14+
HELLO_WORLD_ID=$(icp canister status my-hello-world -e local --id-only 2>/dev/null || echo "")
15+
APP_CANISTER_ID=$(icp canister status my-canister-app -e local --id-only 2>/dev/null || echo "")
1416

1517
# Write test.env with discovered canister IDs
1618
cat > tests/test.env <<EOF
@@ -29,7 +31,7 @@ if [ -n "$APP_CANISTER_ID" ]; then
2931
fi
3032

3133
# Add wasm-registry canister ID if it exists
32-
WASM_REGISTRY_ID=$((cd canisters && icp canister status wasm-registry -e local --id-only) 2>/dev/null || echo "")
34+
WASM_REGISTRY_ID=$(icp canister status wasm-registry -e local --id-only 2>/dev/null || echo "")
3335
if [ -n "$WASM_REGISTRY_ID" ]; then
3436
echo "VITE_WASM_REGISTRY_CANISTER_ID=${WASM_REGISTRY_ID}" >> tests/test.env
3537
fi

0 commit comments

Comments
 (0)