truffle-box / react-box

Truffle, Webpack and React boilerplate.
https://truffle-box.github.io/
MIT License
736 stars 251 forks source link

Bugfixes in latest Truffle-React Box #185

Closed cryptoAnalyst99 closed 1 year ago

cryptoAnalyst99 commented 1 year ago

Hey Developer Team, there are two minor bugs in the latest version of the truffle-react box.

  1. the requestAccounts() method in the ETH Provider throws an error (at least for my setup : latest versions of react etc.) --> Fix: replace by web3.js method getAccounts()

  2. When someone does not have the Chrome Metamask extension installed the webpage remains blank, because the useEffect Hook int the init Callback function inside the EthProvider file throws an error. --> Fix: wrap the second useEffect hook (line 43 ff) into an if statement like this: if(window.ethereum) { ... }. That way also people that just playaround with Ganache and a simple Chrome browser (no dApp browser, no injected web3, etc.) can also use the box.

cliffoo commented 1 year ago

Hey @cryptoAnalyst99. So web3.eth.requestAccounts is the correct method to activate an injected wallet like MetaMask, see docs. And to your second point I'll make a note to gracefully error when there's no wallet. Thanks!