Skip to content

chore: migrate motoko/evm_block_explorer to icp-cli - #1436

Merged
raymondk merged 8 commits into
masterfrom
motoko/evm-block-explorer
Jul 9, 2026
Merged

raymondk merged 8 commits into
masterfrom
motoko/evm-block-explorer

Conversation

@marc0olo

@marc0olo marc0olo commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • icp.yaml: @dfinity/motoko@v5.0.0 backend, @dfinity/asset-canister@v2.2.1 frontend; pre-built evm_rpc canister at v2.8.0 with nodesInSubnet = 28; environments block with local (deploys all three canisters) and ic (deploys only backend + frontend, injects PUBLIC_CANISTER_ID:evm_rpc = 7hfb6-caaaa-aaaar-qadga-cai)
  • Deleted: dfx.json, BUILD.md, .devcontainer/ (dfx artifacts)
  • backend/EvmRpcApi.mo (new): inline actor type for the EVM RPC canister following the basic_bitcoin / BitcoinApi.mo pattern — no dfx canister: import, no moc flags; principal resolved at runtime via Runtime.envVar<system>("PUBLIC_CANISTER_ID:evm_rpc"); full type definitions for eth_getBlockByNumber with a link to the complete EVM RPC Candid interface
  • backend/app.mo: thin wrapper over EvmRpcApi.getBlock; get_evm_block returns { #Ok : Block; #Err : Text } instead of trapping; no persistent keyword (redundant with --default-persistent-actors)
  • backend/backend.did (new): generated via mops generate candid backend; committed because the frontend consumes it via @icp-sdk/bindgen
  • Dropped signing functions: get_ecdsa_public_key, get_schnorr_public_key, sign_message_with_ecdsa, sign_message_with_schnorr — isolated primitives with no EVM context; refer to basic_ethereum for the full signing + submission flow
  • mops.toml: moc = "1.11.0", core = "2.5.0" (dropped sha2, base16); --default-persistent-actors + warning flags; [canisters.backend] with main and candid pointing to the committed .did
  • Frontend: rewrote vite.config.js and added actor.js to icp-cli only (no dfx fallback); removed ECDSASigning and SchnorrSigning components; Block.jsx handles the Result variant and requires a valid block number before enabling the fetch button; upgraded to @icp-sdk/bindgen for TypeScript binding generation
  • test.sh: fetches Ethereum mainnet block 1 and asserts its deterministic hash and miner address
  • CI workflow: added motoko-evm_block_explorer job using ghcr.io/dfinity/icp-dev-env-motoko:1.0.1; also added motoko/evm_block_explorer/** to the PR path trigger
  • Root .gitignore: added **/src/bindings/ to globally ignore bindgen output (mirrors the existing **/src/declarations/ for dfx)

Test plan

  • icp network start -d && icp deploy && bash test.sh passes locally
  • Frontend builds and block fetch works: npm run dev --prefix frontend
  • icp deploy -e ic deploys only backend + frontend on ICP mainnet

🤖 Generated with Claude Code

marc0olo and others added 4 commits July 9, 2026 18:21
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- moc 1.9.0 → 1.11.0 (latest per mops-cli skill)
- Remove `persistent` from actor declaration — redundant with
  `--default-persistent-actors` in mops.toml (motoko skill convention)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- backend/backend.did now generated by `mops generate candid backend`;
  type is named EvmBlockResult, Block fields alphabetically sorted by moc
- README: use `mops generate candid backend` instead of raw moc command

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Auto-generated by @icp-sdk/bindgen during build; mirrors the existing
**/src/declarations/ entry for dfx-generated declarations.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@marc0olo
marc0olo requested a review from Copilot July 9, 2026 19:26
@marc0olo
marc0olo marked this pull request as ready for review July 9, 2026 19:27
@marc0olo
marc0olo requested review from a team as code owners July 9, 2026 19:27

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

Migrates the Motoko evm_block_explorer example from dfx to icp-cli, aligning the project layout and tooling (icp.yaml, mops, Vite + bindgen, CI) with the repository’s current ICP example conventions.

Changes:

  • Replaced dfx.json-based setup with icp.yaml (including local pre-built evm_rpc and an ic environment override) and updated the README/test flow to icp commands.
  • Refactored the backend to a thin get_evm_block wrapper over a new backend/EvmRpcApi.mo module and committed backend/backend.did for frontend bindgen.
  • Updated the frontend to use @icp-sdk/bindgen + safeGetCanisterEnv actor wiring and removed the signing UI components.

Reviewed changes

Copilot reviewed 19 out of 20 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
motoko/evm_block_explorer/icp.yaml Defines backend/frontend recipes and local pre-built evm_rpc, plus ic environment injection for mainnet
motoko/evm_block_explorer/mops.toml Updates toolchain/deps and sets canister main + candid path
motoko/evm_block_explorer/backend/app.mo Simplifies backend API to get_evm_block returning a Result variant
motoko/evm_block_explorer/backend/EvmRpcApi.mo New inline EVM RPC interface + getBlock helper (contains interface mismatches called out in review comments)
motoko/evm_block_explorer/backend/backend.did Committed Candid interface for frontend binding generation
motoko/evm_block_explorer/frontend/vite.config.js Switches to @icp-sdk/bindgen Vite plugin and icp-cli devserver cookie/proxy flow
motoko/evm_block_explorer/frontend/src/actor.js New actor wiring via safeGetCanisterEnv + bindgen-generated actor
motoko/evm_block_explorer/frontend/src/Block.jsx Updates UI to handle Result and validates block number input before enabling fetch
motoko/evm_block_explorer/frontend/src/main.jsx Removes signing components from the UI
motoko/evm_block_explorer/frontend/package.json Drops dfx generate step; adds @icp-sdk/bindgen
motoko/evm_block_explorer/test.sh Adds an icp-cli test asserting deterministic Ethereum mainnet block 1 fields
motoko/evm_block_explorer/README.md Updates instructions to icp-cli and documents candid regen + provider notes
motoko/evm_block_explorer/package.json Removes workspace prebuild script
.github/workflows/evm_block_explorer.yml Adds Motoko CI job + PR path trigger for the migrated example
.gitignore Globally ignores bindgen output **/src/bindings/
motoko/evm_block_explorer/dfx.json Deleted (dfx artifact)
motoko/evm_block_explorer/BUILD.md Deleted (dfx/ICP Ninja artifact)
motoko/evm_block_explorer/.devcontainer/devcontainer.json Deleted (per-example devcontainer artifact)
motoko/evm_block_explorer/frontend/src/ECDSASigning.jsx Deleted (signing UI removed)
motoko/evm_block_explorer/frontend/src/SchnorrSigning.jsx Deleted (signing UI removed)

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

Comment thread motoko/evm_block_explorer/backend/EvmRpcApi.mo Outdated
Comment thread motoko/evm_block_explorer/backend/EvmRpcApi.mo
marc0olo and others added 4 commits July 9, 2026 21:36
int64 in Candid maps to Int64 in Motoko, not Int.
No runtime impact since Candid allows int64 → int widening,
but this matches the canonical interface precisely.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replaces the ?{} placeholder with the proper ?RpcConfig type matching
evm_rpc.did exactly. Adds inline comments explaining each field so
readers understand when and why they'd override the defaults.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@raymondk
raymondk merged commit 33346be into master Jul 9, 2026
7 checks passed
@raymondk
raymondk deleted the motoko/evm-block-explorer branch July 9, 2026 22:53
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