Skip to content

Commit

Permalink
refactor: Extract createAgent parameters and export them
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonioVentilii-DFINITY committed Oct 16, 2024
1 parent ae6c752 commit a860e67
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions packages/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export * from "./enums/token.enums";
export * from "./parser/token";
export * from "./services/canister";
export * from "./types/actor-type.utils";
export type { CreateAgentParams } from "./types/agent.utils";
export type { CanisterOptions } from "./types/canister.options";
export type { QueryParams } from "./types/query.params";
export * from "./utils/actor.utils";
Expand Down
10 changes: 10 additions & 0 deletions packages/utils/src/types/agent.utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { Identity } from "@dfinity/agent";

export interface CreateAgentParams {
identity: Identity;
host?: string;
fetchRootKey?: boolean;
// @deprecated Shipped as an opt-in feature but, will become the default in next major version
verifyQuerySignatures?: boolean;
retryTimes?: number;
}
12 changes: 3 additions & 9 deletions packages/utils/src/utils/agent.utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Agent, Identity } from "@dfinity/agent";
import type { Agent } from "@dfinity/agent";
import { AnonymousIdentity, HttpAgent } from "@dfinity/agent";
import type { CreateAgentParams } from "../types/agent.utils";
import { nonNullish } from "./nullish.utils";

/**
Expand All @@ -26,14 +27,7 @@ export const createAgent = async ({
fetchRootKey = false,
verifyQuerySignatures = false,
retryTimes,
}: {
identity: Identity;
host?: string;
fetchRootKey?: boolean;
// @deprecated Shipped as an opt-in feature but, will become the default in next major version
verifyQuerySignatures?: boolean;
retryTimes?: number;
}): Promise<HttpAgent> => {
}: CreateAgentParams): Promise<HttpAgent> => {
return await HttpAgent.create({
identity,
...(nonNullish(host) && { host }),
Expand Down

0 comments on commit a860e67

Please sign in to comment.