Skip to content

chore(vetkeys): split basic_ibe into self-contained motoko + rust examples#1443

Open
marc0olo wants to merge 6 commits into
masterfrom
chore/split-vetkeys-basic-ibe
Open

chore(vetkeys): split basic_ibe into self-contained motoko + rust examples#1443
marc0olo wants to merge 6 commits into
masterfrom
chore/split-vetkeys-basic-ibe

Conversation

@marc0olo

Copy link
Copy Markdown
Member

Summary

Splits the vetkeys basic_ibe example into two self-contained examples — one per language — matching the basic_vetkd layout, and duplicates the frontend so each is independent.

Previously basic_ibe lived only under rust/vetkeys/basic_ibe/ with a shared frontend/ symlinked into motoko/ and rust/ subdirs, and a gen_bindings.sh that always generated bindings from the Rust backend. Now:

motoko/vetkeys/basic_ibe/   backend/app.mo + own frontend/ + icp.yaml + mops.toml
rust/vetkeys/basic_ibe/     backend/ (flattened) + own frontend/ + icp.yaml + Cargo.toml

Frontend

  • Duplicated per language. Bindings are generated by the @icp-sdk/bindgen Vite plugin from the committed backend/backend.did (replacing the shared scripts/gen_bindings.sh). main.ts imports from ./bindings/backend.
  • Slimmed to the established shape: dropped eslint/prettier/gen_bindings.sh and the BACKEND-env dev logic; package.json reduced to name: "frontend".
  • Added a root workspace package.json to each example so npm run dev / npm run build run from the example root (matching ic-pos, daily_planner, …).

Backend

  • Motoko: idiomatic camelCase public interface (getMyMessages, .encryptedMessage, …). The vetKD management-canister interface is kept snake_case (vetkd_public_key, key_id, …) since it's the fixed system API. moc 1.11.0 + --default-persistent-actors (the now-redundant persistent keyword removed). Dropped unused sha2 dep. Committed backend/backend.did.
  • Rust: unchanged (snake_case), just relocated into the flattened layout.

Since the frontends are now separate, the Motoko frontend uses the camelCase interface and the Rust frontend keeps snake_case — each matches its own backend.

Docs & CI

  • README split per language (cross-linked); prerequisites link each tool with its install command inline.
  • vetkeys-basic-ibe.yml: motoko + rust jobs target the new paths, watch both motoko/** and rust/**, and run test.sh.

CODEOWNERS

Unchanged — /motoko/vetkeys/ and /rust/vetkeys/ both already map to @dfinity/core-protocol, so both examples keep that owner.

Verification (local, icp 1.x)

  • Motoko: mops generate candid, frontend build + tsc --noEmit clean, icp deploy, test.sh PASS, and state survives an upgrade (sent a message → redeployed as upgrade → message still present, confirming persistence with the flag).
  • Rust: cargo/wasm build + icp deploy, test.sh PASS.
  • Both frontends build and serve (HTTP 200).

Part of a series — each vetkeys example that currently shares a frontend under rust/vetkeys/ will get its own split PR (basic_bls_signing, encrypted_notes_app_vetkd, password_manager, password_manager_with_metadata).

🤖 Generated with Claude Code

…mples

Previously basic_ibe lived only under rust/vetkeys/basic_ibe with a shared
frontend symlinked into motoko/ and rust/ subdirs. Split it into two
self-contained examples that match the basic_vetkd layout:

  motoko/vetkeys/basic_ibe/   backend/app.mo + own frontend/ + icp.yaml
  rust/vetkeys/basic_ibe/     backend/ (flattened) + own frontend/ + icp.yaml

Frontend
- Duplicated per language; bindings now generated by the @icp-sdk/bindgen
  Vite plugin from the committed backend/backend.did (replaces the shared
  scripts/gen_bindings.sh that always used the Rust .did).
- Slimmed to the established shape: dropped eslint/prettier/gen_bindings and
  the BACKEND-env dev logic; added a root workspace package.json so
  `npm run dev` / `npm run build` run from the example root.

Backend
- Motoko: idiomatic camelCase public interface (getMyMessages,
  .encryptedMessage, ...); the vetKD management-canister interface is kept
  snake_case (fixed system API). moc 1.11.0 + --default-persistent-actors
  (dropped the now-redundant `persistent` keyword); dropped unused sha2 dep.
  Committed backend/backend.did.
- Rust: unchanged (snake_case), just relocated to the flattened layout.

Docs & CI
- README split per language (cross-linked), prerequisites link each tool
  with its install command inline.
- vetkeys-basic-ibe.yml: motoko + rust jobs now target the new paths, watch
  both motoko/** and rust/**, and run test.sh.

CODEOWNERS is unchanged: /motoko/vetkeys/ and /rust/vetkeys/ both already
map to @dfinity/core-protocol, so both examples keep that owner.

Verified locally: Motoko deploy + test.sh + state survives an upgrade;
Rust cargo/wasm build + deploy + test.sh; both frontends build and serve.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@marc0olo
marc0olo marked this pull request as ready for review July 16, 2026 15:05
@marc0olo
marc0olo requested review from a team as code owners July 16, 2026 15:05
@marc0olo
marc0olo requested a review from Copilot July 16, 2026 15:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Splits the vetkeys/basic_ibe example into two self-contained examples (Motoko + Rust), each with its own frontend and project config, and updates CI accordingly to build/deploy/test both language variants independently.

Changes:

  • Introduces standalone Motoko example at motoko/vetkeys/basic_ibe (backend, frontend, icp.yaml, mops.toml, docs, tests).
  • Refactors Rust example at rust/vetkeys/basic_ibe into the flattened layout with its own frontend/bindgen flow, docs, and tests.
  • Updates .github/workflows/vetkeys-basic-ibe.yml to run Motoko + Rust deploy-and-test jobs against the new paths.

Reviewed changes

Copilot reviewed 30 out of 40 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
.github/workflows/vetkeys-basic-ibe.yml Runs deploy + test.sh for both Motoko and Rust example directories and watches both paths.
motoko/vetkeys/basic_ibe/README.md Adds Motoko-specific README and cross-link to Rust variant.
motoko/vetkeys/basic_ibe/icp.yaml Defines backend + frontend canisters and frontend build steps for Motoko example.
motoko/vetkeys/basic_ibe/mops.toml Pins Motoko toolchain/settings and declares backend entry + candid path.
motoko/vetkeys/basic_ibe/package.json Adds per-example npm workspace root for running frontend scripts from the example root.
motoko/vetkeys/basic_ibe/test.sh Adds basic CLI tests for Motoko backend endpoints.
motoko/vetkeys/basic_ibe/backend/app.mo Motoko backend implementation with camelCase public API and vetKD system API types.
motoko/vetkeys/basic_ibe/backend/backend.did Committed Motoko Candid interface used for frontend bindgen.
motoko/vetkeys/basic_ibe/frontend/index.html Adds Motoko frontend entry HTML for Vite build.
motoko/vetkeys/basic_ibe/frontend/package.json Frontend deps/scripts including @icp-sdk/bindgen plugin usage.
motoko/vetkeys/basic_ibe/frontend/tsconfig.json TypeScript config for the Motoko frontend.
motoko/vetkeys/basic_ibe/frontend/vite.config.ts Vite config generating bindings from backend/backend.did and local dev cookie/proxy wiring.
motoko/vetkeys/basic_ibe/frontend/.gitignore Ignores dist/, node_modules/, and generated bindings output.
motoko/vetkeys/basic_ibe/frontend/public/.ic-assets.json5 Sets hardened asset canister headers/CSP for the Motoko frontend.
motoko/vetkeys/basic_ibe/frontend/public/vite.svg Adds frontend favicon asset.
motoko/vetkeys/basic_ibe/frontend/src/main.ts Motoko frontend logic using generated bindings and II auth.
motoko/vetkeys/basic_ibe/frontend/src/style.css Frontend styling for the Motoko UI.
motoko/vetkeys/basic_ibe/frontend/src/vite-env.d.ts Vite TS type reference.
rust/vetkeys/basic_ibe/README.md Updates Rust README to match the new self-contained layout and bindgen flow.
rust/vetkeys/basic_ibe/icp.yaml Renames canisters to backend/frontend, points to frontend/dist, and updates build commands.
rust/vetkeys/basic_ibe/package.json Adds per-example npm workspace root for the Rust example.
rust/vetkeys/basic_ibe/test.sh Adds basic CLI tests for Rust backend endpoints.
rust/vetkeys/basic_ibe/Cargo.toml Adds a workspace root pointing at backend/.
rust/vetkeys/basic_ibe/rust-toolchain.toml Ensures wasm32 target is configured for the example toolchain.
rust/vetkeys/basic_ibe/backend/Cargo.toml Rust backend crate config + dependencies for the IBE canister.
rust/vetkeys/basic_ibe/backend/Makefile Build + candid extraction helper targets for the Rust backend.
rust/vetkeys/basic_ibe/backend/backend.did Committed Rust Candid interface used for frontend bindgen.
rust/vetkeys/basic_ibe/backend/src/lib.rs Rust backend canister code (stable inboxes, vetKD integration, public API).
rust/vetkeys/basic_ibe/backend/src/types.rs Shared Rust types and stable-structure serialization helpers.
rust/vetkeys/basic_ibe/frontend/.gitignore Ignores dist/, node_modules/, and generated bindings output.
rust/vetkeys/basic_ibe/frontend/package.json Slimmed frontend deps/scripts and adds bindgen plugin dependency.
rust/vetkeys/basic_ibe/frontend/vite.config.ts Rust frontend Vite config generating bindings from backend/backend.did.
rust/vetkeys/basic_ibe/frontend/src/main.ts Updates Rust frontend to import from generated bindings and use backend canister env key.
rust/vetkeys/basic_ibe/frontend/scripts/gen_bindings.sh Removes legacy manual bindings generation script.
rust/vetkeys/basic_ibe/frontend/eslint.config.mjs Removes legacy eslint config.
rust/vetkeys/basic_ibe/frontend/.prettierrc Removes legacy prettier config.
rust/vetkeys/basic_ibe/motoko/mops.toml Removes the old shared Motoko config under the Rust example tree.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread rust/vetkeys/basic_ibe/frontend/src/main.ts
Comment thread motoko/vetkeys/basic_ibe/frontend/src/main.ts
Comment thread rust/vetkeys/basic_ibe/test.sh Outdated
Comment thread motoko/vetkeys/basic_ibe/test.sh Outdated
- main.ts: the "Canister ID not set" error referenced the old canister
  name (basic_ibe); update it to `backend` to match the renamed
  PUBLIC_CANISTER_ID:backend env key, so a missing env cookie is not
  confusing to debug.
- test.sh: call the query method (getMyMessages / get_my_messages) with
  `--query` instead of as an update.

Applies to both the Motoko and Rust variants.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
marc0olo and others added 4 commits July 17, 2026 10:13
Bump the Rust recipe to @dfinity/rust@v3.3.0 and rename the Cargo package to
`backend` (drops the custom `package:` in the recipe config). Drop
backend/Makefile and advertise candid regeneration in the README via
`icp build backend && candid-extractor … > backend/backend.did`.

Verified: rust deploy + test.sh pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The example never had a test.sh on master; drop the ones added during the
split and run deploy-only CI (the deploy verifies build + install). Persistence
is unchanged — the `--default-persistent-actors` flag is kept (without it and
without an explicit `persistent` keyword, moc 1.11.0 errors M0219; the flag is
the forward-compatible choice and provably persists this main-canister actor
class across upgrades).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
"The canister (IC smart contract) ensures ..." -> "The canister ensures ...".

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace "dapp" with "app" and normalize the security best-practices link to
https://docs.internetcomputer.org/guides/security/overview/.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants