diff options
author | Dan Finlay <dan@danfinlay.com> | 2017-07-04 06:39:25 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2017-07-04 06:39:25 +0800 |
commit | 5eb3d5d485b17b98b19443d8def2f03dec9b38ef (patch) | |
tree | 1b814f7706a9eb559824624b87937631ac3ca505 /ui/classic/index.js | |
parent | d0d01552da8d0a6f58fb7c5be16947175ec90267 (diff) | |
download | tangerine-wallet-browser-5eb3d5d485b17b98b19443d8def2f03dec9b38ef.tar.gz tangerine-wallet-browser-5eb3d5d485b17b98b19443d8def2f03dec9b38ef.tar.zst tangerine-wallet-browser-5eb3d5d485b17b98b19443d8def2f03dec9b38ef.zip |
Make folder for responsive UI
Diffstat (limited to 'ui/classic/index.js')
-rw-r--r-- | ui/classic/index.js | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/ui/classic/index.js b/ui/classic/index.js new file mode 100644 index 000000000..a729138d3 --- /dev/null +++ b/ui/classic/index.js @@ -0,0 +1,58 @@ +const render = require('react-dom').render +const h = require('react-hyperscript') +const Root = require('./app/root') +const actions = require('./app/actions') +const configureStore = require('./app/store') +const txHelper = require('./lib/tx-helper') +global.log = require('loglevel') + +module.exports = launchMetamaskUi + + +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) return cb(err) + const store = startApp(metamaskState, accountManager, opts) + cb(null, store) + }) +} + +function startApp (metamaskState, accountManager, opts) { + // parse opts + const store = configureStore({ + + // metamaskState represents the cross-tab state + metamask: metamaskState, + + // appState represents the current tab's popup state + appState: {}, + + // Which blockchain we are using: + networkVersion: opts.networkVersion, + }) + + // if unconfirmed txs, start on txConf page + const unapprovedTxsAll = txHelper(metamaskState.unapprovedTxs, metamaskState.unapprovedMsgs, metamaskState.unapprovedPersonalMsgs, metamaskState.network) + if (unapprovedTxsAll.length > 0) { + store.dispatch(actions.showConfTxPage()) + } + + accountManager.on('update', function (metamaskState) { + store.dispatch(actions.updateMetamaskState(metamaskState)) + }) + + // start app + render( + h(Root, { + // inject initial state + store: store, + } + ), opts.container) + + return store +} |