@@ -13,7 +13,17 @@ import OKXNetworkCheck from '@/components/OKXNetworkCheck'
1313interface ExtendedWindow extends Window {
1414 ethereum ?: {
1515 selectedAddress ?: string
16+ isOKX ?: boolean
17+ isOkxWallet ?: boolean
18+ isMetaMask ?: boolean
19+ isRabby ?: boolean
20+ isTrust ?: boolean
21+ isCoinbaseWallet ?: boolean
22+ chainId ?: string
23+ networkVersion ?: string
1624 }
25+ okxwallet ?: any
26+ okex ?: any
1727}
1828import { AppProps } from 'next/app'
1929import {
@@ -88,20 +98,45 @@ const queryClient = new QueryClient()
8898// https://github.com/0xRowdy/nextauth-siwe-route-handlers/blob/main/src/app/providers/web3-providers.tsx
8999export function AppProvider ( props : RainbowKitProviderProps ) {
90100 useEffect ( ( ) => {
101+ const win = window as ExtendedWindow
91102 console . log ( '=== OKX DIAGNOSTIC INFO ===' )
92103 console . log ( '1. User Agent:' , navigator . userAgent )
93104 console . log ( '2. Is OKX Browser?' , navigator . userAgent . toLowerCase ( ) . includes ( 'okx' ) )
94- console . log ( '3. Ethereum provider:' , window . ethereum ? 'Present' : 'Absent' )
95- if ( window . ethereum ) {
96- console . log ( '4. Provider details:' , {
97- isOKX : window . ethereum . isOKX ,
98- isMetaMask : window . ethereum . isMetaMask ,
99- chainId : window . ethereum . chainId ,
100- networkVersion : window . ethereum . networkVersion
105+ console . log ( '3. Ethereum provider:' , win . ethereum ? 'Present' : 'Absent' )
106+ console . log ( '4. window.okxwallet:' , win . okxwallet ? 'Present' : 'Absent' )
107+ console . log ( '5. window.okex:' , win . okex ? 'Present' : 'Absent' )
108+ if ( win . ethereum ) {
109+ console . log ( '6. Provider details:' , {
110+ isOKX : win . ethereum . isOKX ,
111+ isOkxWallet : win . ethereum . isOkxWallet ,
112+ isMetaMask : win . ethereum . isMetaMask ,
113+ isRabby : win . ethereum . isRabby ,
114+ isTrust : win . ethereum . isTrust ,
115+ isCoinbaseWallet : win . ethereum . isCoinbaseWallet ,
116+ chainId : win . ethereum . chainId ,
117+ networkVersion : win . ethereum . networkVersion
101118 } )
119+ // Log all enumerable properties of window.ethereum
120+ try {
121+ const props = Object . keys ( win . ethereum )
122+ console . log ( '7. window.ethereum properties:' , props )
123+ } catch ( e ) {
124+ console . log ( '7. Failed to enumerate window.ethereum properties:' , e )
125+ }
102126 }
103127 } , [ ] )
104128
129+ // Monitor wallet connection state
130+ const { address, chainId, isConnected, connector } = useAccount ( )
131+ useEffect ( ( ) => {
132+ console . log ( '=== WALLET CONNECTION STATE ===' )
133+ console . log ( 'Address:' , address )
134+ console . log ( 'Chain ID:' , chainId )
135+ console . log ( 'Is connected:' , isConnected )
136+ console . log ( 'Connector:' , connector ?. name )
137+ console . log ( 'Connector ID:' , connector ?. id )
138+ } , [ address , chainId , isConnected , connector ] )
139+
105140 return (
106141 < WagmiProvider config = { config } >
107142 < SessionProvider >
0 commit comments