1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-29 23:58:06 +01:00
metamask-extension/app/scripts/migrations/004.js

34 lines
841 B
JavaScript
Raw Normal View History

import { cloneDeep } from 'lodash'
const version = 4
export default {
version,
2016-05-11 22:10:54 +02:00
migrate (versionedData) {
const safeVersionedData = cloneDeep(versionedData)
safeVersionedData.meta.version = version
2016-05-11 22:10:54 +02:00
try {
if (safeVersionedData.data.config.provider.type !== 'rpc') {
return Promise.resolve(safeVersionedData)
}
switch (safeVersionedData.data.config.provider.rpcTarget) {
2016-05-11 22:10:54 +02:00
case 'https://testrpc.metamask.io/':
safeVersionedData.data.config.provider = {
2016-06-21 22:18:32 +02:00
type: 'testnet',
}
2016-05-11 22:10:54 +02:00
break
case 'https://rpc.metamask.io/':
safeVersionedData.data.config.provider = {
2016-06-21 22:18:32 +02:00
type: 'mainnet',
}
2016-05-11 22:10:54 +02:00
break
// No default
2016-05-11 22:10:54 +02:00
}
} catch (_) {
// empty
}
return Promise.resolve(safeVersionedData)
2016-06-21 22:18:32 +02:00
},
2016-05-11 22:10:54 +02:00
}