import type { Config, ResolvedRegister } from "@wagmi/core"; import { createMemo, useContext, type Accessor } from "solid-js"; import { WagmiContext } from "../context.js"; import { WagmiProviderNotFoundError } from "../errors/context.js"; import type { ConfigParameter } from "../types/index.js"; export type UseConfigParameters = Accessor< ConfigParameter >; export type UseConfigReturnType = Accessor; export function useConfig( parameters: UseConfigParameters = () => ({}) ): UseConfigReturnType { return createMemo(() => { const config = parameters().config ?? useContext(WagmiContext); if (!config) throw new WagmiProviderNotFoundError(); return config as config; }); }