A Metamask fork with Infura removed and default networks editable
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ciphermask/app/scripts/migrations/048.js

39 lines
1.2 KiB

import { cloneDeep } from 'lodash'
const version = 48
/**
* 1. Delete NetworkController.settings
* 2a. Delete NetworkController.provider if set to type 'rpc'.
* It will be re-set to Mainnet on background initialization.
* 2b. Re-key provider.rpcTarget to provider.rpcUrl
*/
export default {
version,
async migrate (originalVersionedData) {
const versionedData = cloneDeep(originalVersionedData)
versionedData.meta.version = version
const state = versionedData.data
versionedData.data = transformState(state)
return versionedData
},
}
function transformState (state = {}) {
// 1. Delete NetworkController.settings
delete state.NetworkController?.settings
// 2. Delete NetworkController.provider or rename rpcTarget key
if (state.NetworkController?.provider?.type === 'rpc') {
delete state.NetworkController.provider
} else if (state.NetworkController?.provider) {
if ('rpcTarget' in state.NetworkController.provider) {
const rpcUrl = state.NetworkController.provider.rpcTarget
state.NetworkController.provider.rpcUrl = rpcUrl
}
delete state.NetworkController?.provider?.rpcTarget
}
return state
}