MCPcopy Create free account
hub / github.com/dfinity/orbit / resolveHost

Function resolveHost

cli/src/audit/agent.ts:14–33  ·  view source on GitHub ↗
(network: string)

Source from the content-addressed store, hash-verified

12};
13
14const resolveHost = async (network: string): Promise<string> => {
15 if (MAINNET_HOSTS[network]) return MAINNET_HOSTS[network];
16
17 // Fall back to dfx.json for local-replica style networks.
18 const dfxJsonPath = join(ROOT_PATH, 'dfx.json');
19 const raw = await readFile(dfxJsonPath, 'utf8').catch(() => null);
20 if (!raw) {
21 throw new Error(`Unknown network '${network}' and dfx.json not found at ${dfxJsonPath}.`);
22 }
23 const dfxJson = JSON.parse(raw) as {
24 networks?: Record<string, { providers?: string[]; bind?: string }>;
25 };
26 const cfg = dfxJson.networks?.[network];
27 if (!cfg) {
28 throw new Error(`Network '${network}' is not defined in dfx.json.`);
29 }
30 if (cfg.providers && cfg.providers.length > 0) return cfg.providers[0];
31 if (cfg.bind) return cfg.bind.startsWith('http') ? cfg.bind : `http://${cfg.bind}`;
32 throw new Error(`Network '${network}' has no providers or bind URL configured.`);
33};
34
35export const createStationActor = async (
36 canisterId: string,

Callers 1

createStationActorFunction · 0.85

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected