56 lines
2.4 KiB
TypeScript
56 lines
2.4 KiB
TypeScript
import { createConfig, createStorage, http } from 'wagmi'
|
|
import { mainnet } from 'wagmi/chains'
|
|
import { injected, walletConnect } from 'wagmi/connectors'
|
|
|
|
export const chains = [mainnet] as const
|
|
|
|
// WalletConnect v2 requires a free project ID from https://cloud.walletconnect.com
|
|
// Set NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID in .env.local to enable:
|
|
// - QR code scanning (desktop → mobile wallet)
|
|
// - All WalletConnect-compatible mobile wallets
|
|
// Without it, only injected (browser extension) wallets are available.
|
|
const wcProjectId = process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID
|
|
|
|
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.
|
|
injected({ shimDisconnect: false }),
|
|
|
|
// WalletConnect v2 — enabled when NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID is set.
|
|
// Provides QR-code pairing (desktop ↔ mobile) and all WalletConnect wallets.
|
|
// Get a free project ID at https://cloud.walletconnect.com
|
|
...(wcProjectId
|
|
? [
|
|
walletConnect({
|
|
projectId: wcProjectId,
|
|
metadata: {
|
|
name: 'Trump Alpha',
|
|
description: 'Live crypto signals — Trump posts, BTC macro, KOL divergence',
|
|
url: process.env.NEXT_PUBLIC_SITE_URL || 'https://trumpsignal.com',
|
|
icons: ['https://trumpsignal.com/icon'],
|
|
},
|
|
showQrModal: true,
|
|
}),
|
|
]
|
|
: []),
|
|
],
|
|
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,
|
|
})
|