'use client' import { type Config, type GetChainsReturnType, type ResolvedRegister, getChains, } from '@wagmi/core' import { watchChains } from '@wagmi/core/internal' import { type Ref, ref } from 'vue-demi' import type { ConfigParameter, MaybeRefDeep } from '../types.js' import { useConfig } from './useConfig.js' export type UseChainsParameters = MaybeRefDeep< ConfigParameter > export type UseChainsReturnType = Ref< GetChainsReturnType > /** https://wagmi.sh/react/api/hooks/useChains */ export function useChains( parameters: UseChainsParameters = {}, ): UseChainsReturnType { const config = useConfig(parameters) const chains = ref(getChains(config)) watchChains(config, { onChange () { chains.value = getChains(config) } }) return chains }