A Metamask fork with Infura removed and default networks editable
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
ciphermask/app/scripts/migrations/056.js

50 lines
1.4 KiB

import { cloneDeep } from 'lodash';
const version = 56;
/**
* Remove tokens that don't have an address due to
* lack of previous addToken validation. Also removes
* an unwanted, undefined image property
*/
export default {
version,
async migrate(originalVersionedData) {
const versionedData = cloneDeep(originalVersionedData);
versionedData.meta.version = version;
const { PreferencesController } = versionedData.data;
if (Array.isArray(PreferencesController?.tokens)) {
PreferencesController.tokens = PreferencesController.tokens.filter(
({ address }) => address,
);
}
if (
PreferencesController?.accountTokens &&
typeof PreferencesController.accountTokens === 'object'
) {
Object.keys(PreferencesController.accountTokens).forEach((account) => {
const chains = Object.keys(
PreferencesController.accountTokens[account],
);
chains.forEach((chain) => {
PreferencesController.accountTokens[account][chain] =
PreferencesController.accountTokens[account][chain].filter(
({ address }) => address,
);
});
});
}
if (
PreferencesController?.assetImages &&
'undefined' in PreferencesController.assetImages
) {
delete PreferencesController.assetImages.undefined;
}
return versionedData;
},
};