Multi canister call

Hi @jaxopaxo,

It seems like you’re encountering challenges with managing connectivity and agent management.

To streamline your deployment process and enhance agent management, I recommend considering @ic-reactor/core. This library offers comprehensive solutions for managing agents, identities, and multiple actors.

Here are some examples of how you can manage agents and actors using @ic-reactor/core:

// agent.ts
import { createAgentManager } from "@ic-reactor/core"

export const agentManager = createAgentManager() // Connects to IC network by default
// actor.ts
import { createActorManager } from "@ic-reactor/core"
import * as candidA from "./declarations/candidA"
import * as candidB from "./declarations/candidB"
import { agentManager } from "./agent"

type CandidA = typeof candidA.candidA
type CandidB = typeof candidB.candidB

const actorA = createActorManager<CandidA>({
  agentManager,
  canisterId: candidA.canisterId,
  idlFactory: candidA.idlFactory,
})

const actorB = createActorManager<CandidB>({
  agentManager,
  canisterId: candidB.canisterId,
  idlFactory: candidB.idlFactory,
})

Once you’ve set up your agent and actors, you can use them as follows:

const { dataPromise } = actorA.queryCall({
  functionName: "serverFunc",
  args: [ principal ]
})
console.log("Response from CanisterA method:", await dataPromise)

const { dataPromise: versionActorB } = actorB.queryCall({
  functionName: "version",
})
console.log("Response from CanisterB method:", await versionActorB)

Feel free to explore the features of @ic-reactor/core to address your current challenges. If you need further assistance or have any questions about integrating the library into your project, don’t hesitate to reach out.