Repository navigation
chore: migrate rust/icp_transfer to icp-cli - #1412
Merged
Merged
Conversation
Replaces dfx.json with icp.yaml (@dfinity/rust@v3.3.0), moves the canister source from src/icp_transfer_backend/ to backend/, renames the Cargo package to `backend`, adds a Makefile that deploys the ICP ledger locally at ryjl3-tyaaa-aaaaa-aaaba-cai and runs end-to-end transfer tests, and adds a CI workflow using icp-dev-env-rust:1.0.0. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…st structure Backend: - Replace single transfer() with to_account_id_hex, transfer_to_principal, transfer_to_account_id (mirrors motoko example) - AccountIdentifier::new for principal path; raw 32-byte blob for account ID path - Bump ic-cdk 0.18 → 0.20; remove unused serde dependency Makefile: - Drop make deploy-ledger (icp network start -d pre-deploys the ledger) - Drop python3 dependency - Same 3-test structure as motoko: CLI hex vs backend hex, transferToPrincipal balance check, transferToAccountId via vec nat8 - Fund 2 ICP, drain to zero (99_990_000 e8s + 10_000 fee = exactly 1 ICP/test) README: - Aligned with motoko README; remove stale token_transfer references Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace manual byte-stripping with from_hex(), which validates the 4-byte CRC32 prefix before constructing the AccountIdentifier. Fails fast in the canister with a readable error instead of propagating invalid bytes to the ICP ledger. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Passing a 64-char hex string (the format CEXs and block explorers provide) is cleaner than a raw blob: AccountIdentifier::from_hex validates the CRC32 in one call with no byte-manipulation, the Makefile test passes the hex string directly, and the Candid type text avoids vec nat8 complexity. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
marc0olo
force-pushed
the
chore/migrate-rust-icp-transfer-to-icp-cli
branch
from
June 17, 2026 13:05
d85357c to
1382f67
Compare
… Rust Replace generic /guides/security/overview with: - /inter-canister-calls/#securely-handle-traps-in-callbacks - /data-integrity-and-authenticity/#certified-variables Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…flict ic-ledger-types 0.15 pins ic-cdk = "^0.18". Upgrading our backend to 0.20 pulls in ic-cdk-executor v2 alongside ic-cdk-executor v1 (from ic-ledger-types), which hits Cargo's `links` uniqueness constraint and fails the build. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ic-ledger-types 0.16 requires ic-cdk ^0.19, so both 0.19 and 0.20 use ic-cdk-executor v2 — no more `links` uniqueness conflict that occurred when mixing ic-ledger-types 0.15 (ic-cdk-executor v1) with ic-cdk 0.20 (ic-cdk-executor v2). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Mirrors the Rust example: transferToAccountId now takes a 64-char hex string instead of a raw blob. Uses mo:hex for decoding; length is checked (must be 32 bytes / 64 hex chars). CRC32 validation is delegated to the ICP ledger — a fromHex helper with CRC32 validation would be a valuable addition to a future Motoko ICP library. Makefile Test 3 simplifies: pass "$cli_hex" directly instead of the vec nat8 construction workaround. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ndid-extractor ic-cdk 0.20 uses ic0::cost_call (new IC system API) which candid-extractor in icp-dev-env-rust:1.0.0 does not recognise, causing the Candid extraction step to fail. ic-cdk 0.19 avoids this import while still satisfying ic-ledger-types 0.16's ^0.19.0 requirement and sharing ic-cdk-executor v2. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
candid-extractor 0.1.6 (shipped in icp-dev-env-rust:1.0.1) supports ic0::cost_call, unblocking ic-cdk 0.20 in CI. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
marc0olo
marked this pull request as ready for review
June 17, 2026 13:59
lwshang
approved these changes
Jun 17, 2026
mbjorkqvist
approved these changes
Jun 17, 2026
mbjorkqvist
left a comment
Contributor
There was a problem hiding this comment.
Thanks @marc0olo, just a couple of nits!
- Makefile: fix stale 'blob' in PASS message — function now accepts hex - icp.yaml: drop redundant networks block (managed is the default, matches motoko/icp_transfer which omits it on master) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
Migrates
rust/icp_transferto icp-cli, aligned with the already-mergedmotoko/icp_transfer(#1389). Also patchesmotoko/icp_transfer(security doc links, hex string API fortransferToAccountId).rust/icp_transfer
icp.yaml: replacesdfx.json; uses@dfinity/rust@v3.3.0backend/src/lib.rs: three public functions matching the Motoko example:to_account_id_hex(principal, subaccount)— query returning the AccountIdentifier as a 64-char hex string (block explorer / CEX deposit format)transfer_to_principal(amount, principal, subaccount)— callsAccountIdentifier::newinternallytransfer_to_account_id(amount, account_id_hex)— accepts a 64-char hex string; usesAccountIdentifier::from_hexwhich validates the CRC32 checksumic-cdk-executorlinks conflict; 0.16 requires^0.19so both use executor v2)Makefile: 3 tests aligned with the Motoko example — no manual ledger deployment (icp-cli pre-deploys it), no python3:icp identity account-id --format ledgermatchesto_account_id_hextransfer_to_principal— asserts exact 1 ICP deduction (99_990_000 amount + 10_000 fee)transfer_to_account_idvia hex string — same deduction, backend drains to zeroicp-dev-env-rust:1.0.1(1.0.0 bundled candid-extractor 0.1.4 which fails on ic-cdk ≥ 0.19 due toic0::cost_call; fixed in 0.1.6)dfx.json,demo.sh,src/, old workflowmotoko/icp_transfer (follow-up patch to #1389)
transferToAccountIdnow accepts a 64-char hex string instead of a raw blob — consistent with Rust, ergonomic for CEX integrations, usesmo:hexfor decoding; note on CRC32 library gap addedinter-canister-calls/#securely-handle-traps-in-callbacks,data-integrity-and-authenticity/#certified-variables)Test plan
icp network start -d && icp deploy && make testpasses locally (rust)icp network start -d && icp deploy && make testpasses locally (motoko)icp-dev-env-rust:1.0.1Docker imagerust-icp_transferandmotoko-icp_transferjobs)🤖 Generated with Claude Code