'use client';

import { getDefaultConfig } from '@rainbow-me/rainbowkit';
import { base } from 'wagmi/chains';
import { http, createStorage, noopStorage } from 'wagmi';

// Use noopStorage on the server to avoid indexedDB/localStorage reference errors
// during Next.js static generation, then hydrate real cookieStorage on the client.
const storage =
  typeof window === 'undefined'
    ? createStorage({ storage: noopStorage })
    : undefined;

export const wagmiConfig = getDefaultConfig({
  appName: 'Vaultfire',
  projectId:
    process.env.NEXT_PUBLIC_WC_PROJECT_ID ?? '5cfe6a0e5c3b4c3e8a5b1e1e1e1e1e1e',
  chains: [base],
  transports: {
    [base.id]: http('https://mainnet.base.org'),
  },
  ssr: true,
  storage,
});
