|
|
@ -4,27 +4,28 @@ const Root = require('./app/root') |
|
|
|
const actions = require('./app/actions') |
|
|
|
const actions = require('./app/actions') |
|
|
|
const configureStore = require('./app/store') |
|
|
|
const configureStore = require('./app/store') |
|
|
|
const txHelper = require('./lib/tx-helper') |
|
|
|
const txHelper = require('./lib/tx-helper') |
|
|
|
module.exports = launchApp |
|
|
|
global.log = require('loglevel') |
|
|
|
|
|
|
|
|
|
|
|
let debugMode = window.METAMASK_DEBUG |
|
|
|
module.exports = launchMetamaskUi |
|
|
|
const log = require('loglevel') |
|
|
|
|
|
|
|
window.log = log |
|
|
|
|
|
|
|
log.setLevel(debugMode ? 'debug' : 'warn') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function launchApp (opts) { |
|
|
|
|
|
|
|
|
|
|
|
log.setLevel(global.METAMASK_DEBUG ? 'debug' : 'warn') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function launchMetamaskUi (opts, cb) { |
|
|
|
var accountManager = opts.accountManager |
|
|
|
var accountManager = opts.accountManager |
|
|
|
actions._setBackgroundConnection(accountManager) |
|
|
|
actions._setBackgroundConnection(accountManager) |
|
|
|
|
|
|
|
|
|
|
|
// 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) return cb(err) |
|
|
|
startApp(metamaskState, accountManager, opts) |
|
|
|
const store = startApp(metamaskState, accountManager, opts) |
|
|
|
|
|
|
|
cb(null, store) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function startApp (metamaskState, accountManager, opts) { |
|
|
|
function startApp (metamaskState, accountManager, opts) { |
|
|
|
// parse opts
|
|
|
|
// parse opts
|
|
|
|
var store = configureStore({ |
|
|
|
const store = configureStore({ |
|
|
|
|
|
|
|
|
|
|
|
// metamaskState represents the cross-tab state
|
|
|
|
// metamaskState represents the cross-tab state
|
|
|
|
metamask: metamaskState, |
|
|
|
metamask: metamaskState, |
|
|
@ -37,7 +38,7 @@ function startApp (metamaskState, accountManager, opts) { |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
// if unconfirmed txs, start on txConf page
|
|
|
|
// if unconfirmed txs, start on txConf page
|
|
|
|
var unapprovedTxsAll = txHelper(metamaskState.unapprovedTxs, metamaskState.unapprovedMsgs, metamaskState.unapprovedPersonalMsgs, metamaskState.network) |
|
|
|
const unapprovedTxsAll = txHelper(metamaskState.unapprovedTxs, metamaskState.unapprovedMsgs, metamaskState.unapprovedPersonalMsgs, metamaskState.network) |
|
|
|
if (unapprovedTxsAll.length > 0) { |
|
|
|
if (unapprovedTxsAll.length > 0) { |
|
|
|
store.dispatch(actions.showConfTxPage()) |
|
|
|
store.dispatch(actions.showConfTxPage()) |
|
|
|
} |
|
|
|
} |
|
|
@ -53,4 +54,6 @@ function startApp (metamaskState, accountManager, opts) { |
|
|
|
store: store, |
|
|
|
store: store, |
|
|
|
} |
|
|
|
} |
|
|
|
), opts.container) |
|
|
|
), opts.container) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return store |
|
|
|
} |
|
|
|
} |
|
|
|