truffle-box / react-auth-box

Truffle, Webpack, React, Redux boilerplate with routing and authentication via a smart contract.
https://truffle-box.github.io/
MIT License
176 stars 66 forks source link

Injected web3 is not properly detected #6

Closed apackin closed 7 years ago

apackin commented 7 years ago

When using this with MetaMask the check for typeof web3 !== 'undefined' fails in getWeb3.js causing fallback to local web3

Error Received

console.log of 'No web3 instance injected, using Local web3.' even though MetaMask is enabled.

Fix:

Replace usage of the local web3 with window.web3 IE:

window.addEventListener('load', function(dispatch) {
    var results

    // Checking if Web3 has been injected by the browser (Mist/MetaMask)
    if (typeof window.web3 !== 'undefined') {
      // Use Mist/MetaMask's provider.
      results = {
        web3Instance: new Web3(window.web3.currentProvider)
      }

      console.log('Injected web3 detected.');

      resolve(store.dispatch(web3Initialized(results)))

https://github.com/apackin/groupBuy/commit/a6881c53fa1d0271a14766a86e1e6d9dd25086fb

OnlyOneJMJQ commented 7 years ago

Thank you for formatting this so well! It's now fixed.