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: [ injected({ target: 'metaMask', // Use the native injected provider path in desktop browsers. // This avoids the MetaMask SDK account-sync bug we hit in the // in-app browser and keeps connect to a single requestAccounts flow. 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, })