|
1 |
| -import { Actor, HttpAgent } from "@dfinity/agent"; |
| 1 | +import { Actor, HttpAgent } from "@dfinity/agent" |
2 | 2 |
|
3 | 3 | // Imports and re-exports candid interface
|
4 |
| -import { idlFactory } from "./ck-doge-canister.did.js"; |
5 |
| -export { idlFactory } from "./ck-doge-canister.did.js"; |
| 4 | +import { idlFactory } from "./ck-doge-canister.did.js" |
| 5 | +export { idlFactory } from "./ck-doge-canister.did.js" |
6 | 6 |
|
7 | 7 | /* CANISTER_ID is replaced by webpack based on node environment
|
8 | 8 | * Note: canister environment variable will be standardized as
|
9 | 9 | * process.env.CANISTER_ID_<CANISTER_NAME_UPPERCASE>
|
10 | 10 | * beginning in dfx 0.15.0
|
11 | 11 | */
|
12 | 12 | export const canisterId =
|
13 |
| - process.env.CANISTER_ID_CK_DOGE_CANISTER; |
| 13 | + process.env.CANISTER_ID_CK_DOGE_CANISTER |
14 | 14 |
|
15 | 15 | export const createActor = (canisterId, options = {}) => {
|
16 |
| - const agent = options.agent || new HttpAgent({ ...options.agentOptions }); |
| 16 | + const agent = options.agent || new HttpAgent({ ...options.agentOptions }) |
17 | 17 |
|
18 | 18 | if (options.agent && options.agentOptions) {
|
19 | 19 | console.warn(
|
20 | 20 | "Detected both agent and agentOptions passed to createActor. Ignoring agentOptions and proceeding with the provided agent."
|
21 |
| - ); |
| 21 | + ) |
22 | 22 | }
|
23 | 23 |
|
24 | 24 | // Fetch root key for certificate validation during development
|
25 | 25 | if (process.env.DFX_NETWORK !== "ic") {
|
26 |
| - agent.fetchRootKey().catch((err) => { |
| 26 | + dynAgent.fetchRootKey().catch((err) => { |
27 | 27 | console.warn(
|
28 | 28 | "Unable to fetch root key. Check to ensure that your local replica is running"
|
29 |
| - ); |
30 |
| - console.error(err); |
31 |
| - }); |
| 29 | + ) |
| 30 | + console.error(err) |
| 31 | + }) |
32 | 32 | }
|
33 | 33 |
|
34 | 34 | // Creates an actor with using the candid interface and the HttpAgent
|
35 | 35 | return Actor.createActor(idlFactory, {
|
36 | 36 | agent,
|
37 | 37 | canisterId,
|
38 | 38 | ...options.actorOptions,
|
39 |
| - }); |
40 |
| -}; |
| 39 | + }) |
| 40 | +} |
0 commit comments