Dynamic Candid arguments #2626
nmattia
started this conversation in
Feature Requests
Replies: 1 comment
-
I'm not sure it's a good idea to implement this. This adds a lot of complexity. For example,
will require dynamically generating a Candid type in DFX, which I'm not sure how to do. Furthermore, I'm not sure why this cannot be implemented with a simple bash script, something like dfx canister create backend
dfx canister create frontend
BACKEND_ID=$(dfx canister id backend)
FRONTEND_ID=$(dfx canister id frontend)
if [[ $PRODUCTION == "1" ]]; then
BACKEND_ARGS=...
FRONTEND_ARGS=...
else
BACKEND_ARGS=...
FRONTEND_ARGS=...
fi
dfx deploy backend --argument $BACKEND_ARGS
dfx deploy frontend --argument $FRONTEND_ARGS |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Say I have two canisters:
A
andB
. Most likely there will be a dependency between the two, i.e.A
may depend onB
at runtime. This is the case if e.g.A
is an asset canister making calls toB
(which could be a motoko canister). In general, canisterA
has no way of knowing the canister ID of canisterB
; it does however need to know the canister ID of canisterB
to make API (IC) calls.This is currently worked around by looking up canister IDs at build time and injecting them in the webpack config. This is not optimal, see #2014 for more details.
Instead I'd like to suggest passing the canister ID of canister
B
as aninit
argument to canisterA
.The naive approach would be to always pass the canister IDs as arguments. This may cause problems in existing projects, and this would restrict what arguments canister developers could use when using
dfx
. Instead, this could be turned on and off indfx.json
:Here, all canisters setting
canister_id_args
totrue
would get the following candid record as init argument:Going yet a little further, we could even go as far as allowing developers to specify init arguments for canisters, as well as supporting basic templating:
Here the templating syntax is borrowed from the GitHub Actions Expressions. Strings are used to write expressions, although in certain cases (
dfx.canister_ids
) they may expand to objects (records). In this example two namespaces are used,dfx
andenv
, wheredfx
could hold project-related values andenv
could be used to look up environment variables.This would resolve the following issues, as well as allowing developers to have more complex setups:
dfx start
#2012Beta Was this translation helpful? Give feedback.
All reactions