aboutsummaryrefslogtreecommitdiffstats
path: root/mascara
diff options
context:
space:
mode:
authorfrankiebee <frankie.diamond@gmail.com>2017-10-05 14:21:30 +0800
committerfrankiebee <frankie.diamond@gmail.com>2017-10-05 14:26:56 +0800
commit7ec068d279276a7e0fcc862d18e3fd3e1648728b (patch)
treebcf46073989b1efbff27231cb0cfed071076d809 /mascara
parent5eca4223b2986e101f64d71916aa7ce5a66064fc (diff)
downloadtangerine-wallet-browser-7ec068d279276a7e0fcc862d18e3fd3e1648728b.tar
tangerine-wallet-browser-7ec068d279276a7e0fcc862d18e3fd3e1648728b.tar.gz
tangerine-wallet-browser-7ec068d279276a7e0fcc862d18e3fd3e1648728b.tar.bz2
tangerine-wallet-browser-7ec068d279276a7e0fcc862d18e3fd3e1648728b.tar.lz
tangerine-wallet-browser-7ec068d279276a7e0fcc862d18e3fd3e1648728b.tar.xz
tangerine-wallet-browser-7ec068d279276a7e0fcc862d18e3fd3e1648728b.tar.zst
tangerine-wallet-browser-7ec068d279276a7e0fcc862d18e3fd3e1648728b.zip
mascara/background: use async await
Diffstat (limited to 'mascara')
-rw-r--r--mascara/src/background.js33
1 files changed, 13 insertions, 20 deletions
diff --git a/mascara/src/background.js b/mascara/src/background.js
index cf043a4f0..8aa1d8fe2 100644
--- a/mascara/src/background.js
+++ b/mascara/src/background.js
@@ -54,7 +54,7 @@ async function loadStateFromPersistence () {
return migratedData.data
}
-function setupController (initState, client) {
+async function setupController (initState, client) {
//
// MetaMask Controller
@@ -74,20 +74,19 @@ function setupController (initState, client) {
})
global.metamaskController = controller
- controller.store.subscribe((state) => {
- versionifyData(state)
- .then((versionedData) => dbController.put(versionedData))
- .catch((err) => { console.error(err) })
+ controller.store.subscribe(async (state) => {
+ try {
+ const versionedData = await versionifyData(state)
+ await dbController.put(versionedData)
+ } catch (e) { console.error('METAMASK Error:', e) }
})
- function versionifyData (state) {
- return dbController.get()
- .then((rawData) => {
- return Promise.resolve({
- data: state,
- meta: rawData.meta,
- })
-}
- )
+
+ async function versionifyData (state) {
+ const rawData = await dbController.get()
+ return {
+ data: state,
+ meta: rawData.meta,
+ }
}
//
@@ -118,12 +117,6 @@ function setupController (initState, client) {
controller.setupProviderConnection(mx.createStream('provider'), originDomain)
controller.setupPublicConfig(mx.createStream('publicConfig'))
}
-
- //
- // User Interface setup
- //
- return Promise.resolve()
-
}
// // this will be useful later but commented out for linting for now (liiiinting)
// function sendMessageToAllClients (message) {