import { fetchPublicJson } from '@/utils/publicExplorer'

const WALLETCONNECT_CONFIG_PATH = '/explorer-api/v1/walletconnect/config'

export interface WalletConnectConfigResponse {
  status: 'stub' | 'disabled' | string
  enabled: boolean
  projectId: string
  relayUrl: string
  metadataUrl: string
  requiredNamespaces: string[]
  supportedChains: number[]
  fallbackAuth: string
  message: string
  updatedAt: string
}

export async function getWalletConnectConfig(): Promise<WalletConnectConfigResponse | null> {
  try {
    return await fetchPublicJson<WalletConnectConfigResponse>(WALLETCONNECT_CONFIG_PATH)
  } catch {
    return null
  }
}
