Skip to content
Merged
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
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ dist/
*.tsbuildinfo
coverage/

# icp-cli / dfx state
.icp/
# icp-cli / dfx state. `.icp/data/` holds the mainnet canister ids and is
# committed, as icp-cli advises: without it, a deploy creates new canisters.
.icp/cache/
.dfx/

# Environment
Expand Down
4 changes: 4 additions & 0 deletions .icp/data/mappings/production.ids.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"backend": "xeka7-ryaaa-aaaal-qb57a-cai",
"frontend": "4lidq-zqaaa-aaaap-abkbq-cai"
}
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,17 @@ backend uses it automatically.
## Deploying to mainnet

```bash
icp deploy -e production
icp deploy -e production --no-create # both canisters
icp deploy frontend -e production --no-create # the frontend only
```

The deploy upgrades the canisters recorded in `.icp/data/mappings/production.ids.json`: backend
`xeka7-ryaaa-aaaal-qb57a-cai` and frontend `4lidq-zqaaa-aaaap-abkbq-cai`. `--no-create` makes it stop
rather than create a canister that is not recorded there. Do not deploy with `-e ic`: that is icp-cli's
built-in mainnet environment, which records none of these ids, so it creates new canisters. A new
frontend is a new origin, which gives every user a new principal, and the custom domain would still
point at the old one.

The `production` environment uses the vetKD key `key_1`, keeps the AI assistant off and sets strict
limits (`icp.yaml`). The frontend reads the backend's id from the asset canister's `ic_env` cookie on
`*.icp0.io`, and from `frontend/src/lib/origins.ts` on a custom domain ([Custom domain](#custom-domain)).
Expand Down
24 changes: 24 additions & 0 deletions frontend/tests/production.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* B3Note's mainnet canisters (README, "Deploying to mainnet"). icp-cli deploys
* the `production` environment to the ids in `.icp/data/mappings`, and creates
* a new canister for any it cannot find there. A new frontend is a new origin,
* which gives every user a new principal, so the ids recorded there must stay
* the ones the app signs in for and calls.
*/
import { readFileSync } from "node:fs"
import { dirname, join } from "node:path"
import { fileURLToPath } from "node:url"
import { describe, expect, it } from "vitest"
import { PRODUCTION } from "../src/lib/origins"

const root = join(dirname(fileURLToPath(import.meta.url)), "../..")

describe("production's canisters", () => {
it("are recorded for icp-cli as the ones the app signs in for and calls", () => {
const ids = JSON.parse(readFileSync(join(root, ".icp/data/mappings/production.ids.json"), "utf8"))
expect(ids).toEqual({
backend: PRODUCTION.backend,
frontend: new URL(PRODUCTION.origin).hostname.replace(/\.icp0\.io$/, ""),
})
})
})
3 changes: 2 additions & 1 deletion icp.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# yaml-language-server: $schema=https://github.com/dfinity/icp-cli/raw/refs/tags/v1.6.0/docs/schemas/icp-yaml-schema.json
#
# B3Note: `icp network start -d && icp deploy` for a local deployment,
# `icp deploy -e production` for mainnet.
# `icp deploy -e production --no-create` for mainnet, never `-e ic`
# (README, "Deploying to mainnet").

canisters:
- name: backend
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dev": "pnpm --dir frontend dev",
"dev:pocketic": "pnpm --dir frontend dev:pocketic",
"deploy": "icp deploy",
"deploy:production": "icp deploy -e production"
"deploy:production": "icp deploy -e production --no-create"
},
"packageManager": "pnpm@10.28.0"
}
Loading