1
0
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:
Frankie 2018-01-31 14:15:52 -08:00 committed by GitHub
commit 1eec2ca8c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 55 additions and 9 deletions

View File

@ -2,6 +2,7 @@
## Current Master
- Removed unneeded data from storage
- Add a "reset account" feature to Settings
- Add warning for importing some kinds of files.

View File

@ -86,9 +86,7 @@ module.exports = class MetamaskController extends EventEmitter {
})
this.infuraController.scheduleInfuraNetworkCheck()
this.blacklistController = new BlacklistController({
initState: initState.BlacklistController,
})
this.blacklistController = new BlacklistController()
this.blacklistController.scheduleUpdates()
// rpc provider
@ -200,12 +198,7 @@ module.exports = class MetamaskController extends EventEmitter {
this.networkController.store.subscribe((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.store.updateState({ InfuraController: state })
})

View 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
}

View File

@ -31,4 +31,5 @@ module.exports = [
require('./018'),
require('./019'),
require('./020'),
require('./021'),
]

File diff suppressed because one or more lines are too long

View 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)
})
})