import { createConfig, createStorage, http } from 'wagmi' import { mainnet } from 'wagmi/chains' import { injected } from 'wagmi/connectors' export const chains = [mainnet] as const export const config = createConfig({ chains, connectors: [ // Generic injected connector — NOT pinned to target:'metaMask'. Pinning to // MetaMask made every other injected wallet (Rabby, Coinbase Wallet ext, // Brave, Frame, Trust, OKX…) fail to connect, and broke in browsers where // window.ethereum isn't MetaMask. wagmi v2 auto-discovers all injected // wallets via EIP-6963 (multiInjectedProviderDiscovery, on by default), so // a generic injected() connector covers them. This still uses the native // injected provider path (NOT the MetaMask SDK), so it avoids the SDK // account-sync bug that motivated the original pin. injected({ shimDisconnect: false }), ], transports: { [mainnet.id]: http(), }, // sessionStorage: clears on tab close, prevents stale auto-reconnect across sessions. // This means MetaMask only pops when the user explicitly clicks "Connect wallet". storage: typeof window !== 'undefined' ? createStorage({ storage: window.sessionStorage }) : undefined, // Disable silent auto-reconnect on page mount. // Without this, wagmi checks localStorage/sessionStorage for a saved connector // and tries to reconnect MetaMask silently — which can pop the MetaMask window. // User must explicitly click "Connect wallet" each session. ssr: true, })