aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2017-05-13 04:09:23 +0800
committerkumavis <aaron@kumavis.me>2017-05-13 04:09:23 +0800
commit5c9449dec1a4662ebb3e1ce18ede018a9e874c39 (patch)
tree39b7025c6115d63232f64ffbf4d899f625d97145
parent154eac4a3aed91bf63146601d0850e2ac2d4cfc5 (diff)
downloadtangerine-wallet-browser-5c9449dec1a4662ebb3e1ce18ede018a9e874c39.tar
tangerine-wallet-browser-5c9449dec1a4662ebb3e1ce18ede018a9e874c39.tar.gz
tangerine-wallet-browser-5c9449dec1a4662ebb3e1ce18ede018a9e874c39.tar.bz2
tangerine-wallet-browser-5c9449dec1a4662ebb3e1ce18ede018a9e874c39.tar.lz
tangerine-wallet-browser-5c9449dec1a4662ebb3e1ce18ede018a9e874c39.tar.xz
tangerine-wallet-browser-5c9449dec1a4662ebb3e1ce18ede018a9e874c39.tar.zst
tangerine-wallet-browser-5c9449dec1a4662ebb3e1ce18ede018a9e874c39.zip
background - drop async-q in favor of async/await
-rw-r--r--app/scripts/background.js38
-rw-r--r--package.json1
2 files changed, 16 insertions, 23 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) {
diff --git a/package.json b/package.json
index f4bdbd998..423821fbe 100644
--- a/package.json
+++ b/package.json
@@ -45,7 +45,6 @@
},
"dependencies": {
"async": "^1.5.2",
- "async-q": "^0.3.1",
"babel-runtime": "^6.23.0",
"bip39": "^2.2.0",
"bluebird": "^3.5.0",