import { Actor, HttpAgent } from '@dfinity/agent';
export const createActor = async ({ canisterId, idlFactory, identity, host }) => {
  const agent = new HttpAgent(Object.assign({ identity }, (host && { host })));
  if (process.env.LOCAL_IDENTITY) {
    // Fetch root key for certificate validation during development
    await agent.fetchRootKey();
  }
  // Creates an actor with using the candid interface and the HttpAgent
  return Actor.createActor(idlFactory, {
    agent,
    canisterId
  });
};
