From e68e3ccc2fa912372d48a1382cefb81d843d6d41 Mon Sep 17 00:00:00 2001 From: Connor Bryan Date: Thu, 5 Jul 2018 12:29:23 -0500 Subject: [PATCH] Tighten web3 network change refresh validation (#2014) * Add a check to make sure a network even exists on the web3Wallet instance * Format snap files --- common/features/config/__snapshots__/sagas.spec.ts.snap | 4 +++- .../deterministicWallets/__snapshots__/sagas.spec.ts.snap | 6 ++++-- common/features/handleMetaMaskPolling.ts | 7 ++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/common/features/config/__snapshots__/sagas.spec.ts.snap b/common/features/config/__snapshots__/sagas.spec.ts.snap index bd0f53b5..5c78d960 100644 --- a/common/features/config/__snapshots__/sagas.spec.ts.snap +++ b/common/features/config/__snapshots__/sagas.spec.ts.snap @@ -12,7 +12,9 @@ Object { } `; -exports[`handleChangeNodeRequested* should select getCustomNodeConfig and match race snapshot 1`] = ` +exports[ + `handleChangeNodeRequested* should select getCustomNodeConfig and match race snapshot 1` +] = ` Object { "@@redux-saga/IO": true, "SELECT": Object { diff --git a/common/features/deterministicWallets/__snapshots__/sagas.spec.ts.snap b/common/features/deterministicWallets/__snapshots__/sagas.spec.ts.snap index 74d459c8..ab5c6333 100644 --- a/common/features/deterministicWallets/__snapshots__/sagas.spec.ts.snap +++ b/common/features/deterministicWallets/__snapshots__/sagas.spec.ts.snap @@ -1,6 +1,8 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`getDeterministicWallets* starting from publicKey & chainCode should match put snapshot 1`] = ` +exports[ + `getDeterministicWallets* starting from publicKey & chainCode should match put snapshot 1` +] = ` Object { "@@redux-saga/IO": true, "PUT": Object { @@ -215,4 +217,4 @@ Object { }, ], } -`; \ No newline at end of file +`; diff --git a/common/features/handleMetaMaskPolling.ts b/common/features/handleMetaMaskPolling.ts index 9c3d12b1..118ec5f7 100644 --- a/common/features/handleMetaMaskPolling.ts +++ b/common/features/handleMetaMaskPolling.ts @@ -37,7 +37,12 @@ export default async function handleMetaMaskPolling(store: Store): Pro const actualChainId = await getActualChainId(); const actualNetwork = configNetworksSelectors.getNetworkByChainId(state, actualChainId); - if (web3Wallet && actualNetwork && (web3Wallet as Web3Wallet).network !== actualNetwork.id) { + if ( + web3Wallet && + (web3Wallet as Web3Wallet).network && + actualNetwork && + (web3Wallet as Web3Wallet).network !== actualNetwork.id + ) { window.location.reload(); return true;