mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-26 04:20:53 +01:00
398a45bfdd
This was done to reduce the number of direct dependencies we have. It should be functionally equivalent. The bundle size should not change, as we use `clone` as a transitive dependency in a number of places.
32 lines
831 B
JavaScript
32 lines
831 B
JavaScript
const version = 4
|
|
|
|
import { cloneDeep } from 'lodash'
|
|
|
|
export default {
|
|
version,
|
|
|
|
migrate: function (versionedData) {
|
|
const safeVersionedData = cloneDeep(versionedData)
|
|
safeVersionedData.meta.version = version
|
|
try {
|
|
if (safeVersionedData.data.config.provider.type !== 'rpc') {
|
|
return Promise.resolve(safeVersionedData)
|
|
}
|
|
switch (safeVersionedData.data.config.provider.rpcTarget) {
|
|
case 'https://testrpc.metamask.io/':
|
|
safeVersionedData.data.config.provider = {
|
|
type: 'testnet',
|
|
}
|
|
break
|
|
case 'https://rpc.metamask.io/':
|
|
safeVersionedData.data.config.provider = {
|
|
type: 'mainnet',
|
|
}
|
|
break
|
|
// No default
|
|
}
|
|
} catch (_) {}
|
|
return Promise.resolve(safeVersionedData)
|
|
},
|
|
}
|