2021-02-04 19:15:23 +01:00
|
|
|
import { cloneDeep } from 'lodash';
|
2017-02-15 20:14:53 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const version = 4;
|
2020-08-19 18:27:05 +02:00
|
|
|
|
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) {
|
2021-02-04 19:15:23 +01:00
|
|
|
const safeVersionedData = cloneDeep(versionedData);
|
|
|
|
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') {
|
2021-02-04 19:15:23 +01:00
|
|
|
return Promise.resolve(safeVersionedData);
|
2019-11-20 01:03:20 +01:00
|
|
|
}
|
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',
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
|
|
|
break;
|
2016-05-11 22:10:54 +02:00
|
|
|
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',
|
2021-02-04 19:15:23 +01: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
|
|
|
|
}
|
2021-02-04 19:15:23 +01:00
|
|
|
return Promise.resolve(safeVersionedData);
|
2016-06-21 22:18:32 +02:00
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|