mirror of
https://github.com/stronk-dev/RandomChad.git
synced 2025-07-06 02:45:09 +02:00
fix minter
This commit is contained in:
parent
a22c02ed1e
commit
c782a665b0
@ -82,7 +82,7 @@ function App() {
|
|||||||
|
|
||||||
<h1>Rocketeer { action === 'mint' ? 'Minter' : 'Verifier' }</h1>
|
<h1>Rocketeer { action === 'mint' ? 'Minter' : 'Verifier' }</h1>
|
||||||
{ action === 'mint' && <p>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.</p> }
|
{ action === 'mint' && <p>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.</p> }
|
||||||
{ action === 'verify' && <p>This interface is used to veriy that you are the owner of a Rocketeer</p> }
|
{ action === 'verify' && <p>This interface is used to verify that you are the owner of a Rocketeer</p> }
|
||||||
<a className="button" href="/#" onClick={ metamasklogin }>
|
<a className="button" href="/#" onClick={ metamasklogin }>
|
||||||
<img alt="metamask fox" src={ Fox } />
|
<img alt="metamask fox" src={ Fox } />
|
||||||
Connect wallet
|
Connect wallet
|
||||||
|
@ -92,7 +92,7 @@ export default function Verifier() {
|
|||||||
return <Container>
|
return <Container>
|
||||||
|
|
||||||
<h1>Verify your hodlr status</h1>
|
<h1>Verify your hodlr status</h1>
|
||||||
<p>Verify your Rocketeer status by signing a message with your wallet. This does NOT trigger a transaction. Therefore it is free.</p>
|
<p>Verify your Rocketeer status by logging in with your wallet. This does NOT trigger a transaction. Therefore it is free.</p>
|
||||||
<input onChange={ e => setUsername( e.target.value ) } type="text" placeholder="Your Discord username" />
|
<input onChange={ e => setUsername( e.target.value ) } type="text" placeholder="Your Discord username" />
|
||||||
<a onClick={ showVerificationUrl } href="/#" className="button">Verify</a>
|
<a onClick={ showVerificationUrl } href="/#" className="button">Verify</a>
|
||||||
|
|
||||||
|
@ -6,8 +6,7 @@ import { ethers } from "ethers"
|
|||||||
|
|
||||||
// Convenience objects
|
// Convenience objects
|
||||||
const { providers: { Web3Provider }, Contract } = ethers
|
const { providers: { Web3Provider }, Contract } = ethers
|
||||||
const { ethereum } = window
|
export const provider = window.ethereum && new Web3Provider( window.ethereum )
|
||||||
export const provider = ethereum && new Web3Provider(ethereum)
|
|
||||||
export const signer = provider && provider.getSigner()
|
export const signer = provider && provider.getSigner()
|
||||||
|
|
||||||
// ///////////////////////////////
|
// ///////////////////////////////
|
||||||
@ -18,7 +17,7 @@ export const signer = provider && provider.getSigner()
|
|||||||
export async function getAddress() {
|
export async function getAddress() {
|
||||||
|
|
||||||
// Check if web3 is exposed
|
// Check if web3 is exposed
|
||||||
if( !ethereum ) throw new Error( 'No web3 provider detected, please install metamask' )
|
if( !window.ethereum ) throw new Error( 'No web3 provider detected, please install metamask' )
|
||||||
|
|
||||||
// Get the first address ( which is the selected address )
|
// Get the first address ( which is the selected address )
|
||||||
const [ address ] = await window.ethereum.request( { method: 'eth_requestAccounts' } )
|
const [ address ] = await window.ethereum.request( { method: 'eth_requestAccounts' } )
|
||||||
@ -34,11 +33,12 @@ export function useAddress() {
|
|||||||
|
|
||||||
// Set initial value if known
|
// Set initial value if known
|
||||||
useEffect( f => {
|
useEffect( f => {
|
||||||
if( ethereum && ethereum.selectedAddress ) setAddress( ethereum.selectedAddress )
|
log( 'useAddress setting: ', window.ethereum && window.ethereum.selectedAddress, ` based on `, window.ethereum )
|
||||||
|
if( window.ethereum && window.ethereum.selectedAddress ) setAddress( window.ethereum.selectedAddress )
|
||||||
}, [] )
|
}, [] )
|
||||||
|
|
||||||
// Create listener to accounts change
|
// Create listener to accounts change
|
||||||
useEffect( f => setListenerAndReturnUnlistener( ethereum, 'accountsChanged', addresses => {
|
useEffect( f => setListenerAndReturnUnlistener( window.ethereum, 'accountsChanged', addresses => {
|
||||||
log( 'Addresses changed to ', addresses )
|
log( 'Addresses changed to ', addresses )
|
||||||
setAddress( addresses[0] )
|
setAddress( addresses[0] )
|
||||||
} ), [ ] )
|
} ), [ ] )
|
||||||
@ -141,7 +141,7 @@ export function useChainId() {
|
|||||||
const [ chain, setChain ] = useState( undefined )
|
const [ chain, setChain ] = useState( undefined )
|
||||||
|
|
||||||
// Create listener to chain change
|
// Create listener to chain change
|
||||||
useEffect( f => setListenerAndReturnUnlistener( ethereum, 'chainChanged', chainId => {
|
useEffect( f => setListenerAndReturnUnlistener( window.ethereum, 'chainChanged', chainId => {
|
||||||
log( 'Chain changed to ', chainId )
|
log( 'Chain changed to ', chainId )
|
||||||
setChain( chainId )
|
setChain( chainId )
|
||||||
} ), [] )
|
} ), [] )
|
||||||
@ -152,8 +152,8 @@ export function useChainId() {
|
|||||||
// Check for initial chain and set to state
|
// Check for initial chain and set to state
|
||||||
( async () => {
|
( async () => {
|
||||||
|
|
||||||
if( !ethereum ) return
|
if( !window.ethereum ) return
|
||||||
const initialChain = await ethereum.request( { method: 'eth_chainId' } )
|
const initialChain = await window.ethereum.request( { method: 'eth_chainId' } )
|
||||||
log( 'Initial chain detected as ', initialChain )
|
log( 'Initial chain detected as ', initialChain )
|
||||||
setChain( initialChain )
|
setChain( initialChain )
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user