Generated declarations in Node.js environment break

Can you explain the issue with having a hard-coded key for the local replica environment? Is there some issue with the local dfx replicas all having the same key for development?

Seems like a simple fix to just hard-code that if using dfx. I understand that there might be other deployments of the IC, such as test networks or who knows other production or private networks later on. But I think there should be an option to hard-code it for this case.

How does JavaScript know that weā€™re using dfx?

Yeah good point, but perhaps thereā€™s a simple setting we could pass into the agent on creation.

Perhaps the agent can just use the hard-coded keys basing it off of the URL (isnā€™t that how it knows to use the hard-coded production key?), if itā€™s a URL that looks local (localhost or 127.0.01 etc) then it can use the hard-coded development key. And only outside of those two situations (which currently would be very rare), a custom key can be fetched.

It knows weā€™re using the production IC somehow, I assume based on the URL. Same type of process can be used to determine if weā€™re local right?

URL is only a thing in a browser context though. Also, when custom domains come into play, it becomes even more complicated.

the host passed to the httpAgent would be the best existing feature to hook into, but at the moment thatā€™s private, so the only time weā€™d know whether to use it for fetchRootKey would be to check it in the createActor args, so that might be a safe enough enhancement

Hi. I have a question (or suggestion) in the local environment if several Actors (Canisters) are randomly generating identifiers. Is it possible to somehow hard-link them in the dfx.json file?

For example

const canister_id_service_dbs = "ryjl3-tyaaa-aaaaa-aaaba-cai";
const canister_id_service_token = "r7inp-6aaaa-aaaaa-aaabq-cai";

Each time you have to reassign to correctly generated ones (this is in the local environment)

I would like something similar to canister_ids.json

Is this available yet?

Weirdly, we seem to have released 0.11.2 recently, but it doesnā€™t seem to have the feature yet. The feature will be in 0.12.0, and you can try it out today by installing 0.12.0-beta.1

1 Like