import { IncomingMessage } from "http" ; import { NextRouter } from "next/router" ; export const getUserIp = ( req ) => { let ip = "" ; if ( req ) { const forwarded = req . headers [ "x-forwarded-for" ] as string ; ip = forwarded ? forwarded . split ( /, / ) [ 0 ] : req . connection . remoteAddress ; } return ip ; } ; export const appLog = ( ... args ) => window . ReactNativeWebView ? window . ReactNativeWebView . postMessage ( JSON . stringify ( { action : 'console.log' , args } ) ) : console . log ( ... args ) ; export const clipboardCopy = ( str ) => { try { navigator . clipboard . writeText ( str ) ; } catch ( err ) { console . log ( err ) ; } } ; export const navigateToSuccess = ( router , title , buttonText , returnUrl , isRedirect , text ? , subText ? ) => { router . push ( { pathname : '/success' , query : { title , text , buttonText , returnUrl , isRedirect , subText } } , "/success" ) ; } ; export const getRandomNFTFromArray = ( array ) => { return array [ Math . floor ( Math . random ( ) * array . length ) ] ; } ; export const timer = ( ms ) => new Promise ( res => setTimeout ( res , ms ) ) ;