2020-01-29 18:14:33 +01:00
|
|
|
import { cloneDeep } from 'lodash'
|
2017-02-15 20:14:53 +01:00
|
|
|
|
2020-08-19 18:27:05 +02:00
|
|
|
const version = 4
|
|
|
|
|
2020-01-09 04:34:58 +01:00
|
|
|
export default {
|
2017-02-15 20:14:53 +01:00
|
|
|
version,
|
2016-05-11 22:10:54 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
migrate(versionedData) {
|
2020-01-29 18:14:33 +01:00
|
|
|
const safeVersionedData = cloneDeep(versionedData)
|
2017-02-15 20:14:53 +01:00
|
|
|
safeVersionedData.meta.version = version
|
2016-05-11 22:10:54 +02:00
|
|
|
try {
|
2019-11-20 01:03:20 +01:00
|
|
|
if (safeVersionedData.data.config.provider.type !== 'rpc') {
|
|
|
|
return Promise.resolve(safeVersionedData)
|
|
|
|
}
|
2017-02-15 20:14:53 +01:00
|
|
|
switch (safeVersionedData.data.config.provider.rpcTarget) {
|
2016-05-11 22:10:54 +02:00
|
|
|
case 'https://testrpc.metamask.io/':
|
2017-02-15 20:14:53 +01:00
|
|
|
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/':
|
2017-02-15 20:14:53 +01:00
|
|
|
safeVersionedData.data.config.provider = {
|
2016-06-21 22:18:32 +02:00
|
|
|
type: 'mainnet',
|
|
|
|
}
|
2016-05-11 22:10:54 +02:00
|
|
|
break
|
2019-11-27 17:08:35 +01:00
|
|
|
// No default
|
2016-05-11 22:10:54 +02:00
|
|
|
}
|
2020-08-12 22:50:29 +02:00
|
|
|
} catch (_) {
|
|
|
|
// empty
|
|
|
|
}
|
2017-02-15 20:14:53 +01:00
|
|
|
return Promise.resolve(safeVersionedData)
|
2016-06-21 22:18:32 +02:00
|
|
|
},
|
2016-05-11 22:10:54 +02:00
|
|
|
}
|