|
|
@ -54,7 +54,7 @@ async function loadStateFromPersistence () { |
|
|
|
return migratedData.data |
|
|
|
return migratedData.data |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function setupController (initState, client) { |
|
|
|
async function setupController (initState, client) { |
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// MetaMask Controller
|
|
|
|
// MetaMask Controller
|
|
|
@ -74,20 +74,19 @@ function setupController (initState, client) { |
|
|
|
}) |
|
|
|
}) |
|
|
|
global.metamaskController = controller |
|
|
|
global.metamaskController = controller |
|
|
|
|
|
|
|
|
|
|
|
controller.store.subscribe((state) => { |
|
|
|
controller.store.subscribe(async (state) => { |
|
|
|
versionifyData(state) |
|
|
|
try { |
|
|
|
.then((versionedData) => dbController.put(versionedData)) |
|
|
|
const versionedData = await versionifyData(state) |
|
|
|
.catch((err) => { console.error(err) }) |
|
|
|
await dbController.put(versionedData) |
|
|
|
|
|
|
|
} catch (e) { console.error('METAMASK Error:', e) } |
|
|
|
}) |
|
|
|
}) |
|
|
|
function versionifyData (state) { |
|
|
|
|
|
|
|
return dbController.get() |
|
|
|
async function versionifyData (state) { |
|
|
|
.then((rawData) => { |
|
|
|
const rawData = await dbController.get() |
|
|
|
return Promise.resolve({ |
|
|
|
return { |
|
|
|
data: state, |
|
|
|
data: state, |
|
|
|
meta: rawData.meta, |
|
|
|
meta: rawData.meta, |
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
@ -118,12 +117,6 @@ function setupController (initState, client) { |
|
|
|
controller.setupProviderConnection(mx.createStream('provider'), originDomain) |
|
|
|
controller.setupProviderConnection(mx.createStream('provider'), originDomain) |
|
|
|
controller.setupPublicConfig(mx.createStream('publicConfig')) |
|
|
|
controller.setupPublicConfig(mx.createStream('publicConfig')) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// User Interface setup
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
return Promise.resolve() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
// // this will be useful later but commented out for linting for now (liiiinting)
|
|
|
|
// // this will be useful later but commented out for linting for now (liiiinting)
|
|
|
|
// function sendMessageToAllClients (message) {
|
|
|
|
// function sendMessageToAllClients (message) {
|
|
|
|