Skip to content

Commit

Permalink
fix - migration 30 undefinds (#6079)
Browse files Browse the repository at this point in the history
  • Loading branch information
frankiebee authored and danfinlay committed Jan 31, 2019
1 parent 7c0e0b6 commit 4e27b64
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions app/scripts/migrations/030.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,25 @@ module.exports = {

function transformState (state) {
const newState = state

const frequentRpcListDetail = newState.PreferencesController.frequentRpcListDetail
if (frequentRpcListDetail) {
frequentRpcListDetail.forEach((rpc, index) => {
if (!!rpc.chainId && Number.isNaN(parseInt(rpc.chainId))) {
delete frequentRpcListDetail[index].chainId
}
})
newState.PreferencesController.frequentRpcListDetail = frequentRpcListDetail
}

if (newState.NetworkController.network && Number.isNaN(parseInt(newState.NetworkController.network))) {
delete newState.NetworkController.network
if (state.PreferencesController) {
const frequentRpcListDetail = newState.PreferencesController.frequentRpcListDetail
if (frequentRpcListDetail) {
frequentRpcListDetail.forEach((rpc, index) => {
if (!!rpc.chainId && Number.isNaN(parseInt(rpc.chainId))) {
delete frequentRpcListDetail[index].chainId
}
})
newState.PreferencesController.frequentRpcListDetail = frequentRpcListDetail
}
}

if (newState.NetworkController.provider && newState.NetworkController.provider.chainId && Number.isNaN(parseInt(newState.NetworkController.provider.chainId))) {
delete newState.NetworkController.provider.chainId
if (state.NetworkController) {
if (newState.NetworkController.network && Number.isNaN(parseInt(newState.NetworkController.network))) {
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
Expand Down

0 comments on commit 4e27b64

Please sign in to comment.