mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-29 23:58:06 +01:00
022ef13372
This migration had referred to the non-existent `TransactionsController` instead of `TransactionController`, so it effectively did nothing. Now it should work. This migration hasn't been included in any release yet, so we can fix it in-place instead of adding an additional corrected migration. The migration comment has also been updated, as it was inaccurate.
29 lines
787 B
JavaScript
29 lines
787 B
JavaScript
const version = 47
|
|
import { cloneDeep } from 'lodash'
|
|
|
|
/**
|
|
* Stringify the `metamaskNetworkId` property of all transactions
|
|
*/
|
|
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?.TransactionController?.transactions
|
|
if (Array.isArray(transactions)) {
|
|
transactions.forEach((transaction) => {
|
|
if (typeof transaction.metamaskNetworkId === 'number') {
|
|
transaction.metamaskNetworkId = transaction.metamaskNetworkId.toString()
|
|
}
|
|
})
|
|
}
|
|
return state
|
|
}
|