Skip to content

Commit 7e7075a

Browse files
authored
chore: CRP-2834 use dfx deploy to simplify setup (#134)
1 parent d8bb5d4 commit 7e7075a

14 files changed

Lines changed: 56 additions & 113 deletions

File tree

backend/rs/canisters/ic_vetkeys_manager_canister/Makefile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,3 @@ compile-wasm:
1010
extract-candid: compile-wasm
1111
candid-extractor $(ROOT_DIR)/target/wasm32-unknown-unknown/release/ic_vetkeys_manager_canister.wasm > ic_vetkeys_manager_canister.did
1212

13-
.PHONY: export-cmd
14-
.SILENT: export-cmd
15-
export-cmd:
16-
CANISTER_ID_IC_VETKEYS_MANAGER_CANISTER=$(shell dfx canister id ic_vetkeys_manager_canister); \
17-
CMD="export CANISTER_ID_IC_VETKEYS_MANAGER_CANISTER=$${CANISTER_ID_IC_VETKEYS_MANAGER_CANISTER}"; \
18-
echo "$${CMD}"

examples/basic_ibe/deploy_locally.sh

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,11 @@ dfx --version >> /dev/null
88
# Run `dfx` if it is not already running.
99
dfx ping &> /dev/null || dfx start --background --clean >> /dev/null
1010

11-
# Deploy the Internet Identity canister and export the environment variable of
12-
# the canister ID.
13-
dfx deps pull && dfx deps init && dfx deps deploy &&
14-
export CANISTER_ID_INTERNET_IDENTITY=rdmx6-jaaaa-aaaaa-aaadq-cai
11+
# Deploy the Internet Identity canister.
12+
dfx deps pull && dfx deps init && dfx deps deploy
1513

16-
dfx canister create basic_ibe
14+
# Deploy backend canister.
1715
dfx deploy --argument '("dfx_test_key")' basic_ibe
1816

19-
# Store environment variables for the frontend.
20-
echo "DFX_NETWORK=$DFX_NETWORK" > frontend/.env
21-
echo "CANISTER_ID_BASIC_IBE=$(dfx canister id basic_ibe)" >> frontend/.env
22-
echo "CANISTER_ID_INTERNET_IDENTITY=$CANISTER_ID_INTERNET_IDENTITY" >> frontend/.env
23-
24-
# Build frontend.
25-
pushd frontend
26-
npm i
27-
npm run build
28-
popd
29-
30-
# Deploy canisters.
31-
dfx deploy
17+
# Deploy frontend canister.
18+
dfx deploy www

examples/basic_ibe/dfx.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@
1616
"id": "rdmx6-jaaaa-aaaaa-aaadq-cai"
1717
},
1818
"www": {
19+
"dependencies": ["basic_ibe"],
20+
"build": ["npm i && cd frontend && npm run build"],
1921
"frontend": {
2022
"entrypoint": "frontend/dist/index.html"
2123
},
2224
"source": ["frontend/dist/"],
23-
"type": "assets"
25+
"type": "assets",
26+
"output_env_file": "frontend/.env"
2427
}
2528
},
2629
"networks": {

examples/basic_ibe/frontend/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ export function login(client: AuthClient) {
270270
identityProvider:
271271
process.env.DFX_NETWORK === "ic"
272272
? "https://identity.ic0.app/#authorize"
273-
: `http://${process.env.CANISTER_ID_INTERNET_IDENTITY}.localhost:8000/#authorize`,
273+
: `http://rdmx6-jaaaa-aaaaa-aaadq-cai.localhost:8000/#authorize`,
274274
onSuccess: () => {
275275
myPrincipal = client.getIdentity().getPrincipal();
276276
updateUI(true);

examples/basic_timelock_ibe/deploy_locally.sh

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,11 @@ dfx --version >> /dev/null
88
# Run `dfx` if it is not already running.
99
dfx ping &> /dev/null || dfx start --background --clean >> /dev/null
1010

11-
# Deploy the Internet Identity canister and export the environment variable of
12-
# the canister ID.
13-
dfx deps pull && dfx deps init && dfx deps deploy &&
14-
export CANISTER_ID_INTERNET_IDENTITY=rdmx6-jaaaa-aaaaa-aaadq-cai
11+
# Deploy the Internet Identity canister.
12+
dfx deps pull && dfx deps init && dfx deps deploy
1513

16-
dfx canister create basic_timelock_ibe
14+
# Deploy backend canister.
1715
dfx deploy --argument '("dfx_test_key")' basic_timelock_ibe
1816

19-
# Store environment variables for the frontend.
20-
echo "DFX_NETWORK=$DFX_NETWORK" > frontend/.env
21-
echo "CANISTER_ID_BASIC_TIMELOCK_IBE=$(dfx canister id basic_timelock_ibe)" >> frontend/.env
22-
echo "CANISTER_ID_INTERNET_IDENTITY=$CANISTER_ID_INTERNET_IDENTITY" >> frontend/.env
23-
24-
npm i
25-
26-
# Build frontend.
27-
pushd frontend
28-
npm run build
29-
popd
30-
31-
# Deploy canisters.
32-
pushd backend
33-
dfx deploy
34-
popd
17+
# Deploy frontend canister.
18+
dfx deploy www

examples/basic_timelock_ibe/dfx.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@
1616
"id": "rdmx6-jaaaa-aaaaa-aaadq-cai"
1717
},
1818
"www": {
19+
"dependencies": ["basic_timelock_ibe"],
20+
"build": ["npm i && cd frontend && npm run build"],
1921
"frontend": {
2022
"entrypoint": "frontend/dist/index.html"
2123
},
2224
"source": ["frontend/dist/"],
23-
"type": "assets"
25+
"type": "assets",
26+
"output_env_file": "frontend/.env"
2427
}
2528
},
2629
"networks": {

examples/basic_timelock_ibe/frontend/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export function login(client: AuthClient) {
5656
identityProvider:
5757
process.env.DFX_NETWORK === "ic"
5858
? "https://identity.ic0.app/#authorize"
59-
: `http://${process.env.CANISTER_ID_INTERNET_IDENTITY}.localhost:8000/#authorize`,
59+
: `http://rdmx6-jaaaa-aaaaa-aaadq-cai.localhost:8000/#authorize`,
6060
onSuccess: () => {
6161
myPrincipal = client.getIdentity().getPrincipal();
6262
updateUI(true);

examples/password_manager/deploy_locally.sh

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,11 @@ dfx --version >> /dev/null
88
# Run `dfx` if it is not already running.
99
dfx ping &> /dev/null || dfx start --background --clean >> /dev/null
1010

11-
# Deploy the Internet Identity canister and export the environment variable of
12-
# the canister ID.
13-
dfx deps pull && dfx deps init && dfx deps deploy &&
14-
export CANISTER_ID_INTERNET_IDENTITY=rdmx6-jaaaa-aaaaa-aaadq-cai
11+
# Deploy the Internet Identity canister.
12+
dfx deps pull && dfx deps init && dfx deps deploy
1513

1614
# Deploy the backend canister.
17-
pushd ../../backend/rs/canisters/ic_vetkeys_encrypted_maps_canister
18-
dfx deploy --argument '("dfx_test_key")' ic_vetkeys_encrypted_maps_canister
19-
export CANISTER_ID_IC_VETKEYS_ENCRYPTED_MAPS_CANISTER=$(dfx canister id ic_vetkeys_encrypted_maps_canister)
20-
popd
21-
22-
# Store environment variables for the frontend.
23-
echo "DFX_NETWORK=$DFX_NETWORK" > frontend/.env
24-
echo "CANISTER_ID_IC_VETKEYS_ENCRYPTED_MAPS_CANISTER=$CANISTER_ID_IC_VETKEYS_ENCRYPTED_MAPS_CANISTER" >> frontend/.env
25-
echo "CANISTER_ID_INTERNET_IDENTITY=$CANISTER_ID_INTERNET_IDENTITY" >> frontend/.env
26-
27-
# Build frontend.
28-
pushd frontend
29-
npm i
30-
npm run build
31-
popd
15+
dfx deploy --argument '("dfx_test_key")' ic_vetkeys_encrypted_maps_canister
3216

3317
# Deploy the frontend canister.
3418
dfx deploy www

examples/password_manager/dfx.json

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
{
2-
"canisters": {
3-
"ic_vetkeys_encrypted_maps_canister": {
4-
"candid": "ic_vetkeys_encrypted_maps_canister.did",
5-
"package": "ic-vetkeys-encrypted-maps-canister",
6-
"type": "rust"
2+
"canisters": {
3+
"ic_vetkeys_encrypted_maps_canister": {
4+
"candid": "../../backend/rs/canisters/ic_vetkeys_encrypted_maps_canister/ic_vetkeys_encrypted_maps_canister.did",
5+
"package": "ic-vetkeys-encrypted-maps-canister",
6+
"type": "rust"
7+
},
8+
"internet-identity": {
9+
"type": "pull",
10+
"id": "rdmx6-jaaaa-aaaaa-aaadq-cai"
11+
},
12+
"www": {
13+
"dependencies": ["ic_vetkeys_encrypted_maps_canister"],
14+
"build": ["npm i && cd frontend && npm run build"],
15+
"frontend": {
16+
"entrypoint": "frontend/dist/index.html"
717
},
8-
"internet-identity": {
9-
"type": "pull",
10-
"id": "rdmx6-jaaaa-aaaaa-aaadq-cai"
11-
},
12-
"www": {
13-
"frontend": {
14-
"entrypoint": "frontend/dist/index.html"
15-
},
16-
"source": [
17-
"frontend/dist/"
18-
],
19-
"type": "assets"
20-
}
18+
"source": ["frontend/dist/"],
19+
"type": "assets",
20+
"output_env_file": "frontend/.env"
2121
}
22-
}
22+
}
23+
}

examples/password_manager/frontend/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ frontend implementation that uses all defaults from the SDK.
77
## Step 1: Deploy `encrypted_maps_example` canister and the internet identity canister.
88

99
## Step 2: Tell `frontend` what canisters to communicate with, so the following environment variables must be defined. For a local deployment, one can run `deploy_locally.sh` from that folder.
10-
* `CANISTER_ID_INTERNET_IDENTITY`
1110
* `CANISTER_ID_IC_VETKEYS_ENCRYPTED_MAPS_CANISTER`
1211

1312
## Step 3: Deploy frontend. This returns a link that can be used to access the frontend from the asset canister.

0 commit comments

Comments
 (0)