diff options
author | Frankie <frankie.diamond@gmail.com> | 2017-04-03 14:04:21 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-03 14:04:21 +0800 |
commit | 235a70b9392d8b87eae4fc141e7f0be1d7788ee2 (patch) | |
tree | e7db8e909888506a21fa6c2fbfa04a3fa2cbcfc1 /ui/index.js | |
parent | 0a5c634081656c9450d4341b96bab6b4134a0b7a (diff) | |
parent | 86e882c51afca3a44bf20bcd1025161e214e6998 (diff) | |
download | tangerine-wallet-browser-235a70b9392d8b87eae4fc141e7f0be1d7788ee2.tar tangerine-wallet-browser-235a70b9392d8b87eae4fc141e7f0be1d7788ee2.tar.gz tangerine-wallet-browser-235a70b9392d8b87eae4fc141e7f0be1d7788ee2.tar.bz2 tangerine-wallet-browser-235a70b9392d8b87eae4fc141e7f0be1d7788ee2.tar.lz tangerine-wallet-browser-235a70b9392d8b87eae4fc141e7f0be1d7788ee2.tar.xz tangerine-wallet-browser-235a70b9392d8b87eae4fc141e7f0be1d7788ee2.tar.zst tangerine-wallet-browser-235a70b9392d8b87eae4fc141e7f0be1d7788ee2.zip |
Merge pull request #1300 from MetaMask/platform
Introduce Platform API
Diffstat (limited to 'ui/index.js')
-rw-r--r-- | ui/index.js | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/ui/index.js b/ui/index.js index 1a65f813c..e3648c374 100644 --- a/ui/index.js +++ b/ui/index.js @@ -4,27 +4,28 @@ const Root = require('./app/root') const actions = require('./app/actions') const configureStore = require('./app/store') const txHelper = require('./lib/tx-helper') -module.exports = launchApp +global.log = require('loglevel') -let debugMode = window.METAMASK_DEBUG -const log = require('loglevel') -window.log = log -log.setLevel(debugMode ? 'debug' : 'warn') +module.exports = launchMetamaskUi -function launchApp (opts) { + +log.setLevel(global.METAMASK_DEBUG ? 'debug' : 'warn') + +function launchMetamaskUi (opts, cb) { var accountManager = opts.accountManager actions._setBackgroundConnection(accountManager) // check if we are unlocked first accountManager.getState(function (err, metamaskState) { - if (err) throw err - startApp(metamaskState, accountManager, opts) + if (err) return cb(err) + const store = startApp(metamaskState, accountManager, opts) + cb(null, store) }) } function startApp (metamaskState, accountManager, opts) { // parse opts - var store = configureStore({ + const store = configureStore({ // metamaskState represents the cross-tab state metamask: metamaskState, @@ -37,7 +38,7 @@ function startApp (metamaskState, accountManager, opts) { }) // 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) { store.dispatch(actions.showConfTxPage()) } @@ -53,4 +54,6 @@ function startApp (metamaskState, accountManager, opts) { store: store, } ), opts.container) + + return store } |