Skip to content

chore: migrate rust/daily_planner to icp-cli#1403

Merged
raymondk merged 12 commits into
masterfrom
chore/migrate-rust-daily-planner-to-icp-cli
Jun 19, 2026
Merged

chore: migrate rust/daily_planner to icp-cli#1403
raymondk merged 12 commits into
masterfrom
chore/migrate-rust-daily-planner-to-icp-cli

Conversation

@marc0olo

@marc0olo marc0olo commented Jun 16, 2026

Copy link
Copy Markdown
Member

Summary

Migrates rust/daily_planner from dfx to icp-cli.

Removed: dfx.json, BUILD.md, .devcontainer/

Changed:

  • Frontend migrated from dfx declarations / vite-plugin-environment to @icp-sdk/bindgen + actor.js; fixed opt-type handling (@icp-sdk/bindgen returns T | null, not [] | [T] as in the old @dfinity/agent convention)
  • Backend HTTP outcalls updated from removed ic_cdk::api::management_canister to ic_cdk_management_canister (new separate crate ic-cdk-management-canister = "0.1.1" required by ic-cdk 0.20)
  • get_month_data zero-pads month to match ISO date keys (pre-existing bug surfaced by tests)

Added:

  • icp.yaml with @dfinity/rust@v3.3.0 (backend, with committed backend.did generated via candid-extractor) and @dfinity/asset-canister@v2.2.1 (frontend)
  • test.sh with 6 tests covering all public canister methods
  • rust-daily_planner CI job in daily_planner.yml using icp-dev-env-rust:1.0.1

Test plan

  • icp network start -d && icp deploy && bash test.sh passes
  • Frontend builds, loads, and "On This Day" data displays correctly after fetching
  • CI rust-daily_planner job passes

🤖 Generated with Claude Code

@marc0olo marc0olo force-pushed the chore/migrate-rust-daily-planner-to-icp-cli branch from e99fe03 to 94bf541 Compare June 17, 2026 17:00
@marc0olo marc0olo closed this Jun 19, 2026
@marc0olo marc0olo force-pushed the chore/migrate-rust-daily-planner-to-icp-cli branch from 94bf541 to 8f077c8 Compare June 19, 2026 06:35
marc0olo and others added 2 commits June 19, 2026 09:38
Replace dfx.json with icp.yaml, update frontend to use @icp-sdk/bindgen
and actor.js pattern, update backend HTTP outcalls to ic-cdk 0.20 API,
add Makefile with tests, and add rust-daily_planner CI job.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@marc0olo marc0olo reopened this Jun 19, 2026
marc0olo and others added 9 commits June 19, 2026 16:21
…p.yaml

- ic_cdk::management_canister was moved to ic-cdk-management-canister in ic-cdk 0.20
- Add ic-cdk-management-canister = '0.1.1' to Cargo.toml
- Update import to use ic_cdk_management_canister::{http_request, ...}
- Remove redundant networks block from icp.yaml

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…d!() instead

With candid: specified, the recipe does not run candid-extractor and the
candid:service metadata is not embedded, causing icp canister call to
output raw bytes for update calls. Let export_candid!() + candid-extractor
handle the metadata embedding as in other examples.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Rust's Result<T,E> serializes to variant { Ok : text; Err : text } (capital)
while the .did had lowercase ok/err (Motoko convention). Update both the
.did file and the test assertion to use capital Ok/Err.

This also explains the previous raw bytes issue: the embedded Candid (from
backend.did with lowercase ok/err) didn't match the actual response (with
capital Ok/Err), causing icp canister call decoding to fail.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…d-extractor

Replaces the manually written .did (which had wrong lowercase ok/err
from Motoko convention) with the correctly generated interface from
the compiled WASM. Uses a Result type alias and correct Ok/Err casing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… correct

With the properly generated backend.did, the candid: field can correctly
embed the interface. The original failure was due to the wrong .did, not
the candid: mechanism itself.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Dates are stored in ISO format (e.g. '2024-01-15') but the prefix was
generated without zero-padding ('2024-1-'), causing get_month_data to
return empty results for single-digit months.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Without await, hideLoading() fired before the state update completed,
and the UI didn't re-render with the fetched on_this_day data.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The @icp-sdk/bindgen converts Candid opt T to T | null (not [] | [T]).
Two bugs caused by the old @dfinity/agent array convention:

1. get_day_data: data?.length > 0 ? data[0] always fell back to the
   default since DayDataEntry | null has no .length → use data ?? {...}

2. on_this_day: checked .length > 0 and indexed [0] but OnThisDay |
   undefined is a plain object → use on_this_day ? and direct access

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- https-outcalls-how-to-use → docs.internetcomputer.org/guides/backends/https-outcalls
- cost calculator URL: icp0.io → icp.net

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@marc0olo marc0olo marked this pull request as ready for review June 19, 2026 14:54
@marc0olo marc0olo requested review from a team as code owners June 19, 2026 14:54
@raymondk raymondk merged commit 486a9db into master Jun 19, 2026
7 checks passed
@raymondk raymondk deleted the chore/migrate-rust-daily-planner-to-icp-cli branch June 19, 2026 20:50
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.

2 participants