Inter-cansister update calls in rust?

Hello fam,

I am trying to make a call from a rust canister to a non-query method of a motoko canister.
I am getting the following error:

The Replica returned an error: code 5, message: “IC0503: Canister rrkah-fqaaa-aaaaa-aaaaq-cai trapped explicitly: Panicked at ‘called Result::unwrap() on an Err value: (DestinationInvalid, “Canister ryjl3-tyaaa-aaaaa-aaaba-cai has no query method ‘getUserDatasetAccess’”)’, src/data_assets/src/main.rs:332:17”

The error seems to suggest that only calls to query methods can be made using ic_cdk::call() (?)
What am I missing here?

I cannot make this method a query one because inside of it I am calling actor class stuff… and inter canister query calls don’t work in motoko, am I getting this right?

It’s probably the error that is misleading. I can confirm that ic_cdk::call() works with update calls.

1 Like

Example in Juno I do following which is an update:

let args = DeleteControllersArgs {
        controllers: controllers.to_owned(),
    };

    let result: CallResult<(Vec<ControllerId>,)> =
        call(*satellite_id, "add_controllers", (args,)).await;

    match result {
        Err((_, message)) => Err(["Failed to add controllers to satellite.", &message].join(" - ")),
        Ok((result,)) => Ok(result),
    }

https://github.com/buildwithjuno/juno/blob/e5177712a2c2f28167bd9999707398ee705af2ff/src/mission_control/src/controllers/satellite.rs#L54

1 Like

It looks like some typo in target function name. If you can share candid or wasm file of target canister I could check what is the problem

3 Likes

Thanks both!
So it appears it was (most likely) an issue with type decoding. Not sure why it got translated into the error message above.
Anyway, I managed to fix the issue by simply using CallResult… which I wasn’t doing before.

Thanks

2 Likes