2021-02-04 19:15:23 +01:00
|
|
|
import { cloneDeep } from 'lodash';
|
2020-12-04 00:55:23 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const version = 50;
|
2020-12-04 00:55:23 +01:00
|
|
|
|
|
|
|
const LEGACY_LOCAL_STORAGE_KEYS = [
|
|
|
|
'METASWAP_GAS_PRICE_ESTIMATES_LAST_RETRIEVED',
|
|
|
|
'METASWAP_GAS_PRICE_ESTIMATES',
|
|
|
|
'cachedFetch',
|
|
|
|
'BASIC_PRICE_ESTIMATES_LAST_RETRIEVED',
|
|
|
|
'BASIC_PRICE_ESTIMATES',
|
|
|
|
'BASIC_GAS_AND_TIME_API_ESTIMATES',
|
|
|
|
'BASIC_GAS_AND_TIME_API_ESTIMATES_LAST_RETRIEVED',
|
|
|
|
'GAS_API_ESTIMATES_LAST_RETRIEVED',
|
|
|
|
'GAS_API_ESTIMATES',
|
2021-02-04 19:15:23 +01:00
|
|
|
];
|
2020-12-04 00:55:23 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Migrate metaMetrics state to the new MetaMetrics controller
|
|
|
|
*/
|
|
|
|
export default {
|
|
|
|
version,
|
|
|
|
async migrate(originalVersionedData) {
|
2021-02-04 19:15:23 +01:00
|
|
|
const versionedData = cloneDeep(originalVersionedData);
|
|
|
|
versionedData.meta.version = version;
|
2020-12-04 00:55:23 +01:00
|
|
|
|
|
|
|
LEGACY_LOCAL_STORAGE_KEYS.forEach((key) =>
|
2021-04-14 16:24:17 +02:00
|
|
|
window.localStorage?.removeItem(key),
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-12-04 00:55:23 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
return versionedData;
|
2020-12-04 00:55:23 +01:00
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|