Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tech 450 update docs and domain #75

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ This section provides steps to set up and run the project locally. Follow the st
```

## Deploy the canisters
To simplify the deployment of the canisters we provide a script `deploy-civic.sh` you can find under `scripts`. To execute it make sure that you have run `npm install` beforehand inside the project.
To simplify the deployment of the canisters we provide a script `deploy-civic.sh` you can find under `scripts`. Make sure that you have run `npm install` beforehand inside the project.

If you want to set a specific admin principal, you can use the `ADMIN_PRINCIPAL_ID` environment variable. Otherwise it will use the principal of the `dfx identity` you are using to deploy.

Run the script with
```bash
./scripts/deploy-civic.sh local
```
Expand Down Expand Up @@ -144,7 +148,10 @@ This script performs the following tasks:
5. **Fetch Credentials**: Fetches and logs all credentials associated with a specified principal.

### Usage Instructions

Note that the script uses a dummy issuer principal which needs to be added to your canister config (inside the deploy/upgrade scripts):
```
authorized_issuers = vec { principal "'"$ADMIN_PRINCIPAL_ID"'"; principal "'"tglqb-kbqlj-to66e-3w5sg-kkz32-c6ffi-nsnta-vj2gf-vdcc5-5rzjk-jae"'" };
```
1. **Ensure Environment Variables are Set**: Make sure the `.env.local` file contains the necessary environment variables.

2. **Run the Script**:
Expand Down Expand Up @@ -198,9 +205,9 @@ Use an external ICP wallet or exchange to transfer cycles to your wallet address
```

## Deploy the canisters
You can use the deploy script to deploy the canisters to mainnet in one step. Be sure that you have deployed locally first ([see](https://github.com/civicteam/civic-icp-canister/tree/develop?tab=readme-ov-file#deploy-the-canisters)), this is necessary for it to work.
You can use the deploy script to deploy the canisters to mainnet in one step. It's necessary to deploy locally first ([more information](https://github.com/civicteam/civic-icp-canister/tree/develop?tab=readme-ov-file#deploy-the-canisters)):

Ensure you have run `npm install` in your project folder. Deploy locally with
Ensure you have run `npm install` in your project folder. Set your `ADMIN_PRINCIPAL_ID` environment variable if necessary and deploy locally with
```bash
./scripts/deploy-civic.sh local
```
Expand Down Expand Up @@ -289,3 +296,11 @@ The Civic Canister supports stable storage and the credential data and configura
DFX_NETWORK=network ./scripts/upgrade-civic.sh
```
setting network to `ic` or `local`. This also allows you to test the stable storage without having to change the canister code.

## Setting a custom domain
If you want to set a custom domain for the canister, you can pass it to the script with `--domain=your-domain.com`. Custom alternative frontends are also supported, edit `/scripts/upgrade-civic.sh`:
```
if [ -n "${CANISTER_DOMAIN:-}" ]; then
# add the alternative frontends you require for your canister here

```
4 changes: 3 additions & 1 deletion scripts/deploy-civic-backend.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ EOF
}

II_CANISTER_ID=
ADMIN_PRINCIPAL_ID=tglqb-kbqlj-to66e-3w5sg-kkz32-c6ffi-nsnta-vj2gf-vdcc5-5rzjk-jae
ADMIN_PRINCIPAL_ID="${ADMIN_PRINCIPAL_ID:-$(dfx identity get-principal)}"

while [[ $# -gt 0 ]]
do
Expand Down Expand Up @@ -94,6 +94,8 @@ echo "Using II canister: $II_CANISTER_ID" >&2
echo "Using issuer canister: $ISSUER_CANISTER_ID" >&2
echo "Using derivation origin: $ISSUER_DERIVATION_ORIGIN" >&2
echo "Using frontend hostname: $ISSUER_FRONTEND_HOSTNAME" >&2
echo "Using admin principal: $ADMIN_PRINCIPAL_ID"


# At the time of writing dfx outputs incorrect JSON with dfx ping (commas between object
# entries are missing).
Expand Down
9 changes: 6 additions & 3 deletions scripts/upgrade-civic-backend.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ EOF
}

II_CANISTER_ID=
ADMIN_PRINCIPAL_ID=tglqb-kbqlj-to66e-3w5sg-kkz32-c6ffi-nsnta-vj2gf-vdcc5-5rzjk-jae
ADMIN_PRINCIPAL_ID="${ADMIN_PRINCIPAL_ID:-$(dfx identity get-principal)}"

while [[ $# -gt 0 ]]
do
Expand Down Expand Up @@ -103,6 +103,8 @@ echo "Using II canister: $II_CANISTER_ID" >&2
echo "Using issuer canister: $ISSUER_CANISTER_ID" >&2
echo "Using derivation origin: $ISSUER_DERIVATION_ORIGIN" >&2
echo "Using frontend hostname: $ISSUER_FRONTEND_HOSTNAME" >&2
echo "Using admin principal: $ADMIN_PRINCIPAL_ID"


# At the time of writing dfx outputs incorrect JSON with dfx ping (commas between object
# entries are missing).
Expand All @@ -122,7 +124,8 @@ if [ "$DFX_NETWORK" = "local" ]; then
ALTERNATIVE_ORIGINS="\"http://$CIVIC_FRONTEND_CANISTER_ID.localhost:4943\""
else
if [ -n "${CANISTER_DOMAIN:-}" ]; then
ALTERNATIVE_ORIGINS="\"https://$CIVIC_FRONTEND_CANISTER_ID.icp0.io\", \"https://icp-sign.civic.me\""
# add the alternative frontends you require for your canister here - these are the ones for icp.civic.com
ALTERNATIVE_ORIGINS="\"https://$CIVIC_FRONTEND_CANISTER_ID.icp0.io\", \"https://icp-sign.civic.me\", \"https://icp-getpass.civic.com\""
else
ALTERNATIVE_ORIGINS="\"https://$CIVIC_FRONTEND_CANISTER_ID.icp0.io\""
fi
Expand Down Expand Up @@ -150,7 +153,7 @@ dfx deploy --upgrade-unchanged civic_canister_backend --network "$DFX_NETWORK" -
derivation_origin = "'"$ISSUER_DERIVATION_ORIGIN"'";
frontend_hostname = "'"$ISSUER_FRONTEND_HOSTNAME"'";
admin = principal "'"$ADMIN_PRINCIPAL_ID"'";
authorized_issuers = vec { principal "'"$ADMIN_PRINCIPAL_ID"'" };
authorized_issuers = vec { principal "'"$ADMIN_PRINCIPAL_ID"'"};
}
)'
# Revert changes
Expand Down
1 change: 1 addition & 0 deletions src/civic_canister_backend/dist/.well-known/ic-domains
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
icp.civic.com
Loading