Skip to content

Bundle ic.did and auto-inject --actor-id-alias for ic:aaaaa-aa imports #492

@ggreif

Description

@ggreif

Feature Request

Depends on caffeinelabs/motoko#6016. Alternatively use a softlink and --actor-idl.

Problem

When a Motoko canister uses ic:aaaaa-aa URL imports (e.g. to call the IC management canister directly), moc requires either:

  • --actor-idl <dir> pointing to a directory containing aaaaa-aa.did, or
  • --actor-id-alias aaaaa-aa aaaaa-aa <did-path> (available since moc 1.4.1)

Today, dfx handles this automatically by bundling the management canister's DID and passing the flag to moc. However, when using mops as the build driver (e.g. via the @dfinity/motoko icp-cli recipe, or mops test), neither flag is passed, so ic:aaaaa-aa imports fail with a compiler error.

Proposed Solution

mops should:

  1. Bundle ic.did — include the IC management canister Candid interface (from https://raw.githubusercontent.com/dfinity/portal/refs/heads/master/docs/references/_attachments/ic.did) alongside the toolchain/moc binary it manages.

  2. Automatically inject --actor-id-alias aaaaa-aa aaaaa-aa <bundled-ic.did> into every moc invocation — so that ic:aaaaa-aa imports just work, the same way dfx handles it today.

Why in mops?

  • mops already manages the moc binary version via mops toolchain — it's the natural place to also manage the IC system DID that moc needs.
  • This makes the ic:aaaaa-aa import pattern work uniformly across all build toolchains that delegate to mops, without requiring each recipe or build script to find and pass the DID path themselves.
  • The moc-flags escape hatch (documented in mops.toml but currently unimplemented) could serve as a fallback for overrides, but the common case should work out of the box.

Alternatives Considered

  • Recipe-level fix: The @dfinity/motoko icp-cli recipe could add --actor-id-alias, but it would need to know where ic.did lives — which brings the same bundling question back.
  • --actor-idl directory: The older approach works but requires a directory symlink/copy setup; --actor-id-alias (moc ≥ 1.4.1) is cleaner.
  • Inline type definitions: The generated code can avoid the ic:aaaaa-aa import by inlining the management canister types — but this is a workaround, not a fix, and loses the benefits of the canonical interface.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions