Hi,
I’d like to find a working example of a client-side call to the IC Management API, canister_status endpoint, using the @dfinity/agent library.
Currently, I get the following error:
Uncaught (in promise) Error: Call was rejected:
Request ID: fcd619917bbae7a933d8d1333d5ad154d42cc5087f933885a7802c9f9663ce35
Reject code:
Reject text: Canister xxxxx has no update method 'canister_status'
Used a partial idl factory for the ic management API:
const idlFactory = ({ IDL }) => {
// eslint-disable-next-line camelcase
const canister_id = IDL.Principal;
// eslint-disable-next-line camelcase
const definite_canister_settings = IDL.Record({
freezing_threshold: IDL.Nat,
controllers: IDL.Vec(IDL.Principal),
memory_allocation: IDL.Nat,
compute_allocation: IDL.Nat,
});
return IDL.Service({
canister_status: IDL.Func(
[IDL.Record({ canister_id })],
[
IDL.Record({
status: IDL.Variant({
stopped: IDL.Null,
stopping: IDL.Null,
running: IDL.Null,
}),
memory_size: IDL.Nat,
cycles: IDL.Nat,
settings: definite_canister_settings,
module_hash: IDL.Opt(IDL.Vec(IDL.Nat8)),
}),
],
[],
),
});
};
The call is made through the @dfinity/agent, with my own identity in which controls the target (effective) canister id. Initially, used the aaaaa-aa
, but after reading ( The Internet Computer Interface Specification :: Internet Computer ), used the target canister id (effective canister id).
A working example would be nice, it’s been a bit boring as I was expecting it to be a bit simpler and the dfx command (ok that the target canister id is not passed as an argument to the call).
dfx canister --network=ic --no-wallet call aaaaa-aa canister_status "(record { canister_id= principal \"xxxxx\" })"