1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

WIP: indexdb is at an err state "provider is undefined"

This commit is contained in:
frankiebee 2017-03-23 11:41:32 -07:00
parent 45ab81fb45
commit 197e6e0b77
5 changed files with 26 additions and 13 deletions

View File

@ -11,7 +11,6 @@ module.exports = initializePopup
function initializePopup (connectionStream) { function initializePopup (connectionStream) {
// setup app // setup app
debugger
connectToAccountManager(connectionStream, setupApp) connectToAccountManager(connectionStream, setupApp)
} }

View File

@ -51,19 +51,35 @@ module.exports = class IndexDbController extends EventEmitter {
return this.requestObjectStore(key) return this.requestObjectStore(key)
.then((dataObject)=> { .then((dataObject)=> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const getRequest = dataObject.get(key) const getRequest = dataObject.get(key)
getRequest.onsuccess = (event) => resolve(event.currentTarget.result) getRequest.onsuccess = (event) => {
getRequest.onerror = (event) => reject(event) const serialized = event.currentTarget.result
try {
console.log('serialized:',serialized)
const state = serialized ? JSON.parse(serialized) : {}
resolve(state)
} catch (err) {
reject(err)
}
}
getRequest.onerror = (event) => reject(event)
})
}) })
})
} }
put (key, store) { put (key, state) {
return this.requestObjectStore(key, 'readwrite') return this.requestObjectStore(key, 'readwrite')
.then((dataObject)=> { .then((dataObject)=> {
const putRequest = dataObject.put(store) return new Promise((resolve, reject) => {
putRequest.onsuccess = (event) => Promise.resolve(event.currentTarget.result) try {
putRequest.onerror = (event) => Promise.reject(event) const serialized = JSON.stringify(state)
const putRequest = dataObject.put(serialized)
putRequest.onsuccess = (event) => resolve(event.currentTarget.result)
putRequest.onerror = (event) => reject(event)
} catch (err) {
reject(err)
}
})
}) })
} }

View File

@ -5,7 +5,6 @@ module.exports = setupIframe
function setupIframe(opts) { function setupIframe(opts) {
debugger
opts = opts || {} opts = opts || {}
var frame = Iframe({ var frame = Iframe({
src: opts.zeroClientProvider || 'https://zero.metamask.io/', src: opts.zeroClientProvider || 'https://zero.metamask.io/',

View File

@ -141,8 +141,8 @@ function setupController (initState, client) {
// storeTransform(versionifyData), // storeTransform(versionifyData),
// diskStore // diskStore
// ) // )
controller.store.subscribe((store) => { controller.store.subscribe((state) => {
dbController.put('dataStore', store) dbController.put('dataStore', state)
// .then((event) => {debugger}) // .then((event) => {debugger})
// .catch((err) => {debugger}) // .catch((err) => {debugger})
}) })

View File

@ -14,7 +14,6 @@ log.setLevel(debugMode ? 'debug' : 'warn')
function launchApp (opts) { function launchApp (opts) {
var accountManager = opts.accountManager var accountManager = opts.accountManager
actions._setBackgroundConnection(accountManager) actions._setBackgroundConnection(accountManager)
debugger
// check if we are unlocked first // check if we are unlocked first
accountManager.getState(function (err, metamaskState) { accountManager.getState(function (err, metamaskState) {
if (err) throw err if (err) throw err