import Minter from './components/minter' import Verifier from './components/verifier' import Fox from './assets/metamask-fox.svg' import { Container } from './components/generic' import { useState, useEffect } from 'react' import { log } from './modules/helpers' import { useAddress, getAddress } from './modules/web3' function App() { // /////////////////////////////// // States // /////////////////////////////// const [ action, setAction ] = useState( undefined ) const [ loading, setLoading ] = useState( 'Detecting metamask...' ) const [ error, setError ] = useState( undefined ) const address = useAddress() // /////////////////////////////// // Functions // /////////////////////////////// function checkAction() { const verify = window.location.href.includes( 'mode=verify' ) log( `Location is ${window.location.href}, ${ !verify ? 'not opening' : 'opening' } verifier` ) if( verify ) return setAction( 'verify' ) return setAction( 'mint' ) } // Handle user login interaction async function metamasklogin( e ) { e.preventDefault() try { setLoading( 'Connecting to Metamask' ) const address = await getAddress() log( 'Received: ', address ) } catch( e ) { setError( `Metamask error: ${ e.message || JSON.stringify( e ) }. Please reload the page.` ) } finally { setLoading( false ) } } // /////////////////////////////// // Lifecycle // /////////////////////////////// // Check for metamask on load useEffect( f => window.ethereum ? setLoading( false ) : setError( 'No web3 provider detected, please install metamask' ), [] ) // Check for action on load useEffect( f => { checkAction() window.addEventListener( 'popstate', checkAction ) }, [] ) // /////////////////////////////// // Rendering // /////////////////////////////// log( action, error, loading, address ) // Initialisation interface if( error || loading || !address ) return { error &&

{ error }

} { !error && loading &&

{ loading }

} { !address && ( !error && !loading ) && <>

Rocketeer { action == 'mint' ? 'Minter' : 'Verifier' }

{ action == 'mint' &&

This interface is used to mint new Rocketeer NFTs. Minting is free, except for the gas fees. After minting you can view your new Rocketeer and its attributes on Opensea.

} { action == 'verify' &&

This interface is used to veriy that you are the owner of a Rocketeer

} metamask fox Connect wallet }
if( action === 'mint' ) return if( action === 'verify' ) return else return <> } export default App;