Merge pull request #216 from poanetwork/metamask-legacy-account-switcher

(Fix) Remove subscriber for legacy MetaMask account switcher event
This commit is contained in:
phahulin 2019-12-04 10:59:06 +03:00 committed by GitHub
commit 0d04cebeb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 8 deletions

View File

@ -37,14 +37,16 @@ export default async function getWeb3(netId = defaultNetId, onAccountChange) {
console.error('Unlock your wallet')
}
let currentAccount = defaultAccount ? defaultAccount.toLowerCase() : ''
web3.currentProvider.publicConfigStore.on('update', function(obj) {
const account = obj.selectedAddress
if (account && account !== currentAccount) {
currentAccount = account
onAccountChange(account)
}
})
if (web3.currentProvider.publicConfigStore) {
let currentAccount = defaultAccount ? defaultAccount.toLowerCase() : ''
web3.currentProvider.publicConfigStore.on('update', function(obj) {
const account = obj.selectedAddress
if (account && account !== currentAccount) {
currentAccount = account
onAccountChange(account)
}
})
}
const web3NetId = await web3.eth.net.getId()
if (web3NetId === netId) {