Merge pull request #216 from poanetwork/metamask-legacy-account-switcher
(Fix) Remove subscriber for legacy MetaMask account switcher event
This commit is contained in:
commit
0d04cebeb5
|
@ -37,14 +37,16 @@ export default async function getWeb3(netId = defaultNetId, onAccountChange) {
|
||||||
console.error('Unlock your wallet')
|
console.error('Unlock your wallet')
|
||||||
}
|
}
|
||||||
|
|
||||||
let currentAccount = defaultAccount ? defaultAccount.toLowerCase() : ''
|
if (web3.currentProvider.publicConfigStore) {
|
||||||
web3.currentProvider.publicConfigStore.on('update', function(obj) {
|
let currentAccount = defaultAccount ? defaultAccount.toLowerCase() : ''
|
||||||
const account = obj.selectedAddress
|
web3.currentProvider.publicConfigStore.on('update', function(obj) {
|
||||||
if (account && account !== currentAccount) {
|
const account = obj.selectedAddress
|
||||||
currentAccount = account
|
if (account && account !== currentAccount) {
|
||||||
onAccountChange(account)
|
currentAccount = account
|
||||||
}
|
onAccountChange(account)
|
||||||
})
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const web3NetId = await web3.eth.net.getId()
|
const web3NetId = await web3.eth.net.getId()
|
||||||
if (web3NetId === netId) {
|
if (web3NetId === netId) {
|
||||||
|
|
Loading…
Reference in New Issue