-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4884 from MetaMask/TokensPerAccountBasis
Tokens per account & network basis
- Loading branch information
Showing
9 changed files
with
287 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// next version number | ||
const version = 28 | ||
|
||
/* | ||
normalizes txParams on unconfirmed txs | ||
*/ | ||
const clone = require('clone') | ||
|
||
module.exports = { | ||
version, | ||
|
||
migrate: async function (originalVersionedData) { | ||
const versionedData = clone(originalVersionedData) | ||
versionedData.meta.version = version | ||
const state = versionedData.data | ||
const newState = transformState(state) | ||
versionedData.data = newState | ||
return versionedData | ||
}, | ||
} | ||
|
||
function transformState (state) { | ||
const newState = state | ||
|
||
if (newState.PreferencesController) { | ||
if (newState.PreferencesController.tokens) { | ||
const identities = newState.TransactionController.identities | ||
const tokens = newState.PreferencesController.tokens | ||
newState.PreferencesController.accountTokens = {} | ||
for (const identity in identities) { | ||
newState.PreferencesController.accountTokens[identity] = {'mainnet': tokens} | ||
} | ||
newState.PreferencesController.tokens = [] | ||
} | ||
} | ||
|
||
return newState | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,4 +38,5 @@ module.exports = [ | |
require('./025'), | ||
require('./026'), | ||
require('./027'), | ||
require('./028'), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.