aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/background.js
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2017-05-16 06:36:03 +0800
committerDan Finlay <dan@danfinlay.com>2017-05-16 06:36:03 +0800
commit6abdec608efadb99be96be498a7c706ec8503342 (patch)
tree674481221d80122521d3ec820d24f8158c6f9993 /app/scripts/background.js
parentf9c0fc0e8cb04f371ce8e99c41c74989841c2c24 (diff)
parentfe3e943169ec32cf6b1db3f9469855cbf8b51403 (diff)
downloadtangerine-wallet-browser-6abdec608efadb99be96be498a7c706ec8503342.tar
tangerine-wallet-browser-6abdec608efadb99be96be498a7c706ec8503342.tar.gz
tangerine-wallet-browser-6abdec608efadb99be96be498a7c706ec8503342.tar.bz2
tangerine-wallet-browser-6abdec608efadb99be96be498a7c706ec8503342.tar.lz
tangerine-wallet-browser-6abdec608efadb99be96be498a7c706ec8503342.tar.xz
tangerine-wallet-browser-6abdec608efadb99be96be498a7c706ec8503342.tar.zst
tangerine-wallet-browser-6abdec608efadb99be96be498a7c706ec8503342.zip
Merge branch 'master' into i1407-FixNonEditingTxForm
Diffstat (limited to 'app/scripts/background.js')
-rw-r--r--app/scripts/background.js38
1 files changed, 16 insertions, 22 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js
index 58f8e7556..e738a9712 100644
--- a/app/scripts/background.js
+++ b/app/scripts/background.js
@@ -1,6 +1,5 @@
const urlUtil = require('url')
const endOfStream = require('end-of-stream')
-const asyncQ = require('async-q')
const pipe = require('pump')
const LocalStorageStore = require('obs-store/lib/localStorage')
const storeTransform = require('obs-store/lib/transform')
@@ -30,34 +29,29 @@ let popupIsOpen = false
const diskStore = new LocalStorageStore({ storageKey: STORAGE_KEY })
// initialization flow
-asyncQ.waterfall([
- () => loadStateFromPersistence(),
- (initState) => setupController(initState),
-])
-.then(() => console.log('MetaMask initialization complete.'))
-.catch((err) => { console.error(err) })
+initialize().catch(console.error)
+
+async function initialize() {
+ const initState = await loadStateFromPersistence()
+ await setupController(initState)
+ console.log('MetaMask initialization complete.')
+}
//
// State and Persistence
//
-function loadStateFromPersistence () {
+async function loadStateFromPersistence () {
// migrations
const migrator = new Migrator({ migrations })
- const initialState = migrator.generateInitialState(firstTimeState)
- return asyncQ.waterfall([
- // read from disk
- () => Promise.resolve(diskStore.getState() || initialState),
- // migrate data
- (versionedData) => migrator.migrateData(versionedData),
- // write to disk
- (versionedData) => {
- diskStore.putState(versionedData)
- return Promise.resolve(versionedData)
- },
- // resolve to just data
- (versionedData) => Promise.resolve(versionedData.data),
- ])
+ // read from disk
+ let versionedData = diskStore.getState() || migrator.generateInitialState(firstTimeState)
+ // migrate data
+ versionedData = await migrator.migrateData(versionedData)
+ // write to disk
+ diskStore.putState(versionedData)
+ // return just the data
+ return versionedData.data
}
function setupController (initState) {