diff options
author | Frankie <frankie.pangilinan@consensys.net> | 2016-06-25 09:02:28 +0800 |
---|---|---|
committer | Frankie <frankie.pangilinan@consensys.net> | 2016-06-25 09:02:28 +0800 |
commit | ab55fefa1a4ebeaa9a42756a72d49b63f036b946 (patch) | |
tree | f30f51dd7dbe413b8944b230d14660a4c1a2fd61 /app/scripts/lib/config-manager.js | |
parent | ef743499cb93dc8360be20db03c4ab0676aa57bb (diff) | |
parent | 36a183db94e66999421980f50c2ab2e8d1ce2c3b (diff) | |
download | tangerine-wallet-browser-ab55fefa1a4ebeaa9a42756a72d49b63f036b946.tar tangerine-wallet-browser-ab55fefa1a4ebeaa9a42756a72d49b63f036b946.tar.gz tangerine-wallet-browser-ab55fefa1a4ebeaa9a42756a72d49b63f036b946.tar.bz2 tangerine-wallet-browser-ab55fefa1a4ebeaa9a42756a72d49b63f036b946.tar.lz tangerine-wallet-browser-ab55fefa1a4ebeaa9a42756a72d49b63f036b946.tar.xz tangerine-wallet-browser-ab55fefa1a4ebeaa9a42756a72d49b63f036b946.tar.zst tangerine-wallet-browser-ab55fefa1a4ebeaa9a42756a72d49b63f036b946.zip |
Merge branch 'master' into uiFixes
Diffstat (limited to 'app/scripts/lib/config-manager.js')
-rw-r--r-- | app/scripts/lib/config-manager.js | 56 |
1 files changed, 3 insertions, 53 deletions
diff --git a/app/scripts/lib/config-manager.js b/app/scripts/lib/config-manager.js index a3ff0bdfb..0af82c89c 100644 --- a/app/scripts/lib/config-manager.js +++ b/app/scripts/lib/config-manager.js @@ -1,9 +1,7 @@ const Migrator = require('pojo-migrator') -const extend = require('xtend') const MetamaskConfig = require('../config.js') const migrations = require('./migrations') -const STORAGE_KEY = 'metamask-config' const TESTNET_RPC = MetamaskConfig.network.testnet const MAINNET_RPC = MetamaskConfig.network.mainnet @@ -15,7 +13,7 @@ const MAINNET_RPC = MetamaskConfig.network.mainnet * particular portions of the state. */ module.exports = ConfigManager -function ConfigManager () { +function ConfigManager (opts) { // ConfigManager is observable and will emit updates this._subs = [] @@ -37,12 +35,10 @@ function ConfigManager () { // How to load initial config. // Includes step on migrating pre-pojo-migrator data. - loadData: loadData, + loadData: opts.loadData, // How to persist migrated config. - setData: function (data) { - window.localStorage[STORAGE_KEY] = JSON.stringify(data) - }, + setData: opts.setData, }) } @@ -280,49 +276,3 @@ ConfigManager.prototype.getConfirmed = function () { return ('isConfirmed' in data) && data.isConfirmed } -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 -} - |