Skip to content

Commit

Permalink
Merge pull request #1384 from MyEtherWallet/bug/match-metamask-networ…
Browse files Browse the repository at this point in the history
…k-on-unlock

bug/match metamask network on wallet unlock
  • Loading branch information
gamalielhere authored Sep 11, 2019
2 parents 0b17a46 + 4bb6666 commit bd6e234
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 13 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@

### Bug

- Fix network mismatch when using metamask [#1384](https://github.com/MyEtherWallet/MyEtherWallet/pull/1384)
- Restrict gas price minimum to 1 gwei [#1386](https://github.com/MyEtherWallet/MyEtherWallet/pull/1386)
- Fix the bug when user expend the token list, footer breaks [#1396](https://github.com/MyEtherWallet/MyEtherWallet/pull/1396)
- Fix the Buy subdomain feature and removed auction from ENS [#1409](https://github.com/MyEtherWallet/MyEtherWallet/pull/1409)


### Devop

- Sentry fixes, additional ledger errors, handle unlock wallet if wallet is null [#1394](https://github.com/MyEtherWallet/MyEtherWallet/pull/1394)
Expand Down
33 changes: 21 additions & 12 deletions src/layouts/InterfaceLayout/InterfaceLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -472,19 +472,25 @@ export default {
}
});
},
checkAndSetNetwork(id) {
if (this.network.type.chainID.toString() !== `${id}`) {
Object.keys(networkTypes).some(net => {
if (
networkTypes[net].chainID.toString() === `${id}` &&
this.Networks[net]
) {
this.$store.dispatch('switchNetwork', this.Networks[net][0]);
return true;
}
});
}
},
matchMetamaskNetwork() {
this.web3.eth.net.getId().then(id => {
this.checkAndSetNetwork(id);
});
window.ethereum.on('networkChanged', netId => {
if (this.network.type.chainID.toString() !== netId) {
Object.keys(networkTypes).some(net => {
if (
networkTypes[net].chainID.toString() === netId &&
this.Networks[net]
) {
this.$store.dispatch('switchNetwork', this.Networks[net][0]);
return true;
}
});
}
this.checkAndSetNetwork(netId);
});
},
setupOnlineEnvironment: web3Utils._.debounce(function() {
Expand All @@ -498,7 +504,10 @@ export default {
if (this.online) {
if (this.account.address !== null) {
if (this.account.identifier === WEB3_TYPE) {
if (window.web3.currentProvider.isMetamask) {
if (
window.web3.currentProvider.isMetaMask ||
window.web3.currentProvider.isMew
) {
this.checkMetamaskAddrChange();
this.matchMetamaskNetwork();
} else {
Expand Down
8 changes: 7 additions & 1 deletion src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,13 @@ const updateNotification = function({ commit, state }, val) {
newNotif[item] = state.notifications[item];
});

newNotif[address][val[1]] = val[2];
const idIndex = newNotif[address].findIndex(entry => entry.id === val[2].id);
if (idIndex > -1) {
newNotif[address][idIndex] = val[2];
} else {
newNotif[address][val[1]] = val[2];
}

commit('UPDATE_NOTIFICATION', newNotif);
};

Expand Down

1 comment on commit bd6e234

@mew-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.