1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 18:41:38 +01:00
metamask-extension/app/scripts/migrations/047.js
Mark Stacey a71cc2b137
Fix display of incoming transactions (#8942)
The `metamaskNetworkId` property in the `txMeta` for incoming
transactions was incorrectly set as a Number instead of a String. This
change was made accidentally as part of #8627.

As a result incoming transactions were being excluded from the
transaction list, as they didn't have a matching network ID.

`metamaskNetworkId` is now set to a string, and a migration has been
added to ensure `metamaskNetworkId` is converted to a string for any
incoming transactions in state.
2020-07-08 16:48:39 -03:00

31 lines
872 B
JavaScript

const version = 47
import { cloneDeep } from 'lodash'
/**
* Stringify numbers:
* - PreferencesController.frequentRpcListDetail item chainId
* - TransactionsController.transactions item metamaskNetworkId
*/
export default {
version,
migrate: async function (originalVersionedData) {
const versionedData = cloneDeep(originalVersionedData)
versionedData.meta.version = version
const state = versionedData.data
versionedData.data = transformState(state)
return versionedData
},
}
function transformState (state) {
const transactions = state?.TransactionsController?.transactions
if (Array.isArray(transactions)) {
transactions.forEach((transaction) => {
if (typeof transaction.metamaskNetworkId === 'number') {
transaction.metamaskNetworkId = transaction.metamaskNetworkId.toString()
}
})
}
return state
}