@@ -7,6 +7,7 @@ export default function OKXNetworkCheck() {
77 const { chainId, address, isConnected, connector } = useAccount ( )
88 const [ isOKXBrowser , setIsOKXBrowser ] = useState ( false )
99 const [ showHelp , setShowHelp ] = useState ( false )
10+ const [ copied , setCopied ] = useState ( false )
1011
1112 useEffect ( ( ) => {
1213 const win = window as any
@@ -55,6 +56,35 @@ export default function OKXNetworkCheck() {
5556 console . log ( 'Connector ID:' , connector ?. id )
5657 } , [ address , chainId , isConnected , connector ] )
5758
59+ // Reset copied state after 2 seconds
60+ useEffect ( ( ) => {
61+ if ( copied ) {
62+ const timer = setTimeout ( ( ) => setCopied ( false ) , 2000 )
63+ return ( ) => clearTimeout ( timer )
64+ }
65+ } , [ copied ] )
66+
67+ const copyDiagnostics = async ( ) => {
68+ const diagnostics = {
69+ userAgent : navigator . userAgent ,
70+ chainId,
71+ address,
72+ isConnected,
73+ connector : connector ?. name ,
74+ connectorId : connector ?. id ,
75+ detectionMethod : isOKXBrowser ? 'OKX detected' : 'Not OKX' ,
76+ timestamp : new Date ( ) . toISOString ( )
77+ }
78+ const text = `OKX Diagnostics:\n${ JSON . stringify ( diagnostics , null , 2 ) } `
79+ try {
80+ await navigator . clipboard . writeText ( text )
81+ console . log ( 'Diagnostics copied to clipboard:' , diagnostics )
82+ setCopied ( true )
83+ } catch ( err ) {
84+ console . error ( 'Failed to copy diagnostics:' , err )
85+ }
86+ }
87+
5888 if ( ! showHelp ) return null
5989
6090 return (
@@ -103,7 +133,18 @@ export default function OKXNetworkCheck() {
103133 >
104134 Open in Chrome
105135 </ button >
136+ < button
137+ onClick = { copyDiagnostics }
138+ className = "flex-1 bg-purple-600 text-white py-2 rounded hover:bg-purple-700"
139+ >
140+ { copied ? 'Copied!' : 'Copy Diagnostics' }
141+ </ button >
106142 </ div >
143+ { copied && (
144+ < p className = "mt-3 text-sm text-green-600 text-center" >
145+ Diagnostics copied to clipboard. You can paste them in support chats.
146+ </ p >
147+ ) }
107148 </ div >
108149 </ div >
109150 )
0 commit comments