fix - migration 30 undefinds (#6079)

feature/default_network_editable
Frankie 6 years ago committed by Dan Finlay
parent 7c0e0b6065
commit 4e27b644ab
  1. 34
      app/scripts/migrations/030.js

@ -24,23 +24,25 @@ module.exports = {
function transformState (state) { function transformState (state) {
const newState = state const newState = state
if (state.PreferencesController) {
const frequentRpcListDetail = newState.PreferencesController.frequentRpcListDetail const frequentRpcListDetail = newState.PreferencesController.frequentRpcListDetail
if (frequentRpcListDetail) { if (frequentRpcListDetail) {
frequentRpcListDetail.forEach((rpc, index) => { frequentRpcListDetail.forEach((rpc, index) => {
if (!!rpc.chainId && Number.isNaN(parseInt(rpc.chainId))) { if (!!rpc.chainId && Number.isNaN(parseInt(rpc.chainId))) {
delete frequentRpcListDetail[index].chainId delete frequentRpcListDetail[index].chainId
} }
}) })
newState.PreferencesController.frequentRpcListDetail = frequentRpcListDetail newState.PreferencesController.frequentRpcListDetail = frequentRpcListDetail
} }
if (newState.NetworkController.network && Number.isNaN(parseInt(newState.NetworkController.network))) {
delete newState.NetworkController.network
} }
if (state.NetworkController) {
if (newState.NetworkController.provider && newState.NetworkController.provider.chainId && Number.isNaN(parseInt(newState.NetworkController.provider.chainId))) { if (newState.NetworkController.network && Number.isNaN(parseInt(newState.NetworkController.network))) {
delete newState.NetworkController.provider.chainId delete newState.NetworkController.network
}
if (newState.NetworkController.provider && newState.NetworkController.provider.chainId && Number.isNaN(parseInt(newState.NetworkController.provider.chainId))) {
delete newState.NetworkController.provider.chainId
}
} }
return newState return newState

Loading…
Cancel
Save