Merge pull request #3148 from MetaMask/localStorage-clean-up
remove BlacklistController from disk statefeature/default_network_editable
commit
1eec2ca8c0
@ -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 |
||||
} |
||||
|
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…
Reference in new issue