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

feature/default_network_editable
ryanml 3 years ago committed by GitHub
parent 932474127e
commit d96973e55b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      app/scripts/migrations/053.js
  2. 6
      app/scripts/migrations/056.js

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

@ -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;

Loading…
Cancel
Save