Skip to content

Commit

Permalink
Small improvement in getWeb3
Browse files Browse the repository at this point in the history
  • Loading branch information
varasev committed Nov 17, 2020
1 parent cc37e5c commit cb9fc16
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/utils/getWeb3.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ export default async function getWeb3(netId, onAccountChange) {
if (window.ethereum) {
web3 = new Web3(window.ethereum)
console.log('Injected web3 detected.')
window.ethereum.on('chainChanged', () => {
window.location.reload()
})
if (!window.ethereum.autoRefreshOnNetworkChange) {
window.ethereum.on('chainChanged', () => {
window.location.reload()
})
}
} else if (window.web3) {
web3 = new Web3(window.web3.currentProvider)
console.log('Injected web3 detected.')
Expand Down

0 comments on commit cb9fc16

Please sign in to comment.