2017-01-12 10:17:05 +01:00
|
|
|
const version = 4
|
|
|
|
|
2017-02-15 20:14:53 +01:00
|
|
|
const clone = require('clone')
|
|
|
|
|
2016-05-11 22:10:54 +02:00
|
|
|
module.exports = {
|
2017-02-15 20:14:53 +01:00
|
|
|
version,
|
2016-05-11 22:10:54 +02:00
|
|
|
|
2017-01-12 11:24:33 +01:00
|
|
|
migrate: function (versionedData) {
|
2017-02-15 20:14:53 +01:00
|
|
|
let safeVersionedData = clone(versionedData)
|
|
|
|
safeVersionedData.meta.version = version
|
2016-05-11 22:10:54 +02:00
|
|
|
try {
|
2017-02-15 20:14:53 +01:00
|
|
|
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/':
|
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
|
|
|
|
}
|
|
|
|
} catch (_) {}
|
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
|
|
|
}
|