Merge pull request #3148 from MetaMask/localStorage-clean-up

remove BlacklistController from disk state
feature/default_network_editable
Frankie 7 years ago committed by GitHub
commit 1eec2ca8c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 11
      app/scripts/metamask-controller.js
  3. 34
      app/scripts/migrations/021.js
  4. 1
      app/scripts/migrations/index.js
  5. 1
      test/lib/migrations/002.json
  6. 16
      test/unit/migrations/021-test.js

@ -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.

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

@ -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('./019'),
require('./020'),
require('./021'),
]

File diff suppressed because one or more lines are too long

@ -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…
Cancel
Save