From c782a665b00aedebd405e6f3bbb14bcbbec1a078 Mon Sep 17 00:00:00 2001 From: Mentor Palokaj Date: Wed, 20 Oct 2021 15:35:28 +0200 Subject: [PATCH] fix minter --- minter/src/App.js | 2 +- minter/src/components/verifier.js | 2 +- minter/src/modules/web3.js | 20 ++++++++++---------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/minter/src/App.js b/minter/src/App.js index 6bf42e9..3f61601 100644 --- a/minter/src/App.js +++ b/minter/src/App.js @@ -82,7 +82,7 @@ function App() {

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

} + { action === 'verify' &&

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

} metamask fox Connect wallet diff --git a/minter/src/components/verifier.js b/minter/src/components/verifier.js index 1bc6a56..2a8ca9c 100644 --- a/minter/src/components/verifier.js +++ b/minter/src/components/verifier.js @@ -92,7 +92,7 @@ export default function Verifier() { return

Verify your hodlr status

-

Verify your Rocketeer status by signing a message with your wallet. This does NOT trigger a transaction. Therefore it is free.

+

Verify your Rocketeer status by logging in with your wallet. This does NOT trigger a transaction. Therefore it is free.

setUsername( e.target.value ) } type="text" placeholder="Your Discord username" />
Verify diff --git a/minter/src/modules/web3.js b/minter/src/modules/web3.js index 07afe2b..9406045 100644 --- a/minter/src/modules/web3.js +++ b/minter/src/modules/web3.js @@ -6,8 +6,7 @@ import { ethers } from "ethers" // Convenience objects const { providers: { Web3Provider }, Contract } = ethers -const { ethereum } = window -export const provider = ethereum && new Web3Provider(ethereum) +export const provider = window.ethereum && new Web3Provider( window.ethereum ) export const signer = provider && provider.getSigner() // /////////////////////////////// @@ -18,10 +17,10 @@ export const signer = provider && provider.getSigner() export async function getAddress() { // 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 ) - const [ address ] = await window.ethereum.request({ method: 'eth_requestAccounts' }) + const [ address ] = await window.ethereum.request( { method: 'eth_requestAccounts' } ) return address @@ -34,14 +33,15 @@ export function useAddress() { // Set initial value if known 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 - useEffect( f => setListenerAndReturnUnlistener( ethereum, 'accountsChanged', addresses => { + useEffect( f => setListenerAndReturnUnlistener( window.ethereum, 'accountsChanged', addresses => { log( 'Addresses changed to ', addresses ) setAddress( addresses[0] ) - } ), [] ) + } ), [ ] ) return address @@ -141,7 +141,7 @@ export function useChainId() { const [ chain, setChain ] = useState( undefined ) // Create listener to chain change - useEffect( f => setListenerAndReturnUnlistener( ethereum, 'chainChanged', chainId => { + useEffect( f => setListenerAndReturnUnlistener( window.ethereum, 'chainChanged', chainId => { log( 'Chain changed to ', chainId ) setChain( chainId ) } ), [] ) @@ -152,8 +152,8 @@ export function useChainId() { // Check for initial chain and set to state ( async () => { - if( !ethereum ) return - const initialChain = await ethereum.request( { method: 'eth_chainId' } ) + if( !window.ethereum ) return + const initialChain = await window.ethereum.request( { method: 'eth_chainId' } ) log( 'Initial chain detected as ', initialChain ) setChain( initialChain )