I’m testing out init arguments in Azle, and all of the sudden I can’t deploy canisters locally with parameters. I am using dfx 0.9.3 and I’ve been trying to follow the advice here: Upgrade canister on ic with new dfx version - #7 by ericswanson but I keep the following error every time I try to deploy with an argument:
Installing canisters...
Upgrading code for canister init, with canister_id rrkah-fqaaa-aaaaa-aaaaq-cai
Error: The Replica returned an error: code 5, message: "Canister rrkah-fqaaa-aaaaa-aaaaq-cai trapped explicitly: Custom(No more values on the wire, the expected type nat64 is not opt, reserved or null)"
The code looks like this, just a normal init with a simple argument:
import {
Init,
ic,
nat64
} from 'azle';
export function init(nat64: nat64): Init {
ic.print('nat64', nat64);
}
postupgrade also takes arguments. In Motoko, we assume this is the same type as the init args in actor class. In Rust, I think we made the same assumption, but theoretically it can take a different type. So for upgrade, you need to provide the init arg, and the behavior is specified in the post-upgrade function, not the init function.