'use client';

import { WagmiProvider } from 'wagmi';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { PropsWithChildren, useEffect, useState } from 'react';
import { config } from '../config/web3';

const metadata = {
  name: 'MortgageFi',
  description: 'Decentralized Mortgage Lending Platform',
  url: 'https://mortgagefi.app',
  icons: ['https://mortgagefi.app/logo.png']
};

const queryClient = new QueryClient();

export function Web3Provider({ children }: PropsWithChildren) {
  const [mounted, setMounted] = useState(false);
  
  useEffect(() => {
    setMounted(true);
  }, []);

  return (
    <WagmiProvider config={config}>
      <QueryClientProvider client={queryClient}>
        {mounted && children}
      </QueryClientProvider>
    </WagmiProvider>
  );
}

