1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 02:10:12 +01:00

mascara/background: use async await

This commit is contained in:
frankiebee 2017-10-04 23:21:30 -07:00
parent 5eca4223b2
commit 7ec068d279

View File

@ -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({
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) {