1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 19:26:13 +02:00

Improving handling for non-existent props in state migrations (#11829)

This commit is contained in:
ryanml 2021-08-17 19:18:53 -07:00 committed by GitHub
parent 932474127e
commit d96973e55b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 14 deletions

View File

@ -23,23 +23,27 @@ function transformState(state) {
state?.IncomingTransactionsController?.incomingTransactions;
if (Array.isArray(transactions)) {
transactions.forEach((transaction) => {
if (
transaction.type !== TRANSACTION_TYPES.RETRY &&
transaction.type !== TRANSACTION_TYPES.CANCEL
) {
transaction.type = transaction.transactionCategory;
if (transaction) {
if (
transaction.type !== TRANSACTION_TYPES.RETRY &&
transaction.type !== TRANSACTION_TYPES.CANCEL
) {
transaction.type = transaction.transactionCategory;
}
delete transaction.transactionCategory;
}
delete transaction.transactionCategory;
});
}
if (incomingTransactions) {
const incomingTransactionsEntries = Object.entries(incomingTransactions);
incomingTransactionsEntries.forEach(([key, transaction]) => {
delete transaction.transactionCategory;
state.IncomingTransactionsController.incomingTransactions[key] = {
...transaction,
type: TRANSACTION_TYPES.INCOMING,
};
if (transaction) {
delete transaction.transactionCategory;
state.IncomingTransactionsController.incomingTransactions[key] = {
...transaction,
type: TRANSACTION_TYPES.INCOMING,
};
}
});
}
return state;

View File

@ -15,14 +15,14 @@ export default {
const { PreferencesController } = versionedData.data;
if (Array.isArray(PreferencesController.tokens)) {
if (Array.isArray(PreferencesController?.tokens)) {
PreferencesController.tokens = PreferencesController.tokens.filter(
({ address }) => address,
);
}
if (
PreferencesController.accountTokens &&
PreferencesController?.accountTokens &&
typeof PreferencesController.accountTokens === 'object'
) {
Object.keys(PreferencesController.accountTokens).forEach((account) => {
@ -40,7 +40,7 @@ export default {
}
if (
PreferencesController.assetImages &&
PreferencesController?.assetImages &&
'undefined' in PreferencesController.assetImages
) {
delete PreferencesController.assetImages.undefined;