I get a 400 bad request
error when I try to query fetch_canister_logs
on mainnet.
POST https://icp0.io/api/v2/canister/aaaaa-aa/query 400 (Bad Request)
vendor.k4coD-xg.js:29 Uncaught (in promise) Ue: Server returned an error:
Code: 400 ()
Body: subnet_not_found
Why? Any idea?
export const canisterLogs = async ({
canisterId,
identity
}: {
canisterId: Principal;
identity: Identity;
}): Promise<canister_log_record[]> => {
const { fetch_canister_logs } = await getICActor({ identity, verifyQuerySignatures: false });
const { canister_log_records } = await fetch_canister_logs({
canister_id: canisterId
});
return canister_log_records;
};
export const getICActor = (params: GetAgentParams): Promise<ICActor> =>
createActor<ICActor>({
canisterId: MANAGEMENT_CANISTER_ID,
config: {
callTransform: transform,
queryTransform: transform
},
idlFactory: idlFactorIC,
...params
});
const transform = (
_methodName: string,
args: unknown[],
_callConfig: CallConfig
): { effectiveCanisterId: Principal } => {
const first = args[0] as any;
let effectiveCanisterId = MANAGEMENT_CANISTER_ID;
if (first && typeof first === 'object' && first.canister_id) {
effectiveCanisterId = Principal.from(first.canister_id as unknown);
}
return { effectiveCanisterId };
};
export const createActor = async <T = Record<string, ActorMethod>>({
canisterId,
idlFactory,
config = {},
...rest
}: {
canisterId: string | Principal;
idlFactory: IDL.InterfaceFactory;
config?: Pick<ActorConfig, 'callTransform' | 'queryTransform'>;
} & GetAgentParams): Promise<ActorSubclass<T>> => {
const agent = await getAgent(rest);
// Creates an actor with using the candid interface and the HttpAgent
return Actor.createActor(idlFactory, {
agent,
canisterId,
...config
});
};
const getAgent = async ({ identity, verifyQuerySignatures = true }: GetAgentParams) => {
const host = 'https://icp0.io';
return new HttpAgent({ identity, host, verifyQuerySignatures });
};