Generate js bindings from remote did

I’m declaring canisters in my repository as “custom” and define the url where to fetch them, in particular for the ICRC1 ledger indexer deployment guide.

The dfx.json file then looks like this

{
  "canisters": {
    "icrc1_index_canister": {
      "type": "custom",
      "candid": "https://raw.githubusercontent.com/dfinity/ic/d87954601e4b22972899e9957e800406a0a6b929/rs/rosetta-api/icrc1/index-ng/index-ng.did",
      "wasm": "https://download.dfinity.systems/ic/d87954601e4b22972899e9957e800406a0a6b929/canisters/ic-icrc1-index-ng.wasm.gz",
    },
    "icrc1_ledger_canister": {
      "type": "custom",
      "candid": "https://raw.githubusercontent.com/dfinity/ic/d87954601e4b22972899e9957e800406a0a6b929/rs/rosetta-api/icrc1/ledger/ledger.did",
      "wasm": "https://download.dfinity.systems/ic/d87954601e4b22972899e9957e800406a0a6b929/canisters/ic-icrc1-ledger.wasm.gz",
    }
  },
  "output_env_file": ".env",
  "version": 1
}

The deployment works fine and I would like to use dfx generate to create the js bindings for the candid. When I simply run dfx generate it throws me an error that it can’t find the did file in the .dfx/local folder. It makes sense because I didn’t deploy locally.

Is there a way to run dfx generate and create my js bindings without having to deploy locally? Can this work from the remote url directly?

1 Like

That’s simply a bug. I can’t get it to work either. I suppose you could declare the canister non-remote,dfx generate, and then revert back to remote as a workaround. Alternatively you could try to generate the bindings yourself with didc. The command would be didc bind --target js <did file>

Note to self: ticket

1 Like

Yeah, that’s what I did in the end. I define non-remote to generate the bindings.

Thanks! Good to know that this will be fixed soon.