DFX declarations don't handle custom networks, like staging (only "ic" and not "ic")

Hi dfx team,

Have been having errors of “fetch root key” on the IC context. And the cause is this if on the automatically generated declarations (even on latest version it happens (v0.20.0)):

As you can see, it’s being binary on that variable. But the truth is that a network can (and should be) more custom than just those two options. In my case I have a “staging” network.

But it can be other things, like “beta”, “internal”, etc. So I strongly recommend to only check if on “local” or not, rather than the “ic”.

Let me know your feedback and if a fix is possible.

Thanks,
Tiago

It’s a tricky design problem. There’s no real way for us to know whether a custom named network is mainnet or not, just by looking at the name of the environment. We would have to make a more sophisticated guess in dfx based on the network configuration and known hosts, but even then we’re just guessing.

My recommendation is - if your use case has advanced beyond the point where the provided index.js is useful, you should stop using it. Import the idlFactory directly and write your own createActor function that suits your needs

1 Like