2020-07-08 21:48:39 +02:00
|
|
|
const version = 47
|
|
|
|
import { cloneDeep } from 'lodash'
|
|
|
|
|
|
|
|
/**
|
2020-07-16 15:16:41 +02:00
|
|
|
* Stringify the `metamaskNetworkId` property of all transactions
|
2020-07-08 21:48:39 +02:00
|
|
|
*/
|
|
|
|
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) {
|
2020-07-16 15:16:41 +02:00
|
|
|
const transactions = state?.TransactionController?.transactions
|
2020-07-08 21:48:39 +02:00
|
|
|
if (Array.isArray(transactions)) {
|
|
|
|
transactions.forEach((transaction) => {
|
|
|
|
if (typeof transaction.metamaskNetworkId === 'number') {
|
|
|
|
transaction.metamaskNetworkId = transaction.metamaskNetworkId.toString()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
return state
|
|
|
|
}
|