service

Values created by the CandidType function Canister correspond to the Candid service type, are inferred to be TypeScript Objects, and will be decoded into JavaScript Objects at runtime.

The properties of this object that match the keys of the service's query and update methods can be passed into ic.call and ic.notify to perform cross-canister calls.

TypeScript or JavaScript:

import { bool, Canister, ic, Principal, query, text, update } from 'azle';

const SomeCanister = Canister({
    query1: query([], bool),
    update1: update([], text)
});

export default Canister({
    getService: query([], SomeCanister, () => {
        return SomeCanister(Principal.fromText('aaaaa-aa'));
    }),
    callService: update([SomeCanister], text, (service) => {
        return ic.call(service.update1);
    })
});

Candid:

type ManualReply = variant { Ok : text; Err : text };
service : () -> {
  callService : (
      service { query1 : () -> (bool) query; update1 : () -> (text) },
    ) -> (ManualReply);
  getService : () -> (
      service { query1 : () -> (bool) query; update1 : () -> (text) },
    ) query;
}

dfx:

dfx canister call candid_canister getService
(service "aaaaa-aa")