UNPKG

@wormhole-foundation/sdk-connect

Version:

The core package for the Connect SDK, used in conjunction with 1 or more of the chain packages

56 lines 1.94 kB
import { circle } from "@wormhole-foundation/sdk-base"; import { buildConfig } from "@wormhole-foundation/sdk-definitions"; export const DEFAULT_TASK_TIMEOUT = 60 * 1000; // 1 minute in milliseconds export const CONFIG = { Mainnet: { api: "https://api.wormholescan.io", circleAPI: circle.circleAPI("Mainnet"), chains: buildConfig("Mainnet"), }, Testnet: { api: "https://api.testnet.wormholescan.io", circleAPI: circle.circleAPI("Testnet"), chains: buildConfig("Testnet"), }, Devnet: { api: "http://guardian:7071", // Tilt Guardian REST api circleAPI: "", chains: buildConfig("Devnet"), }, }; export function networkPlatformConfigs(network, platform) { return Object.fromEntries(Object.entries(CONFIG[network].chains).filter(([_, c]) => { return c.platform == platform; })); } // Apply any overrides to the base config export function applyWormholeConfigOverrides(network, overrides) { let base = CONFIG[network]; if (!overrides) return base; return override(base, overrides); } // Apply any overrides to the base config export function applyChainsConfigConfigOverrides(network, platform, overrides) { const base = networkPlatformConfigs(network, platform); if (!overrides) return base; return override(base, overrides); } // recurse through the overrides and apply them to the base config function override(base, overrides) { if (!base) base = {}; for (const [key, value] of Object.entries(overrides)) { if (typeof value === "object" && !Array.isArray(value)) { base[key] = override(base[key], value); } else { base[key] = value; } } return base; } const inNode = typeof process !== "undefined"; export const DEFAULT_NETWORK = (inNode && process.env["NETWORK"]) || "Testnet"; //# sourceMappingURL=config.js.map