aboutsummaryrefslogtreecommitdiffstats
path: root/test/lib
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2017-01-12 14:47:56 +0800
committerkumavis <aaron@kumavis.me>2017-01-12 14:47:56 +0800
commit3bc996878b467e1fa5fd63656bd465377daa137d (patch)
tree9c1661af778b58cd6d83c7d5fb5727f7a61b6dd9 /test/lib
parent2019c02fc0fc33d4bd98416654370250d7aa0ca6 (diff)
downloadtangerine-wallet-browser-3bc996878b467e1fa5fd63656bd465377daa137d.tar
tangerine-wallet-browser-3bc996878b467e1fa5fd63656bd465377daa137d.tar.gz
tangerine-wallet-browser-3bc996878b467e1fa5fd63656bd465377daa137d.tar.bz2
tangerine-wallet-browser-3bc996878b467e1fa5fd63656bd465377daa137d.tar.lz
tangerine-wallet-browser-3bc996878b467e1fa5fd63656bd465377daa137d.tar.xz
tangerine-wallet-browser-3bc996878b467e1fa5fd63656bd465377daa137d.tar.zst
tangerine-wallet-browser-3bc996878b467e1fa5fd63656bd465377daa137d.zip
background - move pojo migrator to outside of metamask controller
Diffstat (limited to 'test/lib')
-rw-r--r--test/lib/mock-config-manager.js64
1 files changed, 7 insertions, 57 deletions
diff --git a/test/lib/mock-config-manager.js b/test/lib/mock-config-manager.js
index 0e84aa001..c62d91da9 100644
--- a/test/lib/mock-config-manager.js
+++ b/test/lib/mock-config-manager.js
@@ -1,61 +1,11 @@
const ConfigManager = require('../../app/scripts/lib/config-manager')
-const ObservableStore = require('../../app/scripts/lib/observable/')
+const LocalStorageStore = require('../../app/scripts/lib/observable/local-storage')
+const firstTimeState = require('../../app/scripts/first-time-state')
const STORAGE_KEY = 'metamask-config'
-const extend = require('xtend')
module.exports = function() {
- let store = new ObservableStore(loadData())
- store.subscribe(setData)
- return new ConfigManager({ store })
-}
-
-function loadData () {
- var oldData = getOldStyleData()
- var newData
-
- try {
- newData = JSON.parse(window.localStorage[STORAGE_KEY])
- } catch (e) {}
-
- var data = extend({
- meta: {
- version: 0,
- },
- data: {
- config: {
- provider: {
- type: 'testnet',
- },
- },
- },
- }, oldData || null, newData || null)
- return data
-}
-
-function getOldStyleData () {
- var config, wallet, seedWords
-
- var result = {
- meta: { version: 0 },
- data: {},
- }
-
- try {
- config = JSON.parse(window.localStorage['config'])
- result.data.config = config
- } catch (e) {}
- try {
- wallet = JSON.parse(window.localStorage['lightwallet'])
- result.data.wallet = wallet
- } catch (e) {}
- try {
- seedWords = window.localStorage['seedWords']
- result.data.seedWords = seedWords
- } catch (e) {}
-
- return result
-}
-
-function setData (data) {
- window.localStorage[STORAGE_KEY] = JSON.stringify(data)
-}
+ let dataStore = new LocalStorageStore({ storageKey: STORAGE_KEY })
+ // initial state for first time users
+ if (!dataStore.get()) dataStore.put(firstTimeState)
+ return new ConfigManager({ store: dataStore })
+} \ No newline at end of file