Is there a way to somehow initialize the CanisterInfo.name field when deploying all the canisters? The name can be the same with the canister name specified in dfx.json. Worst case, I could call a API to set the name after deployment for each canister. But since I will have many canisters, doing that during development is a pain
At some point I’d like to see a field argument_file for canisters so you can point all of them at the same file and you’re good to go. Until then, I think the easiest solution is to write a script that calls dfx deploy with the same --argument <...> for every canister
Thanks. I was not aware that there is a --argument option. Two questions
Say I have a candid file (the actual code is more complex so I simply the request type)
type SetCanisterInfoRequest = record {
name : text;
};
service : {
set_canister_info : (SetCanisterInfoRequest) -> ();
}
I tried dfx canister call test_canister set_canister_info '(record { name="hey" })' and I got
Error: Failed to create argument blob.
Caused by: Failed to create argument blob.
Invalid data: Unable to serialize Candid values: Invalid data: Unable to serialize Candid values: record field info not found
When using dfx deploy test_canister --argument= as you suggested, what should I put in the argument using the example above? The official doc says
Specifies an argument using Candid syntax to pass to the canister during deployment. Note that this option requires you to define an actor class in the Motoko program.
but I still don’t understand. Are you aware of any example of this argument usage?
Looks completely fine to me. Really stupid question: did you save the candid file and point at it properly? It sounds like it’s expecting a different record that includes a field called info
If your canister takes SetCanisterInfoRequest as an init argument then you’d simply call dfx deploy test_canister --argument='(record { name="hey" })'