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

34 lines
851 B
JavaScript
Raw Normal View History

import { cloneDeep } from 'lodash';
const version = 4;
export default {
version,
2016-05-11 22:10:54 +02:00
2020-11-03 00:41:28 +01: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',
};
break;
2016-05-11 22:10:54 +02:00
case 'https://rpc.metamask.io/':
safeVersionedData.data.config.provider = {
2016-06-21 22:18:32 +02:00
type: 'mainnet',
};
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
},
};