Commit bc34020
chore: migrate motoko/icp_transfer to icp-cli (#1389)
* chore: migrate motoko/icp_transfer to icp-cli
- Replace dfx.json with icp.yaml using @dfinity/motoko@v5.0.0 recipe
- Move src/icp_transfer_backend/main.mo → backend/app.mo
- Refactor Motoko code: replace canister import with direct actor reference
to the ICP ledger at its well-known principal ryjl3-tyaaa-aaaaa-aaaba-cai
(available on both mainnet and the icp-cli local network's NNS subnet)
- Update mops.toml: moc 1.9.0, core 2.5.0, --default-persistent-actors flag
- Add Makefile with test target (funds backend then tests transfer function)
- Add CI workflow .github/workflows/icp_transfer.yml (motoko-only job)
- Delete dfx.json, demo.sh, src/ directory, old per-example .gitignore
- Delete old .github/workflows/motoko-icp-transfer-example.yml
- Add mops.lock to root .gitignore
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* chore(icp_transfer): remove old Motoko workflow and Candid section from README
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* docs(icp_transfer): remove GitHub link and Overview heading from README
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(icp_transfer): fix Makefile grep, -i flag, and clarify created_at_time comment
- grep -q '#ok' → grep -q 'ok': Candid output is (variant { ok = N : nat64 }),
no # prefix
- --id-only → -i: matches the canonical flag used across all Makefiles
- Clarify created_at_time = null comment: null stores current IC time in the
block but also disables deduplication protection
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* improve(icp_transfer): add balance checks via icrc1_balance_of
Tests now verify the actual ICP balance deltas on the ledger:
- Test 1: fund backend with 2 ICP, assert backend gained +200_000_000 e8s
- Test 2: transfer 1 ICP, assert backend lost -100_010_000 e8s (amount + fee)
and recipient gained +100_000_000 e8s exactly
Delta-based checks so tests are idempotent across re-runs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* refocus(icp_transfer): highlight toLedgerAccount with dual transfer paths
- toAccountId(principal, subaccount) — query that surfaces the
AccountIdentifier blob so callers can inspect the conversion
- transferToPrincipal — converts internally via toLedgerAccount
- transferToAccountId — accepts the blob directly (exchange use case)
- make test calls both with the same recipient and verifies identical
balance deltas, proving the two paths reach the same account
- README rewritten around AccountIdentifier concept; removes broken
token_transfer reference; notes ICRC-1 alternative
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(icp_transfer): clarify CEX vs wallet account format in README
CEXs use AccountIdentifier; wallets prefer ICRC-1 account format.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(icp_transfer): use icp token balance + shell function for robust balance checks
- Define get_balance() shell function at the top of the test block to avoid
repeating the awk conversion; avoids Make/shell variable expansion traps
with $(call ...) and $$-style variables
- icp token balance -q outputs ICP as a decimal; awk converts to e8s integer
for exact arithmetic — avoids the underscore-in-Candid-nat parsing bug
where grep -oE '[0-9]+' on (400_000_000 : nat) gave 400 not 400000000
- Delta-based checks remain idempotent across re-runs
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* refocus(icp_transfer): AccountIdentifier, fee-aware tests, hex mops library
Backend (3 public functions):
- Remove toAccountId (raw blob, superseded by toAccountIdHex)
- toAccountIdHex: use hex mops library instead of manual nibble arithmetic
- transferToPrincipal / transferToAccountId: unchanged code paths
Makefile (3 tests):
- Test 1: assert icp identity account-id --format ledger == toAccountIdHex
- Test 2: transferToPrincipal — 99_990_000 e8s + 10_000 fee = exactly 1 ICP
- Test 3: transferToAccountId — AccountIdentifier as vec { N : nat8; ... }
constructed from hex via fold -w2 and bash $((16#xx)) arithmetic;
blob "\xx..." fails with non-ASCII bytes in @dfinity/candid (reproduces
on icp-cli 0.3.2 and 1.0.0 — likely a bug in the Candid text parser)
- Fund 2 ICP, both transfers drain it to zero (highlights fee deduction)
CI: bump icp-dev-env-motoko 0.3.2 → 1.0.0
mops.toml: add hex = "1.0.3"
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(icp_transfer): use printf '%d' 0x for POSIX sh hex conversion
$((16#xx)) is bash-only. CI runs Makefile recipes with /bin/sh (dash)
which doesn't support this syntax, producing an empty vec. printf '%d' "0x$b"
is POSIX-specified and works in both dash and bash.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent bafb2cf commit bc34020
12 files changed
Lines changed: 221 additions & 469 deletions
File tree
- .github/workflows
- motoko/icp_transfer
- backend
- src/icp_transfer_backend
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
0 commit comments