mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Improving handling for non-existent props in state migrations (#11829)
This commit is contained in:
parent
932474127e
commit
d96973e55b
@ -23,23 +23,27 @@ function transformState(state) {
|
|||||||
state?.IncomingTransactionsController?.incomingTransactions;
|
state?.IncomingTransactionsController?.incomingTransactions;
|
||||||
if (Array.isArray(transactions)) {
|
if (Array.isArray(transactions)) {
|
||||||
transactions.forEach((transaction) => {
|
transactions.forEach((transaction) => {
|
||||||
if (
|
if (transaction) {
|
||||||
transaction.type !== TRANSACTION_TYPES.RETRY &&
|
if (
|
||||||
transaction.type !== TRANSACTION_TYPES.CANCEL
|
transaction.type !== TRANSACTION_TYPES.RETRY &&
|
||||||
) {
|
transaction.type !== TRANSACTION_TYPES.CANCEL
|
||||||
transaction.type = transaction.transactionCategory;
|
) {
|
||||||
|
transaction.type = transaction.transactionCategory;
|
||||||
|
}
|
||||||
|
delete transaction.transactionCategory;
|
||||||
}
|
}
|
||||||
delete transaction.transactionCategory;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (incomingTransactions) {
|
if (incomingTransactions) {
|
||||||
const incomingTransactionsEntries = Object.entries(incomingTransactions);
|
const incomingTransactionsEntries = Object.entries(incomingTransactions);
|
||||||
incomingTransactionsEntries.forEach(([key, transaction]) => {
|
incomingTransactionsEntries.forEach(([key, transaction]) => {
|
||||||
delete transaction.transactionCategory;
|
if (transaction) {
|
||||||
state.IncomingTransactionsController.incomingTransactions[key] = {
|
delete transaction.transactionCategory;
|
||||||
...transaction,
|
state.IncomingTransactionsController.incomingTransactions[key] = {
|
||||||
type: TRANSACTION_TYPES.INCOMING,
|
...transaction,
|
||||||
};
|
type: TRANSACTION_TYPES.INCOMING,
|
||||||
|
};
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return state;
|
return state;
|
||||||
|
@ -15,14 +15,14 @@ export default {
|
|||||||
|
|
||||||
const { PreferencesController } = versionedData.data;
|
const { PreferencesController } = versionedData.data;
|
||||||
|
|
||||||
if (Array.isArray(PreferencesController.tokens)) {
|
if (Array.isArray(PreferencesController?.tokens)) {
|
||||||
PreferencesController.tokens = PreferencesController.tokens.filter(
|
PreferencesController.tokens = PreferencesController.tokens.filter(
|
||||||
({ address }) => address,
|
({ address }) => address,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
PreferencesController.accountTokens &&
|
PreferencesController?.accountTokens &&
|
||||||
typeof PreferencesController.accountTokens === 'object'
|
typeof PreferencesController.accountTokens === 'object'
|
||||||
) {
|
) {
|
||||||
Object.keys(PreferencesController.accountTokens).forEach((account) => {
|
Object.keys(PreferencesController.accountTokens).forEach((account) => {
|
||||||
@ -40,7 +40,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
PreferencesController.assetImages &&
|
PreferencesController?.assetImages &&
|
||||||
'undefined' in PreferencesController.assetImages
|
'undefined' in PreferencesController.assetImages
|
||||||
) {
|
) {
|
||||||
delete PreferencesController.assetImages.undefined;
|
delete PreferencesController.assetImages.undefined;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user