diff options
Diffstat (limited to 'ui/app')
-rw-r--r-- | ui/app/account-detail.js | 1 | ||||
-rw-r--r-- | ui/app/accounts/index.js | 6 | ||||
-rw-r--r-- | ui/app/actions.js | 173 | ||||
-rw-r--r-- | ui/app/app.js | 36 | ||||
-rw-r--r-- | ui/app/config.js | 16 | ||||
-rw-r--r-- | ui/app/eth-store-warning.js | 89 | ||||
-rw-r--r-- | ui/app/first-time/create-vault-complete.js | 74 | ||||
-rw-r--r-- | ui/app/first-time/init-menu.js | 22 | ||||
-rw-r--r-- | ui/app/first-time/restore-vault.js | 148 | ||||
-rw-r--r-- | ui/app/new-keychain.js | 29 | ||||
-rw-r--r-- | ui/app/recover-seed/confirmation.js | 148 | ||||
-rw-r--r-- | ui/app/reducers/app.js | 15 | ||||
-rw-r--r-- | ui/app/reducers/metamask.js | 6 |
13 files changed, 105 insertions, 658 deletions
diff --git a/ui/app/account-detail.js b/ui/app/account-detail.js index 01c7e8781..c41ba61fd 100644 --- a/ui/app/account-detail.js +++ b/ui/app/account-detail.js @@ -30,7 +30,6 @@ function mapStateToProps (state) { network: state.metamask.network, unconfTxs: valuesFor(state.metamask.unconfTxs), unconfMsgs: valuesFor(state.metamask.unconfMsgs), - isEthWarningConfirmed: state.metamask.isEthConfirmed, shapeShiftTxList: state.metamask.shapeShiftTxList, } } diff --git a/ui/app/accounts/index.js b/ui/app/accounts/index.js index 7551c498e..92054f24d 100644 --- a/ui/app/accounts/index.js +++ b/ui/app/accounts/index.js @@ -87,7 +87,7 @@ AccountsScreen.prototype.render = function () { h('div.footer.hover-white.pointer', { key: 'reveal-account-bar', onClick: () => { - this.onRevealAccount() + this.addNewKeyring() }, style: { display: 'flex', @@ -146,8 +146,8 @@ AccountsScreen.prototype.onShowDetail = function (address, event) { this.props.dispatch(actions.showAccountDetail(address)) } -AccountsScreen.prototype.onRevealAccount = function () { - this.props.dispatch(actions.revealAccount()) +AccountsScreen.prototype.addNewKeyring = function () { + this.props.dispatch(actions.addNewKeyring('Simple Key Pair')) } AccountsScreen.prototype.goHome = function () { diff --git a/ui/app/actions.js b/ui/app/actions.js index 1f0d8fc78..1f8ba7f04 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -1,4 +1,6 @@ var actions = { + _setBackgroundConnection: _setBackgroundConnection, + GO_HOME: 'GO_HOME', goHome: goHome, // menu state @@ -16,10 +18,6 @@ var actions = { SHOW_INIT_MENU: 'SHOW_INIT_MENU', SHOW_NEW_VAULT_SEED: 'SHOW_NEW_VAULT_SEED', SHOW_INFO_PAGE: 'SHOW_INFO_PAGE', - RECOVER_FROM_SEED: 'RECOVER_FROM_SEED', - CLEAR_SEED_WORD_CACHE: 'CLEAR_SEED_WORD_CACHE', - clearSeedWordCache: clearSeedWordCache, - recoverFromSeed: recoverFromSeed, unlockMetamask: unlockMetamask, unlockFailed: unlockFailed, showCreateVault: showCreateVault, @@ -27,12 +25,9 @@ var actions = { showInitializeMenu: showInitializeMenu, createNewVault: createNewVault, createNewVaultInProgress: createNewVaultInProgress, + addNewKeyring: addNewKeyring, showNewVaultSeed: showNewVaultSeed, showInfoPage: showInfoPage, - // seed recovery actions - REVEAL_SEED_CONFIRMATION: 'REVEAL_SEED_CONFIRMATION', - revealSeedConfirmation: revealSeedConfirmation, - requestRevealSeed: requestRevealSeed, // unlock screen UNLOCK_IN_PROGRESS: 'UNLOCK_IN_PROGRESS', UNLOCK_FAILED: 'UNLOCK_FAILED', @@ -53,8 +48,6 @@ var actions = { SHOW_ACCOUNTS_PAGE: 'SHOW_ACCOUNTS_PAGE', SHOW_CONF_TX_PAGE: 'SHOW_CONF_TX_PAGE', SHOW_CONF_MSG_PAGE: 'SHOW_CONF_MSG_PAGE', - REVEAL_ACCOUNT: 'REVEAL_ACCOUNT', - revealAccount: revealAccount, SET_CURRENT_FIAT: 'SET_CURRENT_FIAT', setCurrentFiat: setCurrentFiat, // account detail screen @@ -68,10 +61,6 @@ var actions = { showPrivateKey: showPrivateKey, SAVE_ACCOUNT_LABEL: 'SAVE_ACCOUNT_LABEL', saveAccountLabel: saveAccountLabel, - AGREE_TO_ETH_WARNING: 'AGREE_TO_ETH_WARNING', - agreeToEthWarning: agreeToEthWarning, - SHOW_ETH_WARNING: 'SHOW_ETH_WARNING', - showEthWarning: showEthWarning, // tx conf screen COMPLETED_TX: 'COMPLETED_TX', TRANSACTION_ERROR: 'TRANSACTION_ERROR', @@ -95,7 +84,6 @@ var actions = { backToAccountDetail: backToAccountDetail, showAccountsPage: showAccountsPage, showConfTxPage: showConfTxPage, - confirmSeedWords: confirmSeedWords, // config screen SHOW_CONFIG_PAGE: 'SHOW_CONFIG_PAGE', SET_RPC_TARGET: 'SET_RPC_TARGET', @@ -105,8 +93,6 @@ var actions = { showConfigPage: showConfigPage, setRpcTarget: setRpcTarget, setProviderType: setProviderType, - // hacky - need a way to get a reference to account manager - _setAccountManager: _setAccountManager, // loading overlay SHOW_LOADING: 'SHOW_LOADING_INDICATION', HIDE_LOADING: 'HIDE_LOADING_INDICATION', @@ -143,13 +129,18 @@ var actions = { RECOVERY_IN_PROGRESS: 'RECOVERY_IN_PROGRESS', BACK_TO_UNLOCK_VIEW: 'BACK_TO_UNLOCK_VIEW', backToUnlockView: backToUnlockView, + // SHOWING KEYCHAIN + SHOW_NEW_KEYCHAIN: 'SHOW_NEW_KEYCHAIN', + showNewKeychain: showNewKeychain, + + } module.exports = actions -var _accountManager = null -function _setAccountManager (accountManager) { - _accountManager = accountManager +var background = null +function _setBackgroundConnection(backgroundConnection) { + background = backgroundConnection } function goHome () { @@ -164,11 +155,16 @@ function tryUnlockMetamask (password) { return (dispatch) => { dispatch(actions.showLoadingIndication()) dispatch(actions.unlockInProgress()) - _accountManager.submitPassword(password, (err, selectedAccount) => { + background.submitPassword(password, (err, newState) => { dispatch(actions.hideLoadingIndication()) if (err) { dispatch(actions.unlockFailed()) } else { + dispatch(this.updateMetamaskState(newState)) + let selectedAccount + try { + selectedAccount = newState.metamask.selectedAccount + } catch (e) {} dispatch(actions.unlockMetamask(selectedAccount)) } }) @@ -178,45 +174,27 @@ function tryUnlockMetamask (password) { function createNewVault (password, entropy) { return (dispatch) => { dispatch(actions.createNewVaultInProgress()) - _accountManager.createNewVault(password, entropy, (err, result) => { + background.createNewVault(password, entropy, (err, newState) => { if (err) { return dispatch(actions.showWarning(err.message)) } - dispatch(actions.showNewVaultSeed(result)) - }) - } -} - -function revealSeedConfirmation () { - return { - type: this.REVEAL_SEED_CONFIRMATION, - } -} - -function requestRevealSeed (password) { - return (dispatch) => { - dispatch(actions.showLoadingIndication()) - _accountManager.tryPassword(password, (err, seed) => { - dispatch(actions.hideLoadingIndication()) - if (err) return dispatch(actions.displayWarning(err.message)) - _accountManager.recoverSeed((err, seed) => { - if (err) return dispatch(actions.displayWarning(err.message)) - dispatch(actions.showNewVaultSeed(seed)) - }) + dispatch(this.updateMetamaskState(newState)) + dispatch(this.showAccountsPage()) + dispatch(this.hideLoadingIndication()) }) } } -function recoverFromSeed (password, seed) { +function addNewKeyring (type, opts) { return (dispatch) => { - // dispatch(actions.createNewVaultInProgress()) dispatch(actions.showLoadingIndication()) - _accountManager.recoverFromSeed(password, seed, (err, metamaskState) => { - dispatch(actions.hideLoadingIndication()) - if (err) return dispatch(actions.displayWarning(err.message)) - - var account = Object.keys(metamaskState.identities)[0] - dispatch(actions.unlockMetamask(account)) + background.addNewKeyring(type, opts, (err, newState) => { + dispatch(this.hideLoadingIndication()) + if (err) { + return dispatch(actions.showWarning(err)) + } + dispatch(this.updateMetamaskState(newState)) + dispatch(this.showAccountsPage()) }) } } @@ -229,27 +207,14 @@ function showInfoPage () { function setSelectedAddress (address) { return (dispatch) => { - _accountManager.setSelectedAddress(address) - } -} - -function revealAccount () { - return (dispatch) => { - dispatch(actions.showLoadingIndication()) - _accountManager.revealAccount((err) => { - dispatch(actions.hideLoadingIndication()) - if (err) return dispatch(actions.displayWarning(err.message)) - dispatch({ - type: actions.REVEAL_ACCOUNT, - }) - }) + background.setSelectedAddress(address) } } function setCurrentFiat (fiat) { return (dispatch) => { dispatch(this.showLoadingIndication()) - _accountManager.setCurrentFiat(fiat, (data, err) => { + background.setCurrentFiat(fiat, (data, err) => { dispatch(this.hideLoadingIndication()) dispatch({ type: this.SET_CURRENT_FIAT, @@ -267,7 +232,7 @@ function signMsg (msgData) { return (dispatch) => { dispatch(actions.showLoadingIndication()) - _accountManager.signMessage(msgData, (err) => { + background.signMessage(msgData, (err) => { dispatch(actions.hideLoadingIndication()) if (err) return dispatch(actions.displayWarning(err.message)) @@ -278,7 +243,7 @@ function signMsg (msgData) { function signTx (txData) { return (dispatch) => { - _accountManager.setGasMultiplier(txData.gasMultiplier, (err) => { + background.setGasMultiplier(txData.gasMultiplier, (err) => { if (err) return dispatch(actions.displayWarning(err.message)) web3.eth.sendTransaction(txData, (err, data) => { dispatch(actions.hideLoadingIndication()) @@ -293,7 +258,7 @@ function signTx (txData) { function sendTx (txData) { return (dispatch) => { - _accountManager.approveTransaction(txData.id, (err) => { + background.approveTransaction(txData.id, (err) => { if (err) { alert(err.message) dispatch(actions.txError(err)) @@ -319,12 +284,12 @@ function txError (err) { } function cancelMsg (msgData) { - _accountManager.cancelMessage(msgData.id) + background.cancelMessage(msgData.id) return actions.completedTx(msgData.id) } function cancelTx (txData) { - _accountManager.cancelTransaction(txData.id) + background.cancelTransaction(txData.id) return actions.completedTx(txData.id) } @@ -353,7 +318,7 @@ function showInitializeMenu () { function agreeToDisclaimer () { return (dispatch) => { dispatch(this.showLoadingIndication()) - _accountManager.agreeToDisclaimer((err) => { + background.agreeToDisclaimer((err) => { if (err) { return dispatch(actions.showWarning(err.message)) } @@ -385,6 +350,12 @@ function backToUnlockView () { } } +function showNewKeychain () { + return { + type: actions.SHOW_NEW_KEYCHAIN, + } +} + // // unlock screen // @@ -417,7 +388,7 @@ function updateMetamaskState (newState) { function lockMetamask () { return (dispatch) => { - _accountManager.setLocked((err) => { + background.setLocked((err) => { dispatch(actions.hideLoadingIndication()) if (err) { return dispatch(actions.showWarning(err.message)) @@ -433,7 +404,7 @@ function lockMetamask () { function showAccountDetail (address) { return (dispatch) => { dispatch(actions.showLoadingIndication()) - _accountManager.setSelectedAddress(address, (err, address) => { + background.setSelectedAddress(address, (err, address) => { dispatch(actions.hideLoadingIndication()) if (err) { return dispatch(actions.showWarning(err.message)) @@ -453,27 +424,6 @@ function backToAccountDetail (address) { value: address, } } -function clearSeedWordCache (account) { - return { - type: actions.CLEAR_SEED_WORD_CACHE, - value: account, - } -} - -function confirmSeedWords () { - return (dispatch) => { - dispatch(actions.showLoadingIndication()) - _accountManager.clearSeedWordCache((err, account) => { - dispatch(actions.hideLoadingIndication()) - if (err) { - return dispatch(actions.showWarning(err.message)) - } - - console.log('Seed word cache cleared. ' + account) - dispatch(actions.showAccountDetail(account)) - }) - } -} function showAccountsPage () { return { @@ -525,7 +475,7 @@ function goBackToInitView () { // function setRpcTarget (newRpc) { - _accountManager.setRpcTarget(newRpc) + background.setRpcTarget(newRpc) return { type: actions.SET_RPC_TARGET, value: newRpc, @@ -533,7 +483,7 @@ function setRpcTarget (newRpc) { } function setProviderType (type) { - _accountManager.setProviderType(type) + background.setProviderType(type) return { type: actions.SET_PROVIDER_TYPE, value: type, @@ -541,7 +491,7 @@ function setProviderType (type) { } function useEtherscanProvider () { - _accountManager.useEtherscanProvider() + background.useEtherscanProvider() return { type: actions.USE_ETHERSCAN_PROVIDER, } @@ -600,7 +550,7 @@ function exportAccount (address) { return function (dispatch) { dispatch(self.showLoadingIndication()) - _accountManager.exportAccount(address, function (err, result) { + background.exportAccount(address, function (err, result) { dispatch(self.hideLoadingIndication()) if (err) { @@ -623,7 +573,7 @@ function showPrivateKey (key) { function saveAccountLabel (account, label) { return (dispatch) => { dispatch(actions.showLoadingIndication()) - _accountManager.saveAccountLabel(account, label, (err) => { + background.saveAccountLabel(account, label, (err) => { dispatch(actions.hideLoadingIndication()) if (err) { return dispatch(actions.showWarning(err.message)) @@ -642,28 +592,9 @@ function showSendPage () { } } -function agreeToEthWarning () { - return (dispatch) => { - _accountManager.agreeToEthWarning((err) => { - if (err) { - return dispatch(actions.showEthWarning(err.message)) - } - dispatch({ - type: actions.AGREE_TO_ETH_WARNING, - }) - }) - } -} - -function showEthWarning () { - return { - type: actions.SHOW_ETH_WARNING, - } -} - function buyEth (address, amount) { return (dispatch) => { - _accountManager.buyEth(address, amount) + background.buyEth(address, amount) dispatch({ type: actions.BUY_ETH, }) @@ -741,7 +672,7 @@ function coinShiftRquest (data, marketData) { if (response.error) return dispatch(actions.showWarning(response.error)) var message = ` Deposit your ${response.depositType} to the address bellow:` - _accountManager.createShapeShiftTx(response.deposit, response.depositType) + background.createShapeShiftTx(response.deposit, response.depositType) dispatch(actions.showQrView(response.deposit, [message].concat(marketData))) }) } diff --git a/ui/app/app.js b/ui/app/app.js index ae6fe7071..588aa9896 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -8,8 +8,7 @@ const ReactCSSTransitionGroup = require('react-addons-css-transition-group') const DisclaimerScreen = require('./first-time/disclaimer') const InitializeMenuScreen = require('./first-time/init-menu') const CreateVaultScreen = require('./first-time/create-vault') -const CreateVaultCompleteScreen = require('./first-time/create-vault-complete') -const RestoreVaultScreen = require('./first-time/restore-vault') +const NewKeyChainScreen = require('./new-keychain') // unlock const UnlockScreen = require('./unlock') // accounts @@ -19,7 +18,6 @@ const SendTransactionScreen = require('./send') const ConfirmTxScreen = require('./conf-tx') // other views const ConfigScreen = require('./config') -const RevealSeedConfirmation = require('./recover-seed/confirmation') const InfoScreen = require('./info') const LoadingIndicator = require('./components/loading') const SandwichExpando = require('sandwich-expando') @@ -27,7 +25,6 @@ const MenuDroppo = require('menu-droppo') const DropMenuItem = require('./components/drop-menu-item') const NetworkIndicator = require('./components/network') const Tooltip = require('./components/tooltip') -const EthStoreWarning = require('./eth-store-warning') const BuyView = require('./components/buy-button-subview') const QrView = require('./components/qr-code') module.exports = connect(mapStateToProps)(App) @@ -40,7 +37,6 @@ function mapStateToProps (state) { // state from plugin isLoading: state.appState.isLoading, isConfirmed: state.metamask.isConfirmed, - isEthConfirmed: state.metamask.isEthConfirmed, isInitialized: state.metamask.isInitialized, isUnlocked: state.metamask.isUnlocked, currentView: state.appState.currentView, @@ -396,24 +392,14 @@ App.prototype.renderPrimary = function () { return h(DisclaimerScreen, {key: 'disclaimerScreen'}) } - if (props.seedWords) { - return h(CreateVaultCompleteScreen, {key: 'createVaultComplete'}) - } - // show initialize screen if (!props.isInitialized || props.forgottenPassword) { + // show current view switch (props.currentView.name) { - case 'createVault': return h(CreateVaultScreen, {key: 'createVault'}) - case 'restoreVault': - return h(RestoreVaultScreen, {key: 'restoreVault'}) - - case 'createVaultComplete': - return h(CreateVaultCompleteScreen, {key: 'createVaultComplete'}) - default: return h(InitializeMenuScreen, {key: 'menuScreenInit'}) @@ -427,9 +413,6 @@ App.prototype.renderPrimary = function () { // show current view switch (props.currentView.name) { - case 'EthStoreWarning': - return h(EthStoreWarning, {key: 'ethWarning'}) - case 'accounts': return h(AccountsScreen, {key: 'accounts'}) @@ -439,22 +422,24 @@ App.prototype.renderPrimary = function () { case 'sendTransaction': return h(SendTransactionScreen, {key: 'send-transaction'}) + case 'newKeychain': + return h(NewKeyChainScreen, {key: 'new-keychain'}) + case 'confTx': return h(ConfirmTxScreen, {key: 'confirm-tx'}) case 'config': return h(ConfigScreen, {key: 'config'}) - case 'reveal-seed-conf': - return h(RevealSeedConfirmation, {key: 'reveal-seed-conf'}) - case 'info': return h(InfoScreen, {key: 'info'}) case 'createVault': return h(CreateVaultScreen, {key: 'createVault'}) + case 'buyEth': return h(BuyView, {key: 'buyEthView'}) + case 'qr': return h('div', { style: { @@ -510,12 +495,7 @@ App.prototype.renderCustomOption = function (rpcTarget) { }) case 'http://localhost:8545': - return h(DropMenuItem, { - label: 'Custom RPC', - closeMenu: () => this.setState({ isNetworkMenuOpen: false }), - action: () => this.props.dispatch(actions.showConfigPage()), - icon: h('i.fa.fa-question-circle.fa-lg'), - }) + return null default: return h(DropMenuItem, { diff --git a/ui/app/config.js b/ui/app/config.js index e09a38cd8..d4730e558 100644 --- a/ui/app/config.js +++ b/ui/app/config.js @@ -77,22 +77,6 @@ ConfigScreen.prototype.render = function () { currentConversionInformation(metamaskState, state), h('hr.horizontal-line'), - h('div', { - style: { - marginTop: '20px', - }, - }, [ - h('button', { - style: { - alignSelf: 'center', - }, - onClick (event) { - event.preventDefault() - state.dispatch(actions.revealSeedConfirmation()) - }, - }, 'Reveal Seed Words'), - ]), - ]), ]), ]) diff --git a/ui/app/eth-store-warning.js b/ui/app/eth-store-warning.js deleted file mode 100644 index fe3c7ce5d..000000000 --- a/ui/app/eth-store-warning.js +++ /dev/null @@ -1,89 +0,0 @@ -const connect = require('react-redux').connect -const Component = require('react').Component -const h = require('react-hyperscript') -const inherits = require('util').inherits -const actions = require('./actions') - -module.exports = connect(mapStateToProps)(EthStoreWarning) - -inherits(EthStoreWarning, Component) -function EthStoreWarning () { - Component.call(this) -} - -function mapStateToProps (state) { - return { - selectedAccount: state.metamask.selectedAccount, - } -} - -EthStoreWarning.prototype.render = function () { - - return ( - - h('.flex-column', { - key: 'ethWarning', - style: { - paddingTop: '25px', - marginRight: '30px', - marginLeft: '30px', - alignItems: 'center', - }, - }, [ - h('.warning', { - style: { - margin: '10px 10px 10px 10px', - }, - }, - `MetaMask is currently in beta; use - caution in storing large - amounts of ether. - `), - - h('i.fa.fa-exclamation-triangle.fa-4', { - style: { - fontSize: '152px', - color: '#AEAEAE', - textAlign: 'center', - }, - }), - - h('.flex-row', { - style: { - marginTop: '25px', - marginBottom: '10px', - }, - }, [ - h('input', { - type: 'checkbox', - onChange: this.toggleShowWarning.bind(this), - }), - h('.warning', { - style: { - fontSize: '11px', - }, - - }, 'Don\'t show me this message again'), - ]), - h('.flex-row', { - style: { - width: '100%', - justifyContent: 'space-around', - }, - }, [ - h('button', { - onClick: this.toAccounts.bind(this), - }, - 'Continue to MetaMask'), - ]), - ]) - ) -} - -EthStoreWarning.prototype.toggleShowWarning = function () { - this.props.dispatch(actions.agreeToEthWarning()) -} - -EthStoreWarning.prototype.toAccounts = function () { - this.props.dispatch(actions.showAccountDetail(this.props.account)) -} diff --git a/ui/app/first-time/create-vault-complete.js b/ui/app/first-time/create-vault-complete.js deleted file mode 100644 index 2b5413955..000000000 --- a/ui/app/first-time/create-vault-complete.js +++ /dev/null @@ -1,74 +0,0 @@ -const inherits = require('util').inherits -const Component = require('react').Component -const connect = require('react-redux').connect -const h = require('react-hyperscript') -const actions = require('../actions') - -module.exports = connect(mapStateToProps)(CreateVaultCompleteScreen) - -inherits(CreateVaultCompleteScreen, Component) -function CreateVaultCompleteScreen () { - Component.call(this) -} - -function mapStateToProps (state) { - return { - seed: state.appState.currentView.seedWords, - cachedSeed: state.metamask.seedWords, - } -} - -CreateVaultCompleteScreen.prototype.render = function () { - var state = this.props - var seed = state.seed || state.cachedSeed - - return ( - - h('.initialize-screen.flex-column.flex-center.flex-grow', [ - - // // subtitle and nav - // h('.section-title.flex-row.flex-center', [ - // h('h2.page-subtitle', 'Vault Created'), - // ]), - - h('h3.flex-center.text-transform-uppercase', { - style: { - background: '#EBEBEB', - color: '#AEAEAE', - marginTop: 36, - marginBottom: 8, - width: '100%', - fontSize: '20px', - padding: 6, - }, - }, [ - 'Vault Created', - ]), - - h('span.error', { // Error for the right red - style: { - padding: '12px 20px 0px 20px', - textAlign: 'center', - }, - }, 'These 12 words can restore all of your MetaMask accounts for this vault.\nSave them somewhere safe and secret.'), - - h('textarea.twelve-word-phrase', { - readOnly: true, - value: seed, - }), - - h('button.primary', { - onClick: () => this.confirmSeedWords(), - style: { - margin: '24px', - fontSize: '0.9em', - }, - }, 'I\'ve copied it somewhere safe'), - ]) - ) -} - -CreateVaultCompleteScreen.prototype.confirmSeedWords = function () { - this.props.dispatch(actions.confirmSeedWords()) -} - diff --git a/ui/app/first-time/init-menu.js b/ui/app/first-time/init-menu.js index 94a9d3df6..4fdade469 100644 --- a/ui/app/first-time/init-menu.js +++ b/ui/app/first-time/init-menu.js @@ -61,35 +61,19 @@ InitializeMenuScreen.prototype.renderMenu = function () { }, }, 'Create New Vault'), + /* h('.flex-row.flex-center.flex-grow', [ h('hr'), - h('div', 'OR'), + h('div', 'Advanced (Eventually?)'), h('hr'), ]), + */ - h('button.primary', { - onClick: this.showRestoreVault.bind(this), - style: { - margin: 12, - }, - }, 'Restore Existing Vault'), ]) ) } -// InitializeMenuScreen.prototype.splitWor = function() { -// this.props.dispatch(actions.showInitializeMenu()) -// } - -InitializeMenuScreen.prototype.showInitializeMenu = function () { - this.props.dispatch(actions.showInitializeMenu()) -} - InitializeMenuScreen.prototype.showCreateVault = function () { this.props.dispatch(actions.showCreateVault()) } -InitializeMenuScreen.prototype.showRestoreVault = function () { - this.props.dispatch(actions.showRestoreVault()) -} - diff --git a/ui/app/first-time/restore-vault.js b/ui/app/first-time/restore-vault.js deleted file mode 100644 index 4c1f21008..000000000 --- a/ui/app/first-time/restore-vault.js +++ /dev/null @@ -1,148 +0,0 @@ -const inherits = require('util').inherits -const PersistentForm = require('../../lib/persistent-form') -const connect = require('react-redux').connect -const h = require('react-hyperscript') -const actions = require('../actions') - -module.exports = connect(mapStateToProps)(RestoreVaultScreen) - -inherits(RestoreVaultScreen, PersistentForm) -function RestoreVaultScreen () { - PersistentForm.call(this) -} - -function mapStateToProps (state) { - return { - warning: state.appState.warning, - } -} - -RestoreVaultScreen.prototype.render = function () { - var state = this.props - this.persistentFormParentId = 'restore-vault-form' - - return ( - - h('.initialize-screen.flex-column.flex-center.flex-grow', [ - - h('h3.flex-center.text-transform-uppercase', { - style: { - background: '#EBEBEB', - color: '#AEAEAE', - marginBottom: 24, - width: '100%', - fontSize: '20px', - padding: 6, - }, - }, [ - 'Restore Vault', - ]), - - // wallet seed entry - h('h3', 'Wallet Seed'), - h('textarea.twelve-word-phrase.letter-spacey', { - dataset: { - persistentFormId: 'wallet-seed', - }, - placeholder: 'Enter your secret twelve word phrase here to restore your vault.', - }), - - // password - h('input.large-input.letter-spacey', { - type: 'password', - id: 'password-box', - placeholder: 'New Password (min 8 chars)', - dataset: { - persistentFormId: 'password', - }, - style: { - width: 260, - marginTop: 12, - }, - }), - - // confirm password - h('input.large-input.letter-spacey', { - type: 'password', - id: 'password-box-confirm', - placeholder: 'Confirm Password', - onKeyPress: this.onMaybeCreate.bind(this), - dataset: { - persistentFormId: 'password-confirmation', - }, - style: { - width: 260, - marginTop: 16, - }, - }), - - (state.warning) && ( - h('span.error.in-progress-notification', state.warning) - ), - - // submit - - h('.flex-row.flex-space-between', { - style: { - marginTop: 30, - width: '50%', - }, - }, [ - - // cancel - h('button.primary', { - onClick: this.showInitializeMenu.bind(this), - }, 'CANCEL'), - - // submit - h('button.primary', { - onClick: this.restoreVault.bind(this), - }, 'OK'), - - ]), - - ]) - - ) -} - -RestoreVaultScreen.prototype.showInitializeMenu = function () { - this.props.dispatch(actions.showInitializeMenu()) -} - -RestoreVaultScreen.prototype.onMaybeCreate = function (event) { - if (event.key === 'Enter') { - this.restoreVault() - } -} - -RestoreVaultScreen.prototype.restoreVault = function () { - // check password - var passwordBox = document.getElementById('password-box') - var password = passwordBox.value - var passwordConfirmBox = document.getElementById('password-box-confirm') - var passwordConfirm = passwordConfirmBox.value - if (password.length < 8) { - this.warning = 'Password not long enough' - - this.props.dispatch(actions.displayWarning(this.warning)) - return - } - if (password !== passwordConfirm) { - this.warning = 'Passwords don\'t match' - this.props.dispatch(actions.displayWarning(this.warning)) - return - } - // check seed - var seedBox = document.querySelector('textarea.twelve-word-phrase') - var seed = seedBox.value.trim() - if (seed.split(' ').length !== 12) { - this.warning = 'seed phrases are 12 words long' - this.props.dispatch(actions.displayWarning(this.warning)) - return - } - // submit - this.warning = null - this.props.dispatch(actions.displayWarning(this.warning)) - this.props.dispatch(actions.recoverFromSeed(password, seed)) -} diff --git a/ui/app/new-keychain.js b/ui/app/new-keychain.js new file mode 100644 index 000000000..cc9633166 --- /dev/null +++ b/ui/app/new-keychain.js @@ -0,0 +1,29 @@ +const inherits = require('util').inherits +const Component = require('react').Component +const h = require('react-hyperscript') +const connect = require('react-redux').connect + +module.exports = connect(mapStateToProps)(NewKeychain) + +function mapStateToProps (state) { + return {} +} + +inherits(NewKeychain, Component) +function NewKeychain () { + Component.call(this) +} + +NewKeychain.prototype.render = function () { + // const props = this.props + + return ( + h('div', { + style: { + background: 'blue', + }, + }, [ + h('h1', `Here's a list!!!!`), + ]) + ) +} diff --git a/ui/app/recover-seed/confirmation.js b/ui/app/recover-seed/confirmation.js deleted file mode 100644 index 55b18025f..000000000 --- a/ui/app/recover-seed/confirmation.js +++ /dev/null @@ -1,148 +0,0 @@ -const inherits = require('util').inherits - -const Component = require('react').Component -const connect = require('react-redux').connect -const h = require('react-hyperscript') -const actions = require('../actions') - -module.exports = connect(mapStateToProps)(RevealSeedConfirmatoin) - -inherits(RevealSeedConfirmatoin, Component) -function RevealSeedConfirmatoin () { - Component.call(this) -} - -function mapStateToProps (state) { - return { - warning: state.appState.warning, - } -} - -RevealSeedConfirmatoin.prototype.confirmationPhrase = 'I understand' - -RevealSeedConfirmatoin.prototype.render = function () { - const props = this.props - const state = this.state - - return ( - - h('.initialize-screen.flex-column.flex-center.flex-grow', [ - - h('h3.flex-center.text-transform-uppercase', { - style: { - background: '#EBEBEB', - color: '#AEAEAE', - marginBottom: 24, - width: '100%', - fontSize: '20px', - padding: 6, - }, - }, [ - 'Reveal Seed Words', - ]), - - h('.div', { - style: { - display: 'flex', - flexDirection: 'column', - padding: '20px', - justifyContent: 'center', - }, - }, [ - - h('h4', 'Do not recover your seed words in a public place! These words can be used to steal all your accounts.'), - - // confirmation - h('input.large-input.letter-spacey', { - type: 'password', - id: 'password-box', - placeholder: 'Enter your password to confirm', - onKeyPress: this.checkConfirmation.bind(this), - style: { - width: 260, - marginTop: '12px', - }, - }), - - h(`h4${state && state.confirmationWrong ? '.error' : ''}`, { - style: { - marginTop: '12px', - }, - }, 'Enter the phrase "I understand" to proceed.'), - - // confirm confirmation - h('input.large-input.letter-spacey', { - type: 'text', - id: 'confirm-box', - placeholder: this.confirmationPhrase, - onKeyPress: this.checkConfirmation.bind(this), - style: { - width: 260, - marginTop: 16, - }, - }), - - h('.flex-row.flex-space-between', { - style: { - marginTop: 30, - width: '50%', - }, - }, [ -// cancel - h('button.primary', { - onClick: this.goHome.bind(this), - }, 'CANCEL'), - - // submit - h('button.primary', { - onClick: this.revealSeedWords.bind(this), - }, 'OK'), - - ]), - - (props.warning) && ( - h('span.error', { - style: { - margin: '20px', - }, - }, props.warning.split('-')) - ), - - props.inProgress && ( - h('span.in-progress-notification', 'Generating Seed...') - ), - ]), - ]) - ) -} - -RevealSeedConfirmatoin.prototype.componentDidMount = function () { - document.getElementById('password-box').focus() -} - -RevealSeedConfirmatoin.prototype.goHome = function () { - this.props.dispatch(actions.showConfigPage(false)) -} - -// create vault - -RevealSeedConfirmatoin.prototype.checkConfirmation = function (event) { - if (event.key === 'Enter') { - event.preventDefault() - this.revealSeedWords() - } -} - -RevealSeedConfirmatoin.prototype.revealSeedWords = function () { - this.setState({ confirmationWrong: false }) - - const confirmBox = document.getElementById('confirm-box') - const confirmation = confirmBox.value - if (confirmation !== this.confirmationPhrase) { - confirmBox.value = '' - return this.setState({ confirmationWrong: true }) - } - - var password = document.getElementById('password-box').value - this.props.dispatch(actions.requestRevealSeed(password)) -} diff --git a/ui/app/reducers/app.js b/ui/app/reducers/app.js index c2ac099a6..d34cd1c2a 100644 --- a/ui/app/reducers/app.js +++ b/ui/app/reducers/app.js @@ -29,13 +29,10 @@ function reduceApp (state, action) { name: 'createVaultComplete', seedWords, } - var ethStoreWarning = { - name: 'EthStoreWarning', - } var appState = extend({ menuOpen: false, - currentView: seedWords ? seedConfView : !state.metamask.isEthConfirmed ? ethStoreWarning : defaultView, + currentView: seedWords ? seedConfView : defaultView, accountDetail: { subview: 'transactions', }, @@ -119,6 +116,15 @@ function reduceApp (state, action) { warning: null, }) + case actions.SHOW_NEW_KEYCHAIN: + return extend(appState, { + currentView: { + name: 'newKeychain', + context: appState.currentView.context, + }, + transForward: true, + }) + // unlock case actions.UNLOCK_METAMASK: @@ -540,4 +546,3 @@ function indexForPending (state, txId) { }) return idx } - diff --git a/ui/app/reducers/metamask.js b/ui/app/reducers/metamask.js index 84953d734..aa809b333 100644 --- a/ui/app/reducers/metamask.js +++ b/ui/app/reducers/metamask.js @@ -10,7 +10,6 @@ function reduceMetamask (state, action) { var metamaskState = extend({ isInitialized: false, isUnlocked: false, - isEthConfirmed: false, rpcTarget: 'https://rawtestrpc.metamask.io/', identities: {}, unconfTxs: {}, @@ -34,11 +33,6 @@ function reduceMetamask (state, action) { isConfirmed: true, }) - case actions.AGREE_TO_ETH_WARNING: - return extend(metamaskState, { - isEthConfirmed: !metamaskState.isEthConfirmed, - }) - case actions.UNLOCK_METAMASK: return extend(metamaskState, { isUnlocked: true, |