Import canister QOL

Hi everyone,

I want to announce a quality of life feature in Motoko. This builds upon previous work by @lwshang on dfx deps.

Currently, you can import canisters into Motoko programs like so:

import Ledger “ic:ryjl3-tyaaa-aaaaa-aaaba-cai”;

This assumes that you have the candid file of the canister under your local .dfx directory.

A good way to retrieve and manage these candid files is to use the dfx deps feature. You can do this by specifying the canister you want to import as a dependency and pulling it. This not only retrieves the candid file of the canister, but it also grabs the wasm for it so you can deploy a local version of your dependency to test against.

But what about the management canister? The management canister isn’t a real canister and thus it cannot be made pullable. The next release of dfx will contain a quality of life improvement where dfx will automatically emit the candid for the management canister if you import it into your Motoko program. Thus, something like the following will build on its own.

import Management "ic:aaaaa-aa";

actor {
  public func rand() : async Blob {
    await Management.raw_rand();

Please let us know if you have any questions or run into any bugs!