chore(examples): migrate all 7 examples to icp-cli and @dfinity/vetkeys#366
Draft
marc0olo wants to merge 25 commits intochore/migrate-to-icp-sdkfrom
Draft
chore(examples): migrate all 7 examples to icp-cli and @dfinity/vetkeys#366marc0olo wants to merge 25 commits intochore/migrate-to-icp-sdkfrom
marc0olo wants to merge 25 commits intochore/migrate-to-icp-sdkfrom
Conversation
…t/rust (#364) Bumps [rand](https://github.com/rust-random/rand) from 0.9.2 to 0.9.3. <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/rust-random/rand/blob/0.9.3/CHANGELOG.md">rand's changelog</a>.</em></p> <blockquote> <h2>[0.9.3] — 2026-02-11</h2> <p>This release back-ports a fix from v0.10. See also <a href="https://redirect.github.com/rust-random/rand/issues/1763">#1763</a>.</p> <h3>Changes</h3> <ul> <li>Deprecate feature <code>log</code> (<a href="https://redirect.github.com/rust-random/rand/issues/1764">#1764</a>)</li> <li>Replace usages of <code>doc_auto_cfg</code> (<a href="https://redirect.github.com/rust-random/rand/issues/1764">#1764</a>)</li> </ul> <p><a href="https://redirect.github.com/rust-random/rand/issues/1763">#1763</a>: <a href="https://redirect.github.com/rust-random/rand/pull/1763">rust-random/rand#1763</a></p> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/rust-random/rand/commit/1aeee9f4c506f9f737c6c37c169ccdc365bfbabf"><code>1aeee9f</code></a> Prepare v0.9.3: deprecate feature <code>log</code> (<a href="https://redirect.github.com/rust-random/rand/issues/1764">#1764</a>)</li> <li><a href="https://github.com/rust-random/rand/commit/98473ee6f9b44eb85154b59b67adade7f2a9b8a1"><code>98473ee</code></a> Prepare rand 0.9.2 (<a href="https://redirect.github.com/rust-random/rand/issues/1648">#1648</a>)</li> <li><a href="https://github.com/rust-random/rand/commit/031a1f5589e487ce95972cb3acc0833ef64cfc10"><code>031a1f5</code></a> <code>examples/print-next.rs</code> (<a href="https://redirect.github.com/rust-random/rand/issues/1647">#1647</a>)</li> <li><a href="https://github.com/rust-random/rand/commit/6cb75ee59eda73967b6a3cae4fdcf2c21f6e0e4e"><code>6cb75ee</code></a> Make UniformUsize serializable (<a href="https://redirect.github.com/rust-random/rand/issues/1646">#1646</a>)</li> <li><a href="https://github.com/rust-random/rand/commit/0c955c5b7a079bc2fe67fe946a8deb46c4bc58d8"><code>0c955c5</code></a> Add some tests for BlockRng, BlockRng64 and Xoshiro RNGs (<a href="https://redirect.github.com/rust-random/rand/issues/1639">#1639</a>)</li> <li><a href="https://github.com/rust-random/rand/commit/204084a35fc7289e9a38575fdd80869818484517"><code>204084a</code></a> Fix: Remove accidental editor swap file (<a href="https://redirect.github.com/rust-random/rand/issues/1636">#1636</a>)</li> <li><a href="https://github.com/rust-random/rand/commit/86262ac190ec20a79293607fb2347dc74c99122e"><code>86262ac</code></a> Deprecate rand::rngs::mock module and StepRng (<a href="https://redirect.github.com/rust-random/rand/issues/1634">#1634</a>)</li> <li><a href="https://github.com/rust-random/rand/commit/a6e217f4a3ce78223a59cc1ff9afb2b5e589d785"><code>a6e217f</code></a> Update statrs link (<a href="https://redirect.github.com/rust-random/rand/issues/1630">#1630</a>)</li> <li><a href="https://github.com/rust-random/rand/commit/db993ec12676119251eaf9f2cba8389a1b07abef"><code>db993ec</code></a> Prepare rand v0.9.1 (<a href="https://redirect.github.com/rust-random/rand/issues/1629">#1629</a>)</li> <li><a href="https://github.com/rust-random/rand/commit/3057641020408f64a4618b1c582cad45a9304811"><code>3057641</code></a> Remove zerocopy from rand (<a href="https://redirect.github.com/rust-random/rand/issues/1579">#1579</a>)</li> <li>Additional commits viewable in <a href="https://github.com/rust-random/rand/compare/rand_core-0.9.2...0.9.3">compare view</a></li> </ul> </details> <br /> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/dfinity/vetkeys/network/alerts). </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
62a28d2 to
43c74d3
Compare
…icp-sdk/core - Replace @dfinity/agent, @dfinity/candid, @dfinity/principal, @dfinity/identity with @icp-sdk/core - DefaultEncryptedMapsClient and DefaultKeyManagerClient constructors now accept HttpAgent directly instead of HttpAgentOptions (BREAKING — see CHANGELOG.md) - Remove generated index.js/index.d.ts wrappers, import idlFactory directly - Update test helpers to use HttpAgent.create() from @icp-sdk/core/agent - Update local dev network port from 4943 to 8000 - Test scripts migrated from dfx CLI to icp CLI Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Replace dfx install with icp-cli in provision-darwin.sh and provision-linux.sh - Add actions/setup-node v22 step to frontend.yml and all example workflows (required by icp-cli which needs Node.js >=22) - Replace dfx.json with icp.yaml in backend Motoko and Rust canisters - Update backend Makefiles to use icp instead of dfx - Update Rust integration tests to use icp canister IDs - Remove root dfx.json Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Fix explicit .js extension on idlFactory import in encrypted_maps_canister.ts (vite resolved extensionless ".did" to the raw Candid file instead of the generated .did.js binding) - Update backend-motoko.yml to use provision-frontend-*.sh (icp-cli) and add setup-node@22, required for `icp build` in the Makefiles Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add [toolchain] moc = "1.5.0" to backend/mo/ic_vetkeys/mops.toml so mops test resolves the compiler without falling back to dfx cache show - Set GITHUB_TOKEN env on test steps in frontend.yml and backend-motoko.yml to avoid 403 rate limiting when icp fetches the network launcher version from the GitHub API Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…rtifacts - Remove dfx-generated index.js, index.d.ts, and raw .did files from both declaration directories (ic_vetkeys_encrypted_maps_canister and ic_vetkeys_manager_canister). These used @dfinity/agent and dfx-specific env vars (DFX_NETWORK, CANISTER_ID_*) and are no longer needed now that the library uses @icp-sdk/core. - Fix encrypted_maps_canister.ts: split idlFactory (value import) from _SERVICE/AccessRights/ByteBuf/EncryptedMapData (type-only imports via import type). The .did.js module only exports idlFactory and init at runtime; importing types as values would fail under strict ESM. - Fix key_manager/index.ts: change import source from the raw Candid text file (.did) to the generated JS module (.did.js), and use import type for type-only symbols. - Fix make_did_bindings.sh: add explicit / path separator between DIR and NAME so the function is robust if DIR is passed without a trailing slash. - Fix provision-frontend-linux.sh: remove sudo from rustup install; sudo installs into root's home while subsequent steps add $HOME/.cargo/bin (runner's home) to PATH, causing cargo to not be found. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ate limits npm run test calls icp network start + icp deploy; icp-cli reads ICP_CLI_GITHUB_TOKEN (not GITHUB_TOKEN) when fetching the network launcher. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ea68c6f to
d01ed07
Compare
43c74d3 to
5a13616
Compare
key_manager_canister.ts and encrypted_maps/index.ts were importing type-only symbols (_SERVICE, AccessRights, ByteBuf) as runtime values from .did.js files that only export idlFactory and init. Also fixes encrypted_maps/index.ts which was still referencing the bare .did file instead of .did.js. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
5a13616 to
8ee818e
Compare
… guards - .github/workflows/frontend.yml: path filter pointed at non-existent `frontend_ic_vetkeys.yml`; change to `frontend.yml` so the workflow re-triggers on changes to itself. - test files: process.env.CANISTER_ID_* is `string | undefined`; add explicit guard that throws a clear error when the env var is missing instead of passing undefined to the constructor. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
HttpAgent.createSync() is not deprecated; only the new HttpAgent(options) constructor is. Update the wording accordingly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Use BTreeMap instead of Vec for keyvals so that if random_map_key generates a duplicate key, the expected value is updated to match the last insert (which is what the canister stores). Previously a collision caused the Vec to hold two entries for the same key with different expected values, making the per-key assertion fail non-deterministically. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…r tests Standardise on the icp-cli/PocketIC key name now that dfx is no longer used. The library retains backward-compatible handling of dfx_test_key for existing deployments. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace @dfinity/auth-client and @dfinity/principal dependencies with @icp-sdk/auth and @icp-sdk/core across all 7 example frontends. Reference @dfinity/vetkeys via local file: path pending npm release. Also add dev:motoko / dev:rust npm scripts, update vite configs to use canister environment from @icp-sdk/core, update gen_bindings.sh scripts to use icp-cli, refresh package-lock.json files, update declaration files and encrypted_maps_canister.ts to match current backend interface, remove deprecated baseUrl from tsconfig, rename tailwind.config.cjs to .mjs in password_manager examples (package.json has "type":"module"), and remove window.global polyfill (no longer needed with icp-sdk). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace dfx.json with icp.yaml for all Motoko and Rust backends. Update mops.toml files to pin moc 1.5.0, remove --enhanced-orthogonal- persistence flag (now the default since moc 0.15.0), and add vetkeys Motoko library dependency. Update Rust backend for password_manager_with_metadata to use the current ic-vetkeys crate interface. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…dk APIs - Rename all canister variables/functions to actor (e.g. getBasicIbeCanister → getBasicIbeActor) for naming consistency across all basic examples - Remove window.global polyfill (no longer needed with @icp-sdk/core) - Remove `as any` cast from IbeIdentity.fromPrincipal (types now resolve) - Fix actor caching in encrypted_chat auth store: create actor once on login and store in state instead of re-instantiating on every call - Fix DerivedKeyMaterial.fromCryptoKey() missing await (method is now async) - Add required associatedData arg to encryptMessage/decryptMessage calls in encrypted_chat symmetricRatchet.ts - Rewrite encrypted_notes crypto.ts: deriveAesGcmCryptoKey is now private; use encryptMessage/decryptMessage on DerivedKeyMaterial directly; cache CryptoKey in IndexedDB (structured-clone safe) and reconstruct DerivedKeyMaterial.fromCryptoKey() on retrieval - Replace HttpAgent.createSync() with async HttpAgent.create() everywhere - Remove unused hex_encode, fix hex_decode to return Uint8Array - Migrate all components and services to @icp-sdk/core identity/agent APIs Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace dfx start/deploy with icp network start / icp deploy, remove DFX_VERSION env var, add Node.js 22 setup step, and update provisioning scripts to install icp-cli rather than dfx. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Update all internetcomputer.org/docs/ links to docs.internetcomputer.org/ - Replace IC SDK install links with ICP CLI (cli.internetcomputer.org) references - Add `icp network stop` instructions to local deployment sections in all READMEs - Comment out icp.ninja badges (icp.ninja currently requires dfx; will re-enable once icp.ninja supports icp-cli) - Fix broken SPEC.md anchor (#state-cache → #encrypted-symmetric-ratchet-state-cache) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tions - encrypted_chat/rust/icp.yaml: missing Rust backend icp.yaml - encrypted_notes_dapp_vetkd/frontend/index.html: new Vite entry point (replaces rollup-based public/index.html) - encrypted_notes_dapp_vetkd/frontend/svelte.config.js: Svelte preprocessor config for Vite - encrypted_notes_dapp_vetkd/rust/backend/Makefile: helper targets for Rust backend - password_manager/frontend/scripts/gen_bindings.sh: binding generation script - password_manager*/frontend/tailwind.config.mjs: renamed from .cjs to .mjs (package.json has "type":"module") Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…lows icp fetches the network launcher version from the GitHub API; without GITHUB_TOKEN the unauthenticated rate limit causes 403 errors in CI. Mirrors the pattern already applied in frontend.yml and backend-motoko.yml in the base branch. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ops.toml The toolchain section was added in the base branch (2c7813b) to allow mops test to resolve the Motoko compiler without falling back to `dfx cache show` (dfx is not installed). Our patch overwrote the file with the version from all-changes which was missing this section, causing backend-motoko CI jobs to fail with "dfx: not found". Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…e limiting icp-cli reads ICP_CLI_GITHUB_TOKEN (not GITHUB_TOKEN) when fetching the network launcher version from the GitHub API. Using the wrong variable name caused 403 Forbidden errors even with the token set. Also restores ICP_CLI_GITHUB_TOKEN on the frontend.yml and backend-motoko.yml test steps, which were lost when our diff overwrote the base branch's 2c7813b fix. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…mples Two issues caused all example CI jobs to fail: 1. mops not installed: the motoko canister recipe checks for `mops` on PATH, but the provision scripts only installed icp-cli and ic-wasm. Add ic-mops to the global npm install in provision-linux.sh and provision-darwin.sh. 2. frontend/ic_vetkeys prepare script fails during npm i: the example frontends reference @dfinity/vetkeys as a file: dependency. When npm installs it, it runs the package's `prepare` script (npm run build = tsc && vite build), but the library's own node_modules are missing in a clean CI environment. Fix: add an "Install workspace dependencies" step (npm install at repo root) before each icp deploy step in all example workflows. This pre-builds the workspace so the prepare script succeeds. Note: both issues are invisible locally because developers typically have already run `npm install` at the repo root and have ic-mops installed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… fix lint - Remove sudo from provision-linux.sh rustup install so cargo lands in the runner user's PATH (same fix already applied to provision-frontend-linux.sh) - Guard all gen_bindings.sh scripts behind `command -v candid-extractor` to prevent bash from truncating the static .did file via shell redirection when candid-extractor is absent but the WASM build cache is present - Fix 4 prettier/eslint violations in password_manager frontend: - NewPassword.svelte: break long disabled attribute across lines - Vault.svelte: remove unnecessary @ts-ignore (svelte-icons types resolve fine) - encrypted_maps.ts: inline canisterEnv lookup onto one line - auth.ts: wrap long expirationMs expression Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…chat tests Consistent with the same change made to the backend canister tests in #365. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
8ee818e to
0c7eed4
Compare
f642706 to
6698d00
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR migrates all 7 example projects to use ICP CLI instead of dfx and
@icp-sdk/coreinstead of@dfinity/*, and fixes a number of runtime issues discovered during testing.Changes by commit
feat(examples): migrate all 7 example frontends to @icp-sdk/core@dfinity/auth-client+@dfinity/principalwith@icp-sdk/auth+@icp-sdk/coredev:motoko/dev:rustnpm scripts, update vite configs, refreshpackage-lock.jsongen_bindings.shscripts to useicp-cliencrypted_maps_canister.tsto match current backend interfacebaseUrlfromtsconfig.json; renametailwind.config.cjs→.mjsin password_manager examples ("type":"module")feat(examples): migrate all 7 example backends from dfx to icp-clidfx.jsonwithicp.yamlfor all Motoko and Rust backendsmops.tomlto pinmoc 1.5.0, remove--enhanced-orthogonal-persistenceflag (default since moc 0.15.0)password_manager_with_metadatato currentic-vetkeyscrate interfacefix(examples): update frontend source for @dfinity/vetkeys and @icp-sdk API changesgetBasicIbeCanister→getBasicIbeActor(and equivalents) for naming consistencywindow.globalpolyfill andas anycasts (no longer needed)encrypted_chatauth store (create once on login, not per call)DerivedKeyMaterial.fromCryptoKey()missingawait(method is now async)associatedDataarg toencryptMessage/decryptMessageencrypted_notescrypto.ts:deriveAesGcmCryptoKeyis now private; useencryptMessage/decryptMessageonDerivedKeyMaterialdirectly; cacheCryptoKeyin IndexedDB and reconstruct on retrieval (class instances are not structured-clone safe)HttpAgent.createSync()with asyncHttpAgent.create(); remove unusedhex_encodefix(ci): update CI workflows to use icp-cli instead of dfxdfx start/deploywithicp network start / icp deployDFX_VERSIONenv var, add Node.js 22 setup stepdocs(examples): update documentation links and ICP CLI referencesinternetcomputer.org/docs/→docs.internetcomputer.org/icp network stopinstructions to local deployment sectionsencrypted_chatgen_bindings.sh—candid-extractorguardEach example's
gen_bindings.shscript callsmake extract-candidto refresh the static.didfile from the compiled WASM, then feeds that file to@icp-sdk/bindgen. The Makefile target ends with a shell redirect:candid-extractor ... > backend.did.In bash, the
>redirect opens and truncates the target file before the command runs. Ifcandid-extractoris not installed (it isn't — our provision scripts don't include it), the static.didfile is wiped to zero bytes even though the command itself exits 127.bindgenthen reads an empty file and generates adid.jswith no exports, causing a vite build failure ("idlFactory" is not exported).On
mainthis was harmless:gen_bindings.shuseddfx generatewhich reads Candid from the deployed canister, not from the.didfile on disk. Withbindgen, the file is the explicit source of truth, so the truncation becomes a real failure.The guard
if command -v candid-extractor >/dev/null 2>&1skips the extraction entirely when the tool is absent, leaving the committed.didfiles intact forbindgento read.Pre-existing
encrypted_chatSPEC.md divergences (not introduced by this PR)The
encrypted_chatexample is an unfinished prototype (README has a disclaimer). The following gaps betweenSPEC.mdand the actual code predate this PR and exist on bothmainand this branch:get_my_chats_and_time→get_my_chat_ids: SPEC defines an API returning{chats, consensus_time_now}, but backend/frontend useget_my_chat_idsreturning only an array of tuples.create_direct_chat(OtherParticipant, SymmetricKeyRotationMins), but both backend and frontend passmessageExpirationDurationMinutesas a third parameter during creation.derive_chat_vetkeyVetKeyEpochId: optional in code ([] | [bigint]), required in SPEC.Nonce = blob, backend DID usesbigint.Test plan
basic_ibe:icp network start -d && icp deploy(Motoko + Rust), verify encrypt/decrypt flowbasic_bls_signing: verify sign/verify flowbasic_timelock_ibe: verify timelock decrypt at future epochencrypted_notes_dapp_vetkd: add note, reload page (tests IndexedDB cache path), verify decryptencrypted_chat: send message, verify decryption on both endspassword_manager: add vault/password, verify encrypt/decryptpassword_manager_with_metadata: same as above with metadata fields🤖 Generated with Claude Code