mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Merge pull request #3148 from MetaMask/localStorage-clean-up
remove BlacklistController from disk state
This commit is contained in:
commit
1eec2ca8c0
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
## Current Master
|
## Current Master
|
||||||
|
|
||||||
|
- Removed unneeded data from storage
|
||||||
- Add a "reset account" feature to Settings
|
- Add a "reset account" feature to Settings
|
||||||
- Add warning for importing some kinds of files.
|
- Add warning for importing some kinds of files.
|
||||||
|
|
||||||
|
@ -86,9 +86,7 @@ module.exports = class MetamaskController extends EventEmitter {
|
|||||||
})
|
})
|
||||||
this.infuraController.scheduleInfuraNetworkCheck()
|
this.infuraController.scheduleInfuraNetworkCheck()
|
||||||
|
|
||||||
this.blacklistController = new BlacklistController({
|
this.blacklistController = new BlacklistController()
|
||||||
initState: initState.BlacklistController,
|
|
||||||
})
|
|
||||||
this.blacklistController.scheduleUpdates()
|
this.blacklistController.scheduleUpdates()
|
||||||
|
|
||||||
// rpc provider
|
// rpc provider
|
||||||
@ -200,12 +198,7 @@ module.exports = class MetamaskController extends EventEmitter {
|
|||||||
this.networkController.store.subscribe((state) => {
|
this.networkController.store.subscribe((state) => {
|
||||||
this.store.updateState({ NetworkController: state })
|
this.store.updateState({ NetworkController: state })
|
||||||
})
|
})
|
||||||
this.blacklistController.store.subscribe((state) => {
|
|
||||||
this.store.updateState({ BlacklistController: state })
|
|
||||||
})
|
|
||||||
this.recentBlocksController.store.subscribe((state) => {
|
|
||||||
this.store.updateState({ RecentBlocks: state })
|
|
||||||
})
|
|
||||||
this.infuraController.store.subscribe((state) => {
|
this.infuraController.store.subscribe((state) => {
|
||||||
this.store.updateState({ InfuraController: state })
|
this.store.updateState({ InfuraController: state })
|
||||||
})
|
})
|
||||||
|
34
app/scripts/migrations/021.js
Normal file
34
app/scripts/migrations/021.js
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
const version = 21
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
This migration removes the BlackListController from disk state
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
const clone = require('clone')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
version,
|
||||||
|
|
||||||
|
migrate: function (originalVersionedData) {
|
||||||
|
const versionedData = clone(originalVersionedData)
|
||||||
|
versionedData.meta.version = version
|
||||||
|
try {
|
||||||
|
const state = versionedData.data
|
||||||
|
const newState = transformState(state)
|
||||||
|
versionedData.data = newState
|
||||||
|
} catch (err) {
|
||||||
|
console.warn(`MetaMask Migration #${version}` + err.stack)
|
||||||
|
}
|
||||||
|
return Promise.resolve(versionedData)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
function transformState (state) {
|
||||||
|
const newState = state
|
||||||
|
delete newState.BlacklistController
|
||||||
|
delete newState.RecentBlocks
|
||||||
|
return newState
|
||||||
|
}
|
||||||
|
|
@ -31,4 +31,5 @@ module.exports = [
|
|||||||
require('./018'),
|
require('./018'),
|
||||||
require('./019'),
|
require('./019'),
|
||||||
require('./020'),
|
require('./020'),
|
||||||
|
require('./021'),
|
||||||
]
|
]
|
||||||
|
1
test/lib/migrations/002.json
Normal file
1
test/lib/migrations/002.json
Normal file
File diff suppressed because one or more lines are too long
16
test/unit/migrations/021-test.js
Normal file
16
test/unit/migrations/021-test.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
const assert = require('assert')
|
||||||
|
|
||||||
|
const wallet2 = require('../../lib/migrations/002.json')
|
||||||
|
const migration21 = require('../../../app/scripts/migrations/021')
|
||||||
|
|
||||||
|
describe('wallet2 is migrated successfully with out the BlacklistController', () => {
|
||||||
|
it('should delete BlacklistController key', (done) => {
|
||||||
|
migration21.migrate(wallet2)
|
||||||
|
.then((migratedData) => {
|
||||||
|
assert.equal(migratedData.meta.version, 21)
|
||||||
|
assert(!migratedData.data.BlacklistController)
|
||||||
|
assert(!migratedData.data.RecentBlocks)
|
||||||
|
done()
|
||||||
|
}).catch(done)
|
||||||
|
})
|
||||||
|
})
|
Loading…
Reference in New Issue
Block a user