From 5c9969e126b1da153d8b0f969fbb430d7a146b14 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Wed, 12 Oct 2016 16:31:15 -0700 Subject: Remove opinionated seed word code Completely breaking all account maangement, I have removed the opinionated seed-word code from the UI. Web3 injection still seems to work. --- ui/app/actions.js | 66 +------------ ui/app/app.js | 18 +--- ui/app/config.js | 16 ---- ui/app/first-time/create-vault-complete.js | 74 --------------- ui/app/first-time/init-menu.js | 20 +--- ui/app/first-time/restore-vault.js | 148 ----------------------------- ui/app/recover-seed/confirmation.js | 148 ----------------------------- 7 files changed, 4 insertions(+), 486 deletions(-) delete mode 100644 ui/app/first-time/create-vault-complete.js delete mode 100644 ui/app/first-time/restore-vault.js delete mode 100644 ui/app/recover-seed/confirmation.js (limited to 'ui') diff --git a/ui/app/actions.js b/ui/app/actions.js index 0cce9065e..fb33b7bc2 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -16,10 +16,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, @@ -29,10 +25,6 @@ var actions = { createNewVaultInProgress: createNewVaultInProgress, 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', @@ -95,7 +87,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', @@ -182,41 +173,7 @@ function createNewVault (password, entropy) { 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)) - }) - }) - } -} - -function recoverFromSeed (password, seed) { - 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)) + dispatch(actions.goHome()) }) } } @@ -451,27 +408,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 { diff --git a/ui/app/app.js b/ui/app/app.js index 71e0637d0..3266ced51 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -8,8 +8,6 @@ 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') // unlock const UnlockScreen = require('./unlock') // accounts @@ -19,7 +17,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') @@ -402,10 +399,6 @@ 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 @@ -414,12 +407,6 @@ App.prototype.renderPrimary = function () { 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'}) @@ -451,16 +438,15 @@ App.prototype.renderPrimary = function () { 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: { 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/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..9b733d0e7 100644 --- a/ui/app/first-time/init-menu.js +++ b/ui/app/first-time/init-menu.js @@ -63,33 +63,15 @@ InitializeMenuScreen.prototype.renderMenu = function () { 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/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)) -} -- cgit From 93ed918caa668951a5b28fd9c7683b4f19b65220 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Wed, 12 Oct 2016 16:43:35 -0700 Subject: Remove additional deprecated action --- ui/app/actions.js | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'ui') diff --git a/ui/app/actions.js b/ui/app/actions.js index fb33b7bc2..1b3fe00ad 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -45,8 +45,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 @@ -190,19 +188,6 @@ function 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, - }) - }) - } -} - function setCurrentFiat (fiat) { return (dispatch) => { dispatch(this.showLoadingIndication()) -- cgit From cd2c00a31873490c9129023abb35dd7983604b60 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Wed, 12 Oct 2016 16:43:48 -0700 Subject: Add minimal method signatures to new keyring controller --- ui/app/actions.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'ui') diff --git a/ui/app/actions.js b/ui/app/actions.js index 1b3fe00ad..4f3083707 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -171,7 +171,8 @@ function createNewVault (password, entropy) { if (err) { return dispatch(actions.showWarning(err.message)) } - dispatch(actions.goHome()) + dispatch(this.goHome()) + dispatch(this.hideLoadingIndication()) }) } } -- cgit From 1481a3ef8e3352eb74fa11c4f578d15d84c76de7 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Sat, 15 Oct 2016 10:48:12 -0700 Subject: Initial work on UI side --- ui/app/actions.js | 10 ++++++++++ ui/app/app.js | 4 ++++ ui/app/new-keychain.js | 33 +++++++++++++++++++++++++++++++++ ui/app/reducers/app.js | 10 +++++++++- 4 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 ui/app/new-keychain.js (limited to 'ui') diff --git a/ui/app/actions.js b/ui/app/actions.js index 4f3083707..bcae784d3 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -132,6 +132,10 @@ 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 @@ -326,6 +330,12 @@ function backToUnlockView () { } } +function showNewKeychain () { + return { + type: actions.SHOW_NEW_KEYCHAIN + } +} + // // unlock screen // diff --git a/ui/app/app.js b/ui/app/app.js index 3266ced51..7392e275d 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -8,6 +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 NewKeychainScreen = require('./new-keychain') // unlock const UnlockScreen = require('./unlock') // accounts @@ -432,6 +433,9 @@ 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'}) diff --git a/ui/app/new-keychain.js b/ui/app/new-keychain.js new file mode 100644 index 000000000..d6fefd0c7 --- /dev/null +++ b/ui/app/new-keychain.js @@ -0,0 +1,33 @@ +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!!!!`), + h('button', + { + onClick: () => this.props.dispatch(actions.goHome()) + }) + ]) + ) +} diff --git a/ui/app/reducers/app.js b/ui/app/reducers/app.js index c2ac099a6..2bfb2567a 100644 --- a/ui/app/reducers/app.js +++ b/ui/app/reducers/app.js @@ -119,6 +119,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 +549,3 @@ function indexForPending (state, txId) { }) return idx } - -- cgit From ad3fa24a28c0ec45dca43a257005626a4027487a Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Wed, 19 Oct 2016 14:55:08 -0700 Subject: Intermediary commit. --- ui/app/actions.js | 48 ++++++++++++++++++++++++------------------------ ui/index.js | 2 +- 2 files changed, 25 insertions(+), 25 deletions(-) (limited to 'ui') diff --git a/ui/app/actions.js b/ui/app/actions.js index bcae784d3..a594fa321 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -95,7 +95,7 @@ var actions = { setRpcTarget: setRpcTarget, setProviderType: setProviderType, // hacky - need a way to get a reference to account manager - _setAccountManager: _setAccountManager, + _setKeyringController: _setKeyringController, // loading overlay SHOW_LOADING: 'SHOW_LOADING_INDICATION', HIDE_LOADING: 'HIDE_LOADING_INDICATION', @@ -140,9 +140,9 @@ var actions = { module.exports = actions -var _accountManager = null -function _setAccountManager (accountManager) { - _accountManager = accountManager +var _keyringController = null +function _setKeyringController (accountManager) { + _keyringController = accountManager } function goHome () { @@ -157,7 +157,7 @@ function tryUnlockMetamask (password) { return (dispatch) => { dispatch(actions.showLoadingIndication()) dispatch(actions.unlockInProgress()) - _accountManager.submitPassword(password, (err, selectedAccount) => { + _keyringController.submitPassword(password, (err, selectedAccount) => { dispatch(actions.hideLoadingIndication()) if (err) { dispatch(actions.unlockFailed()) @@ -171,11 +171,11 @@ function tryUnlockMetamask (password) { function createNewVault (password, entropy) { return (dispatch) => { dispatch(actions.createNewVaultInProgress()) - _accountManager.createNewVault(password, entropy, (err, result) => { + _keyringController.createNewVault(password, entropy, (err, result) => { if (err) { return dispatch(actions.showWarning(err.message)) } - dispatch(this.goHome()) + dispatch(this.showAccountsPage()) dispatch(this.hideLoadingIndication()) }) } @@ -189,14 +189,14 @@ function showInfoPage () { function setSelectedAddress (address) { return (dispatch) => { - _accountManager.setSelectedAddress(address) + _keyringController.setSelectedAddress(address) } } function setCurrentFiat (fiat) { return (dispatch) => { dispatch(this.showLoadingIndication()) - _accountManager.setCurrentFiat(fiat, (data, err) => { + _keyringController.setCurrentFiat(fiat, (data, err) => { dispatch(this.hideLoadingIndication()) dispatch({ type: this.SET_CURRENT_FIAT, @@ -214,7 +214,7 @@ function signMsg (msgData) { return (dispatch) => { dispatch(actions.showLoadingIndication()) - _accountManager.signMessage(msgData, (err) => { + _keyringController.signMessage(msgData, (err) => { dispatch(actions.hideLoadingIndication()) if (err) return dispatch(actions.displayWarning(err.message)) @@ -238,7 +238,7 @@ function signTx (txData) { function sendTx (txData) { return (dispatch) => { - _accountManager.approveTransaction(txData.id, (err) => { + _keyringController.approveTransaction(txData.id, (err) => { if (err) { alert(err.message) dispatch(actions.txError(err)) @@ -264,12 +264,12 @@ function txError (err) { } function cancelMsg (msgData) { - _accountManager.cancelMessage(msgData.id) + _keyringController.cancelMessage(msgData.id) return actions.completedTx(msgData.id) } function cancelTx (txData) { - _accountManager.cancelTransaction(txData.id) + _keyringController.cancelTransaction(txData.id) return actions.completedTx(txData.id) } @@ -298,7 +298,7 @@ function showInitializeMenu () { function agreeToDisclaimer () { return (dispatch) => { dispatch(this.showLoadingIndication()) - _accountManager.agreeToDisclaimer((err) => { + _keyringController.agreeToDisclaimer((err) => { if (err) { return dispatch(actions.showWarning(err.message)) } @@ -368,7 +368,7 @@ function updateMetamaskState (newState) { function lockMetamask () { return (dispatch) => { - _accountManager.setLocked((err) => { + _keyringController.setLocked((err) => { dispatch(actions.hideLoadingIndication()) if (err) { return dispatch(actions.showWarning(err.message)) @@ -384,7 +384,7 @@ function lockMetamask () { function showAccountDetail (address) { return (dispatch) => { dispatch(actions.showLoadingIndication()) - _accountManager.setSelectedAddress(address, (err, address) => { + _keyringController.setSelectedAddress(address, (err, address) => { dispatch(actions.hideLoadingIndication()) if (err) { return dispatch(actions.showWarning(err.message)) @@ -455,7 +455,7 @@ function goBackToInitView () { // function setRpcTarget (newRpc) { - _accountManager.setRpcTarget(newRpc) + _keyringController.setRpcTarget(newRpc) return { type: actions.SET_RPC_TARGET, value: newRpc, @@ -463,7 +463,7 @@ function setRpcTarget (newRpc) { } function setProviderType (type) { - _accountManager.setProviderType(type) + _keyringController.setProviderType(type) return { type: actions.SET_PROVIDER_TYPE, value: type, @@ -471,7 +471,7 @@ function setProviderType (type) { } function useEtherscanProvider () { - _accountManager.useEtherscanProvider() + _keyringController.useEtherscanProvider() return { type: actions.USE_ETHERSCAN_PROVIDER, } @@ -530,7 +530,7 @@ function exportAccount (address) { return function (dispatch) { dispatch(self.showLoadingIndication()) - _accountManager.exportAccount(address, function (err, result) { + _keyringController.exportAccount(address, function (err, result) { dispatch(self.hideLoadingIndication()) if (err) { @@ -553,7 +553,7 @@ function showPrivateKey (key) { function saveAccountLabel (account, label) { return (dispatch) => { dispatch(actions.showLoadingIndication()) - _accountManager.saveAccountLabel(account, label, (err) => { + _keyringController.saveAccountLabel(account, label, (err) => { dispatch(actions.hideLoadingIndication()) if (err) { return dispatch(actions.showWarning(err.message)) @@ -574,7 +574,7 @@ function showSendPage () { function agreeToEthWarning () { return (dispatch) => { - _accountManager.agreeToEthWarning((err) => { + _keyringController.agreeToEthWarning((err) => { if (err) { return dispatch(actions.showEthWarning(err.message)) } @@ -593,7 +593,7 @@ function showEthWarning () { function buyEth (address, amount) { return (dispatch) => { - _accountManager.buyEth(address, amount) + _keyringController.buyEth(address, amount) dispatch({ type: actions.BUY_ETH, }) @@ -671,7 +671,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) + _keyringController.createShapeShiftTx(response.deposit, response.depositType) dispatch(actions.showQrView(response.deposit, [message].concat(marketData))) }) } diff --git a/ui/index.js b/ui/index.js index a6905b639..f07a4006c 100644 --- a/ui/index.js +++ b/ui/index.js @@ -8,7 +8,7 @@ module.exports = launchApp function launchApp (opts) { var accountManager = opts.accountManager - actions._setAccountManager(accountManager) + actions._setKeyringController(accountManager) // check if we are unlocked first accountManager.getState(function (err, metamaskState) { -- cgit From 40f175c06fbd7de6754dc7ce3597534046c9add8 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Thu, 20 Oct 2016 09:50:29 -0700 Subject: Linted --- ui/app/reducers/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui') diff --git a/ui/app/reducers/app.js b/ui/app/reducers/app.js index 2bfb2567a..5b3f44d68 100644 --- a/ui/app/reducers/app.js +++ b/ui/app/reducers/app.js @@ -123,7 +123,7 @@ function reduceApp (state, action) { return extend(appState, { currentView: { name: 'newKeychain', - context: appState.currentView.context + context: appState.currentView.context, }, transForward: true, }) -- cgit From f14fdf7a257243cb672e23a71a4fb4b109ce3d47 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Thu, 20 Oct 2016 09:58:33 -0700 Subject: Change actions reference to keyringController to background --- ui/app/actions.js | 48 ++++++++++++++++++++++++------------------------ ui/index.js | 2 +- 2 files changed, 25 insertions(+), 25 deletions(-) (limited to 'ui') diff --git a/ui/app/actions.js b/ui/app/actions.js index a6601cd0e..e33a3800a 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -95,7 +95,7 @@ var actions = { setRpcTarget: setRpcTarget, setProviderType: setProviderType, // hacky - need a way to get a reference to account manager - _setKeyringController: _setKeyringController, + _setBackgroundConnection: _setBackgroundConnection, // loading overlay SHOW_LOADING: 'SHOW_LOADING_INDICATION', HIDE_LOADING: 'HIDE_LOADING_INDICATION', @@ -140,9 +140,9 @@ var actions = { module.exports = actions -var _keyringController = null -function _setKeyringController (accountManager) { - _keyringController = accountManager +var background = null +function _setBackgroundConnection(backgroundConnection) { + background = backgroundConnection } function goHome () { @@ -157,7 +157,7 @@ function tryUnlockMetamask (password) { return (dispatch) => { dispatch(actions.showLoadingIndication()) dispatch(actions.unlockInProgress()) - _keyringController.submitPassword(password, (err, selectedAccount) => { + background.submitPassword(password, (err, selectedAccount) => { dispatch(actions.hideLoadingIndication()) if (err) { dispatch(actions.unlockFailed()) @@ -171,7 +171,7 @@ function tryUnlockMetamask (password) { function createNewVault (password, entropy) { return (dispatch) => { dispatch(actions.createNewVaultInProgress()) - _keyringController.createNewVault(password, entropy, (err, result) => { + background.createNewVault(password, entropy, (err, result) => { if (err) { return dispatch(actions.showWarning(err.message)) } @@ -189,14 +189,14 @@ function showInfoPage () { function setSelectedAddress (address) { return (dispatch) => { - _keyringController.setSelectedAddress(address) + background.setSelectedAddress(address) } } function setCurrentFiat (fiat) { return (dispatch) => { dispatch(this.showLoadingIndication()) - _keyringController.setCurrentFiat(fiat, (data, err) => { + background.setCurrentFiat(fiat, (data, err) => { dispatch(this.hideLoadingIndication()) dispatch({ type: this.SET_CURRENT_FIAT, @@ -214,7 +214,7 @@ function signMsg (msgData) { return (dispatch) => { dispatch(actions.showLoadingIndication()) - _keyringController.signMessage(msgData, (err) => { + background.signMessage(msgData, (err) => { dispatch(actions.hideLoadingIndication()) if (err) return dispatch(actions.displayWarning(err.message)) @@ -225,7 +225,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()) @@ -240,7 +240,7 @@ function signTx (txData) { function sendTx (txData) { return (dispatch) => { - _keyringController.approveTransaction(txData.id, (err) => { + background.approveTransaction(txData.id, (err) => { if (err) { alert(err.message) dispatch(actions.txError(err)) @@ -266,12 +266,12 @@ function txError (err) { } function cancelMsg (msgData) { - _keyringController.cancelMessage(msgData.id) + background.cancelMessage(msgData.id) return actions.completedTx(msgData.id) } function cancelTx (txData) { - _keyringController.cancelTransaction(txData.id) + background.cancelTransaction(txData.id) return actions.completedTx(txData.id) } @@ -300,7 +300,7 @@ function showInitializeMenu () { function agreeToDisclaimer () { return (dispatch) => { dispatch(this.showLoadingIndication()) - _keyringController.agreeToDisclaimer((err) => { + background.agreeToDisclaimer((err) => { if (err) { return dispatch(actions.showWarning(err.message)) } @@ -370,7 +370,7 @@ function updateMetamaskState (newState) { function lockMetamask () { return (dispatch) => { - _keyringController.setLocked((err) => { + background.setLocked((err) => { dispatch(actions.hideLoadingIndication()) if (err) { return dispatch(actions.showWarning(err.message)) @@ -386,7 +386,7 @@ function lockMetamask () { function showAccountDetail (address) { return (dispatch) => { dispatch(actions.showLoadingIndication()) - _keyringController.setSelectedAddress(address, (err, address) => { + background.setSelectedAddress(address, (err, address) => { dispatch(actions.hideLoadingIndication()) if (err) { return dispatch(actions.showWarning(err.message)) @@ -457,7 +457,7 @@ function goBackToInitView () { // function setRpcTarget (newRpc) { - _keyringController.setRpcTarget(newRpc) + background.setRpcTarget(newRpc) return { type: actions.SET_RPC_TARGET, value: newRpc, @@ -465,7 +465,7 @@ function setRpcTarget (newRpc) { } function setProviderType (type) { - _keyringController.setProviderType(type) + background.setProviderType(type) return { type: actions.SET_PROVIDER_TYPE, value: type, @@ -473,7 +473,7 @@ function setProviderType (type) { } function useEtherscanProvider () { - _keyringController.useEtherscanProvider() + background.useEtherscanProvider() return { type: actions.USE_ETHERSCAN_PROVIDER, } @@ -532,7 +532,7 @@ function exportAccount (address) { return function (dispatch) { dispatch(self.showLoadingIndication()) - _keyringController.exportAccount(address, function (err, result) { + background.exportAccount(address, function (err, result) { dispatch(self.hideLoadingIndication()) if (err) { @@ -555,7 +555,7 @@ function showPrivateKey (key) { function saveAccountLabel (account, label) { return (dispatch) => { dispatch(actions.showLoadingIndication()) - _keyringController.saveAccountLabel(account, label, (err) => { + background.saveAccountLabel(account, label, (err) => { dispatch(actions.hideLoadingIndication()) if (err) { return dispatch(actions.showWarning(err.message)) @@ -576,7 +576,7 @@ function showSendPage () { function agreeToEthWarning () { return (dispatch) => { - _keyringController.agreeToEthWarning((err) => { + background.agreeToEthWarning((err) => { if (err) { return dispatch(actions.showEthWarning(err.message)) } @@ -595,7 +595,7 @@ function showEthWarning () { function buyEth (address, amount) { return (dispatch) => { - _keyringController.buyEth(address, amount) + background.buyEth(address, amount) dispatch({ type: actions.BUY_ETH, }) @@ -673,7 +673,7 @@ function coinShiftRquest (data, marketData) { if (response.error) return dispatch(actions.showWarning(response.error)) var message = ` Deposit your ${response.depositType} to the address bellow:` - _keyringController.createShapeShiftTx(response.deposit, response.depositType) + background.createShapeShiftTx(response.deposit, response.depositType) dispatch(actions.showQrView(response.deposit, [message].concat(marketData))) }) } diff --git a/ui/index.js b/ui/index.js index f07a4006c..dedfd8c8c 100644 --- a/ui/index.js +++ b/ui/index.js @@ -8,7 +8,7 @@ module.exports = launchApp function launchApp (opts) { var accountManager = opts.accountManager - actions._setKeyringController(accountManager) + actions._setBackgroundConnection(accountManager) // check if we are unlocked first accountManager.getState(function (err, metamaskState) { -- cgit From f090828f9967b53bf73b21c3f59e1d15816f86a6 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Thu, 20 Oct 2016 09:58:44 -0700 Subject: Commented out useless advanced not on init screen --- ui/app/first-time/init-menu.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'ui') diff --git a/ui/app/first-time/init-menu.js b/ui/app/first-time/init-menu.js index 9b733d0e7..4fdade469 100644 --- a/ui/app/first-time/init-menu.js +++ b/ui/app/first-time/init-menu.js @@ -61,11 +61,13 @@ InitializeMenuScreen.prototype.renderMenu = function () { }, }, 'Create New Vault'), + /* h('.flex-row.flex-center.flex-grow', [ h('hr'), h('div', 'Advanced (Eventually?)'), h('hr'), ]), + */ ]) ) -- cgit From e5c95d68f80eba3e3d4645f7ac1f6606d0dddd52 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Thu, 20 Oct 2016 11:00:38 -0700 Subject: Fix state updating after vault creation and unlocking --- ui/app/actions.js | 10 ++++++++-- ui/app/app.js | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'ui') diff --git a/ui/app/actions.js b/ui/app/actions.js index e33a3800a..d5a00833b 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -157,11 +157,16 @@ function tryUnlockMetamask (password) { return (dispatch) => { dispatch(actions.showLoadingIndication()) dispatch(actions.unlockInProgress()) - background.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)) } }) @@ -171,10 +176,11 @@ function tryUnlockMetamask (password) { function createNewVault (password, entropy) { return (dispatch) => { dispatch(actions.createNewVaultInProgress()) - background.createNewVault(password, entropy, (err, result) => { + background.createNewVault(password, entropy, (err, newState) => { if (err) { return dispatch(actions.showWarning(err.message)) } + dispatch(this.updateMetamaskState(newState)) dispatch(this.showAccountsPage()) dispatch(this.hideLoadingIndication()) }) diff --git a/ui/app/app.js b/ui/app/app.js index 7392e275d..cbe02b683 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -402,6 +402,7 @@ App.prototype.renderPrimary = function () { // show initialize screen if (!props.isInitialized || props.forgottenPassword) { + // show current view switch (props.currentView.name) { -- cgit From 383f8ea7dc4a264613cfe92b257878eb78438ce7 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Thu, 20 Oct 2016 11:33:18 -0700 Subject: Linted & added salting to vault --- ui/app/actions.js | 2 +- ui/app/app.js | 2 +- ui/app/new-keychain.js | 8 ++------ 3 files changed, 4 insertions(+), 8 deletions(-) (limited to 'ui') diff --git a/ui/app/actions.js b/ui/app/actions.js index d5a00833b..b70716214 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -340,7 +340,7 @@ function backToUnlockView () { function showNewKeychain () { return { - type: actions.SHOW_NEW_KEYCHAIN + type: actions.SHOW_NEW_KEYCHAIN, } } diff --git a/ui/app/app.js b/ui/app/app.js index cbe02b683..fb9b16a3a 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -8,7 +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 NewKeychainScreen = require('./new-keychain') +const NewKeyChainScreen = require('./new-keychain') // unlock const UnlockScreen = require('./unlock') // accounts diff --git a/ui/app/new-keychain.js b/ui/app/new-keychain.js index d6fefd0c7..cc9633166 100644 --- a/ui/app/new-keychain.js +++ b/ui/app/new-keychain.js @@ -15,7 +15,7 @@ function NewKeychain () { } NewKeychain.prototype.render = function () { - const props = this.props + // const props = this.props return ( h('div', { @@ -23,11 +23,7 @@ NewKeychain.prototype.render = function () { background: 'blue', }, }, [ - h('h1',`Here's a list!!!!`), - h('button', - { - onClick: () => this.props.dispatch(actions.goHome()) - }) + h('h1', `Here's a list!!!!`), ]) ) } -- cgit From 0deed1775237bc8d48eb41e83b5a661b55e4b6be Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Thu, 20 Oct 2016 12:07:53 -0700 Subject: Fix tests --- ui/app/actions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ui') diff --git a/ui/app/actions.js b/ui/app/actions.js index b70716214..230ffee78 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 @@ -94,8 +96,6 @@ var actions = { showConfigPage: showConfigPage, setRpcTarget: setRpcTarget, setProviderType: setProviderType, - // hacky - need a way to get a reference to account manager - _setBackgroundConnection: _setBackgroundConnection, // loading overlay SHOW_LOADING: 'SHOW_LOADING_INDICATION', HIDE_LOADING: 'HIDE_LOADING_INDICATION', -- cgit From 55d56f77cf42a9c4e80768fd7e4a9bb6f0485606 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Thu, 20 Oct 2016 16:44:31 -0700 Subject: Began adding first basic keyring --- ui/app/accounts/index.js | 6 +++--- ui/app/actions.js | 16 ++++++++++++++++ ui/app/app.js | 1 - 3 files changed, 19 insertions(+), 4 deletions(-) (limited to 'ui') 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 230ffee78..e49cac4b4 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -25,6 +25,7 @@ var actions = { showInitializeMenu: showInitializeMenu, createNewVault: createNewVault, createNewVaultInProgress: createNewVaultInProgress, + addNewKeyring: addNewKeyring, showNewVaultSeed: showNewVaultSeed, showInfoPage: showInfoPage, // unlock screen @@ -136,6 +137,7 @@ var actions = { SHOW_NEW_KEYCHAIN: 'SHOW_NEW_KEYCHAIN', showNewKeychain: showNewKeychain, + } module.exports = actions @@ -187,6 +189,20 @@ function createNewVault (password, entropy) { } } +function addNewKeyring (type, opts) { + return (dispatch) => { + dispatch(actions.showLoadingIndication()) + background.addNewKeyring(type, opts, (err, newState) => { + dispatch(this.hideLoadingIndication()) + if (err) { + return dispatch(actions.showWarning(err.message)) + } + dispatch(this.updateMetamaskState(newState)) + dispatch(this.showAccountsPage()) + }) + } +} + function showInfoPage () { return { type: actions.SHOW_INFO_PAGE, diff --git a/ui/app/app.js b/ui/app/app.js index fb9b16a3a..3ceae0027 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -405,7 +405,6 @@ App.prototype.renderPrimary = function () { // show current view switch (props.currentView.name) { - case 'createVault': return h(CreateVaultScreen, {key: 'createVault'}) -- cgit From 957b7a72b55be864320a346108673d02448caefd Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Thu, 20 Oct 2016 17:24:03 -0700 Subject: Improved simple account generation --- ui/app/actions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui') diff --git a/ui/app/actions.js b/ui/app/actions.js index e49cac4b4..525ceca54 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -195,7 +195,7 @@ function addNewKeyring (type, opts) { background.addNewKeyring(type, opts, (err, newState) => { dispatch(this.hideLoadingIndication()) if (err) { - return dispatch(actions.showWarning(err.message)) + return dispatch(actions.showWarning(err)) } dispatch(this.updateMetamaskState(newState)) dispatch(this.showAccountsPage()) -- cgit From a462fc82e00c98f4e8c018fbd5dac36d74b88efc Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Fri, 21 Oct 2016 15:19:16 -0700 Subject: Fix duplicate provider menu item bug --- ui/app/app.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'ui') diff --git a/ui/app/app.js b/ui/app/app.js index 3ceae0027..a1004b74b 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -501,12 +501,7 @@ App.prototype.renderCustomOption = function (rpcTarget) { return null 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, { -- cgit From 678301a20e6112d79a052c13f921bb75c451c613 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Tue, 25 Oct 2016 13:24:03 -0700 Subject: Phase out extra warning screen. --- ui/app/account-detail.js | 1 - ui/app/actions.js | 23 ------------ ui/app/app.js | 5 --- ui/app/eth-store-warning.js | 89 --------------------------------------------- ui/app/reducers/app.js | 5 +-- ui/app/reducers/metamask.js | 6 --- 6 files changed, 1 insertion(+), 128 deletions(-) delete mode 100644 ui/app/eth-store-warning.js (limited to 'ui') 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/actions.js b/ui/app/actions.js index 525ceca54..1f8ba7f04 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -61,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', @@ -596,25 +592,6 @@ function showSendPage () { } } -function agreeToEthWarning () { - return (dispatch) => { - background.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) => { background.buyEth(address, amount) diff --git a/ui/app/app.js b/ui/app/app.js index a1004b74b..061545d59 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -25,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) @@ -38,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, @@ -421,9 +419,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'}) 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/reducers/app.js b/ui/app/reducers/app.js index 5b3f44d68..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', }, 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, -- cgit From 28eec68f85a423c0baec26b70de0098df8ac2a63 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Thu, 27 Oct 2016 16:02:34 -0700 Subject: Update first screen to match design. --- ui/app/first-time/init-menu.js | 106 ++++++++++++++++++++++++++++++++++++++--- ui/app/unlock.js | 3 -- 2 files changed, 99 insertions(+), 10 deletions(-) (limited to 'ui') diff --git a/ui/app/first-time/init-menu.js b/ui/app/first-time/init-menu.js index 4fdade469..9788db382 100644 --- a/ui/app/first-time/init-menu.js +++ b/ui/app/first-time/init-menu.js @@ -5,6 +5,8 @@ const connect = require('react-redux').connect const h = require('react-hyperscript') const Mascot = require('../components/mascot') const actions = require('../actions') +const Tooltip = require('../components/tooltip') +const getCaretCoordinates = require('textarea-caret') module.exports = connect(mapStateToProps)(InitializeMenuScreen) @@ -54,18 +56,73 @@ InitializeMenuScreen.prototype.renderMenu = function () { }, }, 'MetaMask'), + + h('div', [ + h('h3', { + style: { + fontSize: '0.8em', + color: '#7F8082', + display: 'inline', + }, + }, 'Encrypt your new DEN'), + + h(Tooltip, { + title: 'Your DEN is your password-encrypted storage within MetaMask.', + }, [ + h('i.fa.fa-question-circle.pointer', { + style: { + fontSize: '18px', + position: 'relative', + color: 'rgb(247, 134, 28)', + top: '2px', + marginLeft: '4px', + }, + }), + ]), + ]), + + // password + h('input.large-input.letter-spacey', { + type: 'password', + id: 'password-box', + placeholder: 'New Password (min 8 chars)', + onInput: this.inputChanged.bind(this), + style: { + width: 260, + marginTop: 12, + }, + }), + + // confirm password + h('input.large-input.letter-spacey', { + type: 'password', + id: 'password-box-confirm', + placeholder: 'Confirm Password', + onKeyPress: this.createVaultOnEnter.bind(this), + onInput: this.inputChanged.bind(this), + style: { + width: 260, + marginTop: 16, + }, + }), + + h('button.primary', { - onClick: this.showCreateVault.bind(this), + onClick: this.createNewVault.bind(this), style: { margin: 12, }, - }, 'Create New Vault'), + }, 'Create'), /* h('.flex-row.flex-center.flex-grow', [ - h('hr'), - h('div', 'Advanced (Eventually?)'), - h('hr'), + h('p.pointer', { + style: { + fontSize: '0.8em', + color: 'rgb(247, 134, 28)', + textDecoration: 'underline', + }, + }, 'I already have a DEN that I would like to import'), ]), */ @@ -73,7 +130,42 @@ InitializeMenuScreen.prototype.renderMenu = function () { ) } -InitializeMenuScreen.prototype.showCreateVault = function () { - this.props.dispatch(actions.showCreateVault()) +InitializeMenuScreen.prototype.createVaultOnEnter = function (event) { + if (event.key === 'Enter') { + event.preventDefault() + this.createNewVault() + } +} + +InitializeMenuScreen.prototype.createNewVault = function () { + var passwordBox = document.getElementById('password-box') + var password = passwordBox.value + var passwordConfirmBox = document.getElementById('password-box-confirm') + var passwordConfirm = passwordConfirmBox.value + // var entropy = document.getElementById('entropy-text-entry').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 + } + + this.props.dispatch(actions.createNewVault(password, ''/* entropy*/)) +} + +InitializeMenuScreen.prototype.inputChanged = function (event) { + // tell mascot to look at page action + var element = event.target + var boundingRect = element.getBoundingClientRect() + var coordinates = getCaretCoordinates(element, element.selectionEnd) + this.animationEventEmitter.emit('point', { + x: boundingRect.left + coordinates.left - element.scrollLeft, + y: boundingRect.top + coordinates.top - element.scrollTop, + }) } diff --git a/ui/app/unlock.js b/ui/app/unlock.js index b82e46d02..ca74c94c3 100644 --- a/ui/app/unlock.js +++ b/ui/app/unlock.js @@ -104,6 +104,3 @@ UnlockScreen.prototype.inputChanged = function (event) { }) } -UnlockScreen.prototype.emitAnim = function (name, a, b, c) { - this.animationEventEmitter.emit(name, a, b, c) -} -- cgit From ed3814bff8cf42218fe5a9f068b0474cac73807d Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Thu, 27 Oct 2016 16:16:28 -0700 Subject: Fix identicon rendering --- ui/app/components/identicon.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'ui') diff --git a/ui/app/components/identicon.js b/ui/app/components/identicon.js index 4b2bf899e..30ef6fbd3 100644 --- a/ui/app/components/identicon.js +++ b/ui/app/components/identicon.js @@ -16,8 +16,8 @@ function IdenticonComponent () { } IdenticonComponent.prototype.render = function () { - var state = this.props - var diameter = state.diameter || this.defaultDiameter + var props = this.props + var diameter = props.diameter || this.defaultDiameter return ( h('div', { key: 'identicon-' + this.props.address, @@ -33,15 +33,14 @@ IdenticonComponent.prototype.render = function () { } IdenticonComponent.prototype.componentDidMount = function () { - var state = this.props - var address = state.address + var props = this.props + var address = props.address if (!address) return var container = findDOMNode(this) - var diameter = state.diameter || this.defaultDiameter - var imageify = state.imageify === undefined ? true : state.imageify - var img = iconFactory.iconForAddress(address, diameter, imageify) + var diameter = props.diameter || this.defaultDiameter + var img = iconFactory.iconForAddress(address, diameter, false) container.appendChild(img) } -- cgit From 6ec471c6dcc52a9d2b599b849fa5017f3056fd43 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Fri, 28 Oct 2016 12:10:35 -0700 Subject: Configure BIP44 Keychain as default one --- ui/app/accounts/index.js | 6 +++--- ui/app/actions.js | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 4 deletions(-) (limited to 'ui') diff --git a/ui/app/accounts/index.js b/ui/app/accounts/index.js index 92054f24d..c742d9fac 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.addNewKeyring() + this.addNewAccount() }, style: { display: 'flex', @@ -146,8 +146,8 @@ AccountsScreen.prototype.onShowDetail = function (address, event) { this.props.dispatch(actions.showAccountDetail(address)) } -AccountsScreen.prototype.addNewKeyring = function () { - this.props.dispatch(actions.addNewKeyring('Simple Key Pair')) +AccountsScreen.prototype.addNewAccount = function () { + this.props.dispatch(actions.addNewAccount(0)) } AccountsScreen.prototype.goHome = function () { diff --git a/ui/app/actions.js b/ui/app/actions.js index 1f8ba7f04..3ae3a623d 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -25,7 +25,8 @@ var actions = { showInitializeMenu: showInitializeMenu, createNewVault: createNewVault, createNewVaultInProgress: createNewVaultInProgress, - addNewKeyring: addNewKeyring, + addNewKeyring, + addNewAccount, showNewVaultSeed: showNewVaultSeed, showInfoPage: showInfoPage, // unlock screen @@ -178,6 +179,7 @@ function createNewVault (password, entropy) { if (err) { return dispatch(actions.showWarning(err.message)) } + dispatch(this.updateMetamaskState(newState)) dispatch(this.showAccountsPage()) dispatch(this.hideLoadingIndication()) @@ -199,6 +201,19 @@ function addNewKeyring (type, opts) { } } +function addNewAccount (ringNumber = 0) { + return (dispatch) => { + dispatch(actions.showLoadingIndication()) + background.addNewAccount(ringNumber, (err, newState) => { + dispatch(this.hideLoadingIndication()) + if (err) { + return dispatch(actions.showWarning(err)) + } + dispatch(this.updateMetamaskState(newState)) + }) + } +} + function showInfoPage () { return { type: actions.SHOW_INFO_PAGE, -- cgit From 24181970416929e51562856d475d16afc1fa2441 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Sun, 30 Oct 2016 13:38:37 -0700 Subject: Modify first-screen design to match docs. --- ui/app/first-time/init-menu.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'ui') diff --git a/ui/app/first-time/init-menu.js b/ui/app/first-time/init-menu.js index 9788db382..21ddc2800 100644 --- a/ui/app/first-time/init-menu.js +++ b/ui/app/first-time/init-menu.js @@ -49,7 +49,7 @@ InitializeMenuScreen.prototype.renderMenu = function () { h('h1', { style: { - fontSize: '1.4em', + fontSize: '1.7em', textTransform: 'uppercase', color: '#7F8082', marginBottom: 20, @@ -90,6 +90,7 @@ InitializeMenuScreen.prototype.renderMenu = function () { style: { width: 260, marginTop: 12, + textAlign: 'center', }, }), @@ -103,6 +104,7 @@ InitializeMenuScreen.prototype.renderMenu = function () { style: { width: 260, marginTop: 16, + textAlign: 'center', }, }), @@ -168,4 +170,3 @@ InitializeMenuScreen.prototype.inputChanged = function (event) { y: boundingRect.top + coordinates.top - element.scrollTop, }) } - -- cgit From 02b0cf2e6d038ead318e9a8b63d493ba710a5187 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Sun, 30 Oct 2016 13:57:23 -0700 Subject: Add password warning div. --- ui/app/first-time/init-menu.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'ui') diff --git a/ui/app/first-time/init-menu.js b/ui/app/first-time/init-menu.js index 21ddc2800..bd6541dd4 100644 --- a/ui/app/first-time/init-menu.js +++ b/ui/app/first-time/init-menu.js @@ -20,6 +20,7 @@ function mapStateToProps (state) { return { // state from plugin currentView: state.appState.currentView, + warning: state.appState.warning, } } @@ -29,7 +30,7 @@ InitializeMenuScreen.prototype.render = function () { switch (state.currentView.name) { default: - return this.renderMenu() + return this.renderMenu(state) } } @@ -38,7 +39,7 @@ InitializeMenuScreen.prototype.render = function () { // document.getElementById('password-box').focus() // } -InitializeMenuScreen.prototype.renderMenu = function () { +InitializeMenuScreen.prototype.renderMenu = function (state) { return ( h('.initialize-screen.flex-column.flex-center.flex-grow', [ @@ -116,6 +117,10 @@ InitializeMenuScreen.prototype.renderMenu = function () { }, }, 'Create'), + (!state.inProgress && state.warning) && ( + h('span.in-progress-notification', state.warning) + ), + /* h('.flex-row.flex-center.flex-grow', [ h('p.pointer', { -- cgit From 625c54b7eca1c12f5d95b3ae9d2374315abc0c2b Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Sun, 30 Oct 2016 14:08:14 -0700 Subject: Add focus to password field. --- ui/app/first-time/init-menu.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'ui') diff --git a/ui/app/first-time/init-menu.js b/ui/app/first-time/init-menu.js index bd6541dd4..b1155e2f6 100644 --- a/ui/app/first-time/init-menu.js +++ b/ui/app/first-time/init-menu.js @@ -144,6 +144,10 @@ InitializeMenuScreen.prototype.createVaultOnEnter = function (event) { } } +InitializeMenuScreen.prototype.componentDidMount = function () { + document.getElementById('password-box').focus() +} + InitializeMenuScreen.prototype.createNewVault = function () { var passwordBox = document.getElementById('password-box') var password = passwordBox.value -- cgit From 25c46a16364612cd4bcebe375af910c08862b17a Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Sun, 30 Oct 2016 15:59:55 -0700 Subject: Make case condition more consistent. Remove extra action. Fix incorrect display of network. --- ui/app/actions.js | 2 +- ui/app/components/network.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'ui') diff --git a/ui/app/actions.js b/ui/app/actions.js index 3ae3a623d..a2f59cb3c 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -174,7 +174,7 @@ function tryUnlockMetamask (password) { function createNewVault (password, entropy) { return (dispatch) => { - dispatch(actions.createNewVaultInProgress()) + // dispatch(actions.createNewVaultInProgress()) background.createNewVault(password, entropy, (err, newState) => { if (err) { return dispatch(actions.showWarning(err.message)) diff --git a/ui/app/components/network.js b/ui/app/components/network.js index 845861396..ff5aefd41 100644 --- a/ui/app/components/network.js +++ b/ui/app/components/network.js @@ -36,13 +36,14 @@ Network.prototype.render = function () { } else if (providerName === 'mainnet') { hoverText = 'Main Ethereum Network' iconName = 'ethereum-network' - } else if (parseInt(networkNumber) === 2) { + } else if (providerName === 'testnet') { hoverText = 'Morden Test Network' iconName = 'morden-test-network' } else { hoverText = 'Unknown Private Network' iconName = 'unknown-private-network' } + return ( h('#network_component.flex-center.pointer', { style: { -- cgit From 96643c222a74552d98218fe1f9fc81e493a1960f Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Mon, 31 Oct 2016 11:35:09 -0700 Subject: Implement seed word confirmation page. Remove logs. Move HD render files to ui/app. --- ui/app/actions.js | 16 +++ ui/app/app.js | 7 ++ ui/app/keychains/hd/create-vault-complete.js | 73 +++++++++++ ui/app/keychains/hd/recover-seed/confirmation.js | 148 +++++++++++++++++++++++ ui/app/keychains/hd/restore-vault.js | 148 +++++++++++++++++++++++ 5 files changed, 392 insertions(+) create mode 100644 ui/app/keychains/hd/create-vault-complete.js create mode 100644 ui/app/keychains/hd/recover-seed/confirmation.js create mode 100644 ui/app/keychains/hd/restore-vault.js (limited to 'ui') diff --git a/ui/app/actions.js b/ui/app/actions.js index a2f59cb3c..5068d1848 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -80,6 +80,7 @@ var actions = { viewPendingTx: viewPendingTx, VIEW_PENDING_TX: 'VIEW_PENDING_TX', // app messages + confirmSeedWords: confirmSeedWords, showAccountDetail: showAccountDetail, BACK_TO_ACCOUNT_DETAIL: 'BACK_TO_ACCOUNT_DETAIL', backToAccountDetail: backToAccountDetail, @@ -172,6 +173,21 @@ function tryUnlockMetamask (password) { } } +function confirmSeedWords () { + return (dispatch) => { + dispatch(actions.showLoadingIndication()) + background.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 createNewVault (password, entropy) { return (dispatch) => { // dispatch(actions.createNewVaultInProgress()) diff --git a/ui/app/app.js b/ui/app/app.js index 588aa9896..f3ad8efc3 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -27,6 +27,8 @@ const NetworkIndicator = require('./components/network') const Tooltip = require('./components/tooltip') const BuyView = require('./components/buy-button-subview') const QrView = require('./components/qr-code') +const HDCreateVaultComplete = require('./keychains/hd/create-vault-complete') + module.exports = connect(mapStateToProps)(App) inherits(App, Component) @@ -35,6 +37,7 @@ function App () { Component.call(this) } function mapStateToProps (state) { return { // state from plugin + seedWords: state.metamask.seedWords, isLoading: state.appState.isLoading, isConfirmed: state.metamask.isConfirmed, isInitialized: state.metamask.isInitialized, @@ -392,6 +395,10 @@ App.prototype.renderPrimary = function () { return h(DisclaimerScreen, {key: 'disclaimerScreen'}) } + if (props.seedWords) { + return h(HDCreateVaultComplete, {key: 'HDCreateVaultComplete'}) + } + // show initialize screen if (!props.isInitialized || props.forgottenPassword) { diff --git a/ui/app/keychains/hd/create-vault-complete.js b/ui/app/keychains/hd/create-vault-complete.js new file mode 100644 index 000000000..7272ebdbd --- /dev/null +++ b/ui/app/keychains/hd/create-vault-complete.js @@ -0,0 +1,73 @@ +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/keychains/hd/recover-seed/confirmation.js b/ui/app/keychains/hd/recover-seed/confirmation.js new file mode 100644 index 000000000..55b18025f --- /dev/null +++ b/ui/app/keychains/hd/recover-seed/confirmation.js @@ -0,0 +1,148 @@ +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/keychains/hd/restore-vault.js b/ui/app/keychains/hd/restore-vault.js new file mode 100644 index 000000000..4c1f21008 --- /dev/null +++ b/ui/app/keychains/hd/restore-vault.js @@ -0,0 +1,148 @@ +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)) +} -- cgit From 0643c35936b66f3f3d6b59423aae615cc90a0fbf Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Mon, 31 Oct 2016 11:38:48 -0700 Subject: Linted --- ui/app/app.js | 1 - 1 file changed, 1 deletion(-) (limited to 'ui') diff --git a/ui/app/app.js b/ui/app/app.js index f3ad8efc3..a593af0a2 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -37,7 +37,6 @@ function App () { Component.call(this) } function mapStateToProps (state) { return { // state from plugin - seedWords: state.metamask.seedWords, isLoading: state.appState.isLoading, isConfirmed: state.metamask.isConfirmed, isInitialized: state.metamask.isInitialized, -- cgit From db356a181a3fde4ad528c699f6da517053171866 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Tue, 1 Nov 2016 11:25:38 -0700 Subject: Made progress on parity for MultiVault - Deleted some unused items - Renamed files and paths to match with new locations. - Modified keyring controller logic to separate concerns. - Fix account naming issues. - Enable creation of new vault with default HD keyring. - Formatting issues. --- ui/app/actions.js | 23 ++-- ui/app/app.js | 20 +--- ui/app/first-time/create-vault.js | 129 ----------------------- ui/app/first-time/init-menu.js | 28 ++--- ui/app/keychains/hd/recover-seed/confirmation.js | 4 +- ui/app/keychains/hd/restore-vault.js | 10 +- 6 files changed, 43 insertions(+), 171 deletions(-) delete mode 100644 ui/app/first-time/create-vault.js (limited to 'ui') diff --git a/ui/app/actions.js b/ui/app/actions.js index 5068d1848..458145380 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -23,7 +23,8 @@ var actions = { showCreateVault: showCreateVault, showRestoreVault: showRestoreVault, showInitializeMenu: showInitializeMenu, - createNewVault: createNewVault, + createNewVaultAndKeychain: createNewVaultAndKeychain, + createNewVaultAndRestore: createNewVaultAndRestore, createNewVaultInProgress: createNewVaultInProgress, addNewKeyring, addNewAccount, @@ -188,17 +189,27 @@ function confirmSeedWords () { } } -function createNewVault (password, entropy) { +function createNewVaultAndRestore (password, seed) { return (dispatch) => { - // dispatch(actions.createNewVaultInProgress()) - background.createNewVault(password, entropy, (err, newState) => { + dispatch(actions.showLoadingIndication()) + background.createNewVaultAndRestore(password, seed, (err, newState) => { + dispatch(actions.hideLoadingIndication()) + if (err) return dispatch(actions.displayWarning(err.message)) + + dispatch(this.updateMetamaskState(newState)) + }) + } +} + +function createNewVaultAndKeychain (password, entropy) { + return (dispatch) => { + background.createNewVaultAndKeychain(password, entropy, (err, newState) => { if (err) { return dispatch(actions.showWarning(err.message)) } dispatch(this.updateMetamaskState(newState)) - dispatch(this.showAccountsPage()) - dispatch(this.hideLoadingIndication()) + dispatch(this.showNewVaultSeed()) }) } } diff --git a/ui/app/app.js b/ui/app/app.js index a593af0a2..b40219763 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -7,7 +7,6 @@ const ReactCSSTransitionGroup = require('react-addons-css-transition-group') // init const DisclaimerScreen = require('./first-time/disclaimer') const InitializeMenuScreen = require('./first-time/init-menu') -const CreateVaultScreen = require('./first-time/create-vault') const NewKeyChainScreen = require('./new-keychain') // unlock const UnlockScreen = require('./unlock') @@ -28,6 +27,7 @@ const Tooltip = require('./components/tooltip') const BuyView = require('./components/buy-button-subview') const QrView = require('./components/qr-code') const HDCreateVaultComplete = require('./keychains/hd/create-vault-complete') +const HDRestoreVaultScreen = require('./keychains/hd/restore-vault') module.exports = connect(mapStateToProps)(App) @@ -349,16 +349,6 @@ App.prototype.renderBackToInitButton = function () { } else if (props.isInitialized) { var style switch (props.currentView.name) { - case 'createVault': - style = { - position: 'absolute', - top: '41px', - left: '80px', - fontSize: '21px', - fontFamily: 'Montserrat Bold', - color: 'rgb(174, 174, 174)', - } - return this.renderBackButton(style, true) case 'restoreVault': style = { position: 'absolute', @@ -403,8 +393,9 @@ App.prototype.renderPrimary = function () { // show current view switch (props.currentView.name) { - case 'createVault': - return h(CreateVaultScreen, {key: 'createVault'}) + + case 'restoreVault': + return h(HDRestoreVaultScreen, {key: 'HDRestoreVaultScreen'}) default: return h(InitializeMenuScreen, {key: 'menuScreenInit'}) @@ -440,9 +431,6 @@ App.prototype.renderPrimary = function () { case 'info': return h(InfoScreen, {key: 'info'}) - case 'createVault': - return h(CreateVaultScreen, {key: 'createVault'}) - case 'buyEth': return h(BuyView, {key: 'buyEthView'}) diff --git a/ui/app/first-time/create-vault.js b/ui/app/first-time/create-vault.js deleted file mode 100644 index 33ae62179..000000000 --- a/ui/app/first-time/create-vault.js +++ /dev/null @@ -1,129 +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)(CreateVaultScreen) - -inherits(CreateVaultScreen, Component) -function CreateVaultScreen () { - Component.call(this) -} - -function mapStateToProps (state) { - return { - warning: state.appState.warning, - } -} - -CreateVaultScreen.prototype.render = function () { - var state = this.props - 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, - }, - }, [ - 'Create Vault', - ]), - - // password - h('input.large-input.letter-spacey', { - type: 'password', - id: 'password-box', - placeholder: 'New Password (min 8 chars)', - style: { - width: 260, - marginTop: 12, - }, - }), - - // confirm password - h('input.large-input.letter-spacey', { - type: 'password', - id: 'password-box-confirm', - placeholder: 'Confirm Password', - onKeyPress: this.createVaultOnEnter.bind(this), - style: { - width: 260, - marginTop: 16, - }, - }), - - 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.createNewVault.bind(this), - }, 'OK'), - - ]), - - (!state.inProgress && state.warning) && ( - h('span.in-progress-notification', state.warning) - ), - - state.inProgress && ( - h('span.in-progress-notification', 'Generating Seed...') - ), - ]) - ) -} - -CreateVaultScreen.prototype.componentDidMount = function () { - document.getElementById('password-box').focus() -} - -CreateVaultScreen.prototype.showInitializeMenu = function () { - this.props.dispatch(actions.showInitializeMenu()) -} - -// create vault - -CreateVaultScreen.prototype.createVaultOnEnter = function (event) { - if (event.key === 'Enter') { - event.preventDefault() - this.createNewVault() - } -} - -CreateVaultScreen.prototype.createNewVault = function () { - var passwordBox = document.getElementById('password-box') - var password = passwordBox.value - var passwordConfirmBox = document.getElementById('password-box-confirm') - var passwordConfirm = passwordConfirmBox.value - // var entropy = document.getElementById('entropy-text-entry').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 - } - - this.props.dispatch(actions.createNewVault(password, ''/* entropy*/)) -} diff --git a/ui/app/first-time/init-menu.js b/ui/app/first-time/init-menu.js index b1155e2f6..897051818 100644 --- a/ui/app/first-time/init-menu.js +++ b/ui/app/first-time/init-menu.js @@ -50,10 +50,10 @@ InitializeMenuScreen.prototype.renderMenu = function (state) { h('h1', { style: { - fontSize: '1.7em', + fontSize: '1.3em', textTransform: 'uppercase', color: '#7F8082', - marginBottom: 20, + marginBottom: 10, }, }, 'MetaMask'), @@ -82,6 +82,8 @@ InitializeMenuScreen.prototype.renderMenu = function (state) { ]), ]), + h('span.in-progress-notification', state.warning), + // password h('input.large-input.letter-spacey', { type: 'password', @@ -91,7 +93,6 @@ InitializeMenuScreen.prototype.renderMenu = function (state) { style: { width: 260, marginTop: 12, - textAlign: 'center', }, }), @@ -105,25 +106,22 @@ InitializeMenuScreen.prototype.renderMenu = function (state) { style: { width: 260, marginTop: 16, - textAlign: 'center', }, }), h('button.primary', { - onClick: this.createNewVault.bind(this), + onClick: this.createNewVaultAndKeychain.bind(this), style: { margin: 12, }, }, 'Create'), - (!state.inProgress && state.warning) && ( - h('span.in-progress-notification', state.warning) - ), - /* + h('.flex-row.flex-center.flex-grow', [ h('p.pointer', { + onClick: this.showRestoreVault.bind(this), style: { fontSize: '0.8em', color: 'rgb(247, 134, 28)', @@ -131,7 +129,7 @@ InitializeMenuScreen.prototype.renderMenu = function (state) { }, }, 'I already have a DEN that I would like to import'), ]), - */ + ]) ) @@ -140,7 +138,7 @@ InitializeMenuScreen.prototype.renderMenu = function (state) { InitializeMenuScreen.prototype.createVaultOnEnter = function (event) { if (event.key === 'Enter') { event.preventDefault() - this.createNewVault() + this.createNewVaultAndKeychain() } } @@ -148,7 +146,11 @@ InitializeMenuScreen.prototype.componentDidMount = function () { document.getElementById('password-box').focus() } -InitializeMenuScreen.prototype.createNewVault = function () { +InitializeMenuScreen.prototype.showRestoreVault = function () { + this.props.dispatch(actions.showRestoreVault()) +} + +InitializeMenuScreen.prototype.createNewVaultAndKeychain = function () { var passwordBox = document.getElementById('password-box') var password = passwordBox.value var passwordConfirmBox = document.getElementById('password-box-confirm') @@ -166,7 +168,7 @@ InitializeMenuScreen.prototype.createNewVault = function () { return } - this.props.dispatch(actions.createNewVault(password, ''/* entropy*/)) + this.props.dispatch(actions.createNewVaultAndKeychain(password, ''/* entropy*/)) } InitializeMenuScreen.prototype.inputChanged = function (event) { diff --git a/ui/app/keychains/hd/recover-seed/confirmation.js b/ui/app/keychains/hd/recover-seed/confirmation.js index 55b18025f..83dbc270f 100644 --- a/ui/app/keychains/hd/recover-seed/confirmation.js +++ b/ui/app/keychains/hd/recover-seed/confirmation.js @@ -3,7 +3,7 @@ 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') +const actions = require('../../../actions') module.exports = connect(mapStateToProps)(RevealSeedConfirmatoin) @@ -68,7 +68,7 @@ RevealSeedConfirmatoin.prototype.render = function () { style: { marginTop: '12px', }, - }, 'Enter the phrase "I understand" to proceed.'), + }, `Enter the phrase "${this.confirmationPhrase}" to proceed.`), // confirm confirmation h('input.large-input.letter-spacey', { diff --git a/ui/app/keychains/hd/restore-vault.js b/ui/app/keychains/hd/restore-vault.js index 4c1f21008..15690a159 100644 --- a/ui/app/keychains/hd/restore-vault.js +++ b/ui/app/keychains/hd/restore-vault.js @@ -1,8 +1,8 @@ const inherits = require('util').inherits -const PersistentForm = require('../../lib/persistent-form') +const PersistentForm = require('../../../lib/persistent-form') const connect = require('react-redux').connect const h = require('react-hyperscript') -const actions = require('../actions') +const actions = require('../../actions') module.exports = connect(mapStateToProps)(RestoreVaultScreen) @@ -96,7 +96,7 @@ RestoreVaultScreen.prototype.render = function () { // submit h('button.primary', { - onClick: this.restoreVault.bind(this), + onClick: this.createNewVaultAndRestore.bind(this), }, 'OK'), ]), @@ -116,7 +116,7 @@ RestoreVaultScreen.prototype.onMaybeCreate = function (event) { } } -RestoreVaultScreen.prototype.restoreVault = function () { +RestoreVaultScreen.prototype.createNewVaultAndRestore = function () { // check password var passwordBox = document.getElementById('password-box') var password = passwordBox.value @@ -144,5 +144,5 @@ RestoreVaultScreen.prototype.restoreVault = function () { // submit this.warning = null this.props.dispatch(actions.displayWarning(this.warning)) - this.props.dispatch(actions.recoverFromSeed(password, seed)) + this.props.dispatch(actions.createNewVaultAndRestore(password, seed)) } -- cgit From 498b30bddcfa16f587a9f62b74a5d9fceb04cb07 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Tue, 1 Nov 2016 11:51:51 -0700 Subject: Fix seed phrase restore --- ui/app/actions.js | 1 - ui/app/keychains/hd/restore-vault.js | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'ui') diff --git a/ui/app/actions.js b/ui/app/actions.js index 458145380..0586e07a3 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -195,7 +195,6 @@ function createNewVaultAndRestore (password, seed) { background.createNewVaultAndRestore(password, seed, (err, newState) => { dispatch(actions.hideLoadingIndication()) if (err) return dispatch(actions.displayWarning(err.message)) - dispatch(this.updateMetamaskState(newState)) }) } diff --git a/ui/app/keychains/hd/restore-vault.js b/ui/app/keychains/hd/restore-vault.js index 15690a159..3fa25a2eb 100644 --- a/ui/app/keychains/hd/restore-vault.js +++ b/ui/app/keychains/hd/restore-vault.js @@ -66,7 +66,7 @@ RestoreVaultScreen.prototype.render = function () { type: 'password', id: 'password-box-confirm', placeholder: 'Confirm Password', - onKeyPress: this.onMaybeCreate.bind(this), + onKeyPress: this.createOnEnter.bind(this), dataset: { persistentFormId: 'password-confirmation', }, @@ -110,9 +110,9 @@ RestoreVaultScreen.prototype.showInitializeMenu = function () { this.props.dispatch(actions.showInitializeMenu()) } -RestoreVaultScreen.prototype.onMaybeCreate = function (event) { +RestoreVaultScreen.prototype.createOnEnter = function (event) { if (event.key === 'Enter') { - this.restoreVault() + this.createNewVaultAndRestore() } } -- cgit From 72729060dc8366dbe965bd66c3b98b88bdb21830 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Tue, 1 Nov 2016 15:00:28 -0700 Subject: Make forgot password button. --- ui/app/app.js | 41 ++++++++++++----------------------------- ui/app/first-time/init-menu.js | 3 --- ui/app/unlock.js | 11 +++++++++++ 3 files changed, 23 insertions(+), 32 deletions(-) (limited to 'ui') diff --git a/ui/app/app.js b/ui/app/app.js index b40219763..4b1818b93 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -300,6 +300,7 @@ App.prototype.renderDropdown = function () { }), ]) } + App.prototype.renderBackButton = function (style, justArrow = false) { var props = this.props return ( @@ -317,12 +318,13 @@ App.prototype.renderBackButton = function (style, justArrow = false) { }, 'BACK'), ]) ) - } + App.prototype.renderBackToInitButton = function () { var props = this.props var button = null if (!props.isConfirmed) return button + if (!props.isUnlocked) { if (props.currentView.name === 'InitMenu') { button = props.forgottenPassword ? h('.flex-row', { @@ -346,32 +348,6 @@ App.prototype.renderBackToInitButton = function () { }, 'LOGIN'), h('i.fa.fa-arrow-right.cursor-pointer'), ]) : null - } else if (props.isInitialized) { - var style - switch (props.currentView.name) { - case 'restoreVault': - style = { - position: 'absolute', - top: '41px', - left: '70px', - fontSize: '21px', - fontFamily: 'Montserrat Bold', - color: 'rgb(174, 174, 174)', - } - return this.renderBackButton(style, true) - default: - style = { - position: 'absolute', - bottom: '10px', - left: '15px', - fontSize: '21px', - fontFamily: 'Montserrat Light', - color: '#7F8082', - width: '71.969px', - alignItems: 'flex-end', - } - return this.renderBackButton(style) - } } } return button @@ -399,17 +375,24 @@ App.prototype.renderPrimary = function () { default: return h(InitializeMenuScreen, {key: 'menuScreenInit'}) - } } // show unlock screen if (!props.isUnlocked) { - return h(UnlockScreen, {key: 'locked'}) + switch (props.currentView.name) { + + case 'restoreVault': + return h(HDRestoreVaultScreen, {key: 'HDRestoreVaultScreen'}) + + default: + return h(UnlockScreen, {key: 'locked'}) + } } // show current view switch (props.currentView.name) { + case 'accounts': return h(AccountsScreen, {key: 'accounts'}) diff --git a/ui/app/first-time/init-menu.js b/ui/app/first-time/init-menu.js index 897051818..14a89b988 100644 --- a/ui/app/first-time/init-menu.js +++ b/ui/app/first-time/init-menu.js @@ -117,8 +117,6 @@ InitializeMenuScreen.prototype.renderMenu = function (state) { }, }, 'Create'), - - h('.flex-row.flex-center.flex-grow', [ h('p.pointer', { onClick: this.showRestoreVault.bind(this), @@ -130,7 +128,6 @@ InitializeMenuScreen.prototype.renderMenu = function (state) { }, 'I already have a DEN that I would like to import'), ]), - ]) ) } diff --git a/ui/app/unlock.js b/ui/app/unlock.js index ca74c94c3..5c9a94f39 100644 --- a/ui/app/unlock.js +++ b/ui/app/unlock.js @@ -65,6 +65,17 @@ UnlockScreen.prototype.render = function () { }, }, 'Unlock'), ]), + + h('.flex-row.flex-center.flex-grow', [ + h('p.pointer', { + onClick: () => this.props.dispatch(actions.showRestoreVault()), + style: { + fontSize: '0.8em', + color: 'rgb(247, 134, 28)', + textDecoration: 'underline', + }, + }, 'I forgot my password.'), + ]), ]) ) } -- cgit From b5f6ef8c013f2f742546a04e148bac99fbc4691c Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Tue, 1 Nov 2016 17:00:17 -0700 Subject: Fixed bugs related to clearing caches when restoring to a new vault --- ui/app/actions.js | 5 +++-- ui/app/reducers/app.js | 2 +- ui/app/unlock.js | 2 ++ 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'ui') diff --git a/ui/app/actions.js b/ui/app/actions.js index 0586e07a3..8218e05ef 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -161,7 +161,7 @@ function tryUnlockMetamask (password) { background.submitPassword(password, (err, newState) => { dispatch(actions.hideLoadingIndication()) if (err) { - dispatch(actions.unlockFailed()) + dispatch(actions.unlockFailed(err.message)) } else { dispatch(this.updateMetamaskState(newState)) let selectedAccount @@ -407,9 +407,10 @@ function unlockInProgress () { } } -function unlockFailed () { +function unlockFailed (message) { return { type: actions.UNLOCK_FAILED, + value: message, } } diff --git a/ui/app/reducers/app.js b/ui/app/reducers/app.js index d34cd1c2a..49507eb30 100644 --- a/ui/app/reducers/app.js +++ b/ui/app/reducers/app.js @@ -335,7 +335,7 @@ function reduceApp (state, action) { case actions.UNLOCK_FAILED: return extend(appState, { - warning: 'Incorrect password. Try again.', + warning: action.value || 'Incorrect password. Try again.', }) case actions.SHOW_LOADING: diff --git a/ui/app/unlock.js b/ui/app/unlock.js index 5c9a94f39..ec467f483 100644 --- a/ui/app/unlock.js +++ b/ui/app/unlock.js @@ -55,6 +55,8 @@ UnlockScreen.prototype.render = function () { h('.error', { style: { display: warning ? 'block' : 'none', + padding: '0 20px', + textAlign: 'center', }, }, warning), -- cgit From f2bfdd7f8ca4d79b3143f39a7bec3b585d9c74b7 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Tue, 1 Nov 2016 17:04:36 -0700 Subject: Make identicon tolerant of changing state --- ui/app/components/identicon.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'ui') diff --git a/ui/app/components/identicon.js b/ui/app/components/identicon.js index 30ef6fbd3..6d4871d02 100644 --- a/ui/app/components/identicon.js +++ b/ui/app/components/identicon.js @@ -44,3 +44,20 @@ IdenticonComponent.prototype.componentDidMount = function () { container.appendChild(img) } +IdenticonComponent.prototype.componentDidUpdate = function () { + var props = this.props + var address = props.address + + if (!address) return + + var container = findDOMNode(this) + + var children = container.children + for (var i = 0; i < children.length; i++) { + container.removeChild(children[i]) + } + + var diameter = props.diameter || this.defaultDiameter + var img = iconFactory.iconForAddress(address, diameter, false) + container.appendChild(img) +} -- cgit From 8f3db0dbc0bafdc604bd7359bd41370f594c792c Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Tue, 1 Nov 2016 22:19:04 -0700 Subject: Add reveal of seed words. --- ui/app/actions.js | 23 +++++++++++++++++++++++ ui/app/app.js | 4 ++++ ui/app/config.js | 16 ++++++++++++++++ 3 files changed, 43 insertions(+) (limited to 'ui') diff --git a/ui/app/actions.js b/ui/app/actions.js index 8218e05ef..070ba2da0 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -30,6 +30,10 @@ var actions = { addNewAccount, 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', @@ -213,6 +217,25 @@ function createNewVaultAndKeychain (password, entropy) { } } +function revealSeedConfirmation () { + return { + type: this.REVEAL_SEED_CONFIRMATION, + } +} + +function requestRevealSeed (password) { + return (dispatch) => { + dispatch(actions.showLoadingIndication()) + background.submitPassword(password, (err, newState) => { + dispatch(actions.hideLoadingIndication()) + if (err) return dispatch(actions.displayWarning(err.message)) + background.placeSeedWords() + dispatch(actions.showNewVaultSeed()) + }) + } +} + + function addNewKeyring (type, opts) { return (dispatch) => { dispatch(actions.showLoadingIndication()) diff --git a/ui/app/app.js b/ui/app/app.js index 4b1818b93..a2532c153 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -28,6 +28,7 @@ const BuyView = require('./components/buy-button-subview') const QrView = require('./components/qr-code') const HDCreateVaultComplete = require('./keychains/hd/create-vault-complete') const HDRestoreVaultScreen = require('./keychains/hd/restore-vault') +const RevealSeedConfirmation = require('./keychains/hd/recover-seed/confirmation') module.exports = connect(mapStateToProps)(App) @@ -411,6 +412,9 @@ App.prototype.renderPrimary = function () { 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'}) diff --git a/ui/app/config.js b/ui/app/config.js index d4730e558..e09a38cd8 100644 --- a/ui/app/config.js +++ b/ui/app/config.js @@ -77,6 +77,22 @@ 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'), + ]), + ]), ]), ]) -- cgit From e3fb7fa7bbe28dcdb3202c6b228700d5812fbdf9 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Fri, 4 Nov 2016 10:48:24 -0700 Subject: Remove insane actions hash --- ui/app/accounts/index.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'ui') diff --git a/ui/app/accounts/index.js b/ui/app/accounts/index.js index c742d9fac..2e8321a77 100644 --- a/ui/app/accounts/index.js +++ b/ui/app/accounts/index.js @@ -34,11 +34,7 @@ AccountsScreen.prototype.render = function () { var state = this.props var identityList = valuesFor(state.identities) var unconfTxList = valuesFor(state.unconfTxs) - var actions = { - onSelect: this.onSelect.bind(this), - onShowDetail: this.onShowDetail.bind(this), - goHome: this.goHome.bind(this), - } + return ( h('.accounts-section.flex-grow', [ @@ -46,7 +42,7 @@ AccountsScreen.prototype.render = function () { // subtitle and nav h('.section-title.flex-center', [ h('i.fa.fa-arrow-left.fa-lg.cursor-pointer', { - onClick: actions.goHome, + onClick: this.goHome.bind(this), }), h('h2.page-subtitle', 'Select Account'), ]), -- cgit From 23263bec7d5100accd61f7648fd9355fc95e2bb7 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Fri, 11 Nov 2016 10:26:12 -0800 Subject: Linting to the max. --- ui/app/actions.js | 2 +- ui/app/app.js | 2 -- ui/app/components/coinbase-form.js | 8 +++---- ui/app/components/copyButton.js | 4 +--- ui/app/components/drop-menu-item.js | 6 ++--- ui/app/components/network.js | 2 -- ui/app/components/pending-tx.js | 36 +++++++++++++++--------------- ui/app/components/shapeshift-form.js | 4 +--- ui/app/components/shift-list-item.js | 1 - ui/app/components/tooltip.js | 2 -- ui/app/components/transaction-list-item.js | 2 +- ui/app/reducers.js | 2 +- ui/app/reducers/app.js | 1 - ui/lib/account-link.js | 2 +- ui/lib/contract-namer.js | 9 ++++---- ui/lib/icon-factory.js | 4 ++-- 16 files changed, 36 insertions(+), 51 deletions(-) (limited to 'ui') diff --git a/ui/app/actions.js b/ui/app/actions.js index 0d2e7f521..7021c69db 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -145,7 +145,7 @@ var actions = { module.exports = actions var background = null -function _setBackgroundConnection(backgroundConnection) { +function _setBackgroundConnection (backgroundConnection) { background = backgroundConnection } diff --git a/ui/app/app.js b/ui/app/app.js index a2532c153..abe609eca 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -98,7 +98,6 @@ App.prototype.render = function () { } App.prototype.renderAppBar = function () { - if (window.METAMASK_UI_TYPE === 'notification') { return null } @@ -367,7 +366,6 @@ App.prototype.renderPrimary = function () { // show initialize screen if (!props.isInitialized || props.forgottenPassword) { - // show current view switch (props.currentView.name) { diff --git a/ui/app/components/coinbase-form.js b/ui/app/components/coinbase-form.js index 3c5708bf8..693eb2ea8 100644 --- a/ui/app/components/coinbase-form.js +++ b/ui/app/components/coinbase-form.js @@ -7,7 +7,7 @@ const actions = require('../actions') const isValidAddress = require('../util').isValidAddress module.exports = connect(mapStateToProps)(CoinbaseForm) -function mapStateToProps(state) { +function mapStateToProps (state) { return { selectedAccount: state.selectedAccount, warning: state.appState.warning, @@ -16,7 +16,7 @@ function mapStateToProps(state) { inherits(CoinbaseForm, Component) -function CoinbaseForm() { +function CoinbaseForm () { Component.call(this) } @@ -124,7 +124,6 @@ CoinbaseForm.prototype.toCoinbase = function () { } CoinbaseForm.prototype.renderLoading = function () { - return h('img', { style: { width: '27px', @@ -134,9 +133,8 @@ CoinbaseForm.prototype.renderLoading = function () { }) } -function isValidAmountforCoinBase(amount) { +function isValidAmountforCoinBase (amount) { amount = parseFloat(amount) - if (amount) { if (amount <= 5 && amount > 0) { return { diff --git a/ui/app/components/copyButton.js b/ui/app/components/copyButton.js index a01603585..a25d0719c 100644 --- a/ui/app/components/copyButton.js +++ b/ui/app/components/copyButton.js @@ -50,12 +50,10 @@ CopyButton.prototype.render = function () { ]) } -CopyButton.prototype.debounceRestore = function() { - +CopyButton.prototype.debounceRestore = function () { this.setState({ copied: true }) clearTimeout(this.timeout) this.timeout = setTimeout(() => { this.setState({ copied: false }) }, 850) - } diff --git a/ui/app/components/drop-menu-item.js b/ui/app/components/drop-menu-item.js index 8088680c0..5c06101df 100644 --- a/ui/app/components/drop-menu-item.js +++ b/ui/app/components/drop-menu-item.js @@ -32,9 +32,9 @@ DropMenuItem.prototype.render = function () { } DropMenuItem.prototype.activeNetworkRender = function () { - let activeNetwork = this.props.activeNetworkRender - let { provider } = this.props - let providerType = provider ? provider.type : null + const activeNetwork = this.props.activeNetworkRender + const { provider } = this.props + const providerType = provider ? provider.type : null if (activeNetwork === undefined) return switch (this.props.label) { diff --git a/ui/app/components/network.js b/ui/app/components/network.js index ff5aefd41..8e67dd741 100644 --- a/ui/app/components/network.js +++ b/ui/app/components/network.js @@ -22,7 +22,6 @@ Network.prototype.render = function () { let iconName, hoverText if (networkNumber === 'loading') { - return h('img.network-indicator', { title: 'Attempting to connect to blockchain.', onClick: (event) => this.props.onClick(event), @@ -32,7 +31,6 @@ Network.prototype.render = function () { }, src: 'images/loading.svg', }) - } else if (providerName === 'mainnet') { hoverText = 'Main Ethereum Network' iconName = 'ethereum-network' diff --git a/ui/app/components/pending-tx.js b/ui/app/components/pending-tx.js index 96f968929..1fc2f47d0 100644 --- a/ui/app/components/pending-tx.js +++ b/ui/app/components/pending-tx.js @@ -30,22 +30,22 @@ PendingTx.prototype.render = function () { } `), - txData.simulationFails ? - h('.error', { - style: { - marginLeft: 50, - fontSize: '0.9em', - }, - }, 'Transaction Error. Exception thrown in contract code.') + txData.simulationFails + ? h('.error', { + style: { + marginLeft: 50, + fontSize: '0.9em', + }, + }, 'Transaction Error. Exception thrown in contract code.') : null, - state.insufficientBalance ? - h('span.error', { - style: { - marginLeft: 50, - fontSize: '0.9em', - }, - }, 'Insufficient balance for transaction') + state.insufficientBalance + ? h('span.error', { + style: { + marginLeft: 50, + fontSize: '0.9em', + }, + }, 'Insufficient balance for transaction') : null, // send + cancel @@ -57,10 +57,10 @@ PendingTx.prototype.render = function () { }, }, [ - state.insufficientBalance ? - h('button.btn-green', { - onClick: state.buyEth, - }, 'Buy Ether') + state.insufficientBalance + ? h('button.btn-green', { + onClick: state.buyEth, + }, 'Buy Ether') : null, h('button.confirm', { diff --git a/ui/app/components/shapeshift-form.js b/ui/app/components/shapeshift-form.js index 1da549288..383d5b623 100644 --- a/ui/app/components/shapeshift-form.js +++ b/ui/app/components/shapeshift-form.js @@ -8,7 +8,7 @@ const Qr = require('./qr-code') const isValidAddress = require('../util').isValidAddress module.exports = connect(mapStateToProps)(ShapeshiftForm) -function mapStateToProps(state) { +function mapStateToProps (state) { return { selectedAccount: state.selectedAccount, warning: state.appState.warning, @@ -25,7 +25,6 @@ function ShapeshiftForm () { } ShapeshiftForm.prototype.render = function () { - return h(ReactCSSTransitionGroup, { className: 'css-transition-group', transitionName: 'main', @@ -34,7 +33,6 @@ ShapeshiftForm.prototype.render = function () { }, [ this.props.qrRequested ? h(Qr, {key: 'qr'}) : this.renderMain(), ]) - } ShapeshiftForm.prototype.renderMain = function () { diff --git a/ui/app/components/shift-list-item.js b/ui/app/components/shift-list-item.js index 38c19eb28..e0243e247 100644 --- a/ui/app/components/shift-list-item.js +++ b/ui/app/components/shift-list-item.js @@ -26,7 +26,6 @@ function ShiftListItem () { } ShiftListItem.prototype.render = function () { - return ( h('.transaction-list-item.flex-row', { style: { diff --git a/ui/app/components/tooltip.js b/ui/app/components/tooltip.js index 757ad0cd6..edbc074bb 100644 --- a/ui/app/components/tooltip.js +++ b/ui/app/components/tooltip.js @@ -11,7 +11,6 @@ function Tooltip () { } Tooltip.prototype.render = function () { - const props = this.props const { position, title, children } = props @@ -20,5 +19,4 @@ Tooltip.prototype.render = function () { title, fixed: false, }, children) - } diff --git a/ui/app/components/transaction-list-item.js b/ui/app/components/transaction-list-item.js index 491e90c7c..d1306549e 100644 --- a/ui/app/components/transaction-list-item.js +++ b/ui/app/components/transaction-list-item.js @@ -63,7 +63,7 @@ TransactionListItem.prototype.render = function () { style: { fontSize: '27px', }, - }) : h( '.pop-hover', { + }) : h('.pop-hover', { onClick: (event) => { event.stopPropagation() if (!isTx || isPending) return diff --git a/ui/app/reducers.js b/ui/app/reducers.js index a691cf614..4d10e2b39 100644 --- a/ui/app/reducers.js +++ b/ui/app/reducers.js @@ -41,7 +41,7 @@ function rootReducer (state, action) { return state } -window.logState = function() { +window.logState = function () { var stateString = JSON.stringify(window.METAMASK_CACHED_LOG_STATE, null, 2) console.log(stateString) } diff --git a/ui/app/reducers/app.js b/ui/app/reducers/app.js index 49507eb30..ca450fd89 100644 --- a/ui/app/reducers/app.js +++ b/ui/app/reducers/app.js @@ -278,7 +278,6 @@ function reduceApp (state, action) { warning: null, }) } else { - notification.closePopup() return extend(appState, { diff --git a/ui/lib/account-link.js b/ui/lib/account-link.js index eb958e22d..479bf23d2 100644 --- a/ui/lib/account-link.js +++ b/ui/lib/account-link.js @@ -1,4 +1,4 @@ -module.exports = function(address, network) { +module.exports = function (address, network) { const net = parseInt(network) let link diff --git a/ui/lib/contract-namer.js b/ui/lib/contract-namer.js index c99d44de6..a94c62b62 100644 --- a/ui/lib/contract-namer.js +++ b/ui/lib/contract-namer.js @@ -8,23 +8,22 @@ // Nickname keys must be stored in lower case. const nicknames = {} -module.exports = function(addr, identities = {}) { - +module.exports = function (addr, identities = {}) { const address = addr.toLowerCase() const ids = hashFromIdentities(identities) return addrFromHash(address, ids) || addrFromHash(address, nicknames) } -function hashFromIdentities(identities) { +function hashFromIdentities (identities) { const result = {} - for (let key in identities) { + for (const key in identities) { result[key] = identities[key].name } return result } -function addrFromHash(addr, hash) { +function addrFromHash (addr, hash) { const address = addr.toLowerCase() return hash[address] || null } diff --git a/ui/lib/icon-factory.js b/ui/lib/icon-factory.js index a30041114..82cc839d6 100644 --- a/ui/lib/icon-factory.js +++ b/ui/lib/icon-factory.js @@ -55,6 +55,6 @@ function jsNumberForAddress (address) { return seed } -function toDataUri(identiconSrc){ +function toDataUri (identiconSrc) { return 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(identiconSrc) -} \ No newline at end of file +} -- cgit From 3828edf6a4458a59161c445587f581c14baf50fe Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Fri, 11 Nov 2016 10:54:15 -0800 Subject: Typo fix. --- ui/app/keychains/hd/recover-seed/confirmation.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'ui') diff --git a/ui/app/keychains/hd/recover-seed/confirmation.js b/ui/app/keychains/hd/recover-seed/confirmation.js index 83dbc270f..56ac461ea 100644 --- a/ui/app/keychains/hd/recover-seed/confirmation.js +++ b/ui/app/keychains/hd/recover-seed/confirmation.js @@ -5,10 +5,10 @@ const connect = require('react-redux').connect const h = require('react-hyperscript') const actions = require('../../../actions') -module.exports = connect(mapStateToProps)(RevealSeedConfirmatoin) +module.exports = connect(mapStateToProps)(RevealSeedConfirmation) -inherits(RevealSeedConfirmatoin, Component) -function RevealSeedConfirmatoin () { +inherits(RevealSeedConfirmation, Component) +function RevealSeedConfirmation () { Component.call(this) } @@ -18,9 +18,9 @@ function mapStateToProps (state) { } } -RevealSeedConfirmatoin.prototype.confirmationPhrase = 'I understand' +RevealSeedConfirmation.prototype.confirmationPhrase = 'I understand' -RevealSeedConfirmatoin.prototype.render = function () { +RevealSeedConfirmation.prototype.render = function () { const props = this.props const state = this.state @@ -116,24 +116,24 @@ RevealSeedConfirmatoin.prototype.render = function () { ) } -RevealSeedConfirmatoin.prototype.componentDidMount = function () { +RevealSeedConfirmation.prototype.componentDidMount = function () { document.getElementById('password-box').focus() } -RevealSeedConfirmatoin.prototype.goHome = function () { +RevealSeedConfirmation.prototype.goHome = function () { this.props.dispatch(actions.showConfigPage(false)) } // create vault -RevealSeedConfirmatoin.prototype.checkConfirmation = function (event) { +RevealSeedConfirmation.prototype.checkConfirmation = function (event) { if (event.key === 'Enter') { event.preventDefault() this.revealSeedWords() } } -RevealSeedConfirmatoin.prototype.revealSeedWords = function () { +RevealSeedConfirmation.prototype.revealSeedWords = function () { this.setState({ confirmationWrong: false }) const confirmBox = document.getElementById('confirm-box') -- cgit From 0c23925c23ec620feadd97157e804ffa6d1003e6 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Fri, 11 Nov 2016 15:37:22 -0800 Subject: Fix lint rules for ternary operator placement. --- ui/app/components/pending-tx.js | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'ui') diff --git a/ui/app/components/pending-tx.js b/ui/app/components/pending-tx.js index 1fc2f47d0..96f968929 100644 --- a/ui/app/components/pending-tx.js +++ b/ui/app/components/pending-tx.js @@ -30,22 +30,22 @@ PendingTx.prototype.render = function () { } `), - txData.simulationFails - ? h('.error', { - style: { - marginLeft: 50, - fontSize: '0.9em', - }, - }, 'Transaction Error. Exception thrown in contract code.') + txData.simulationFails ? + h('.error', { + style: { + marginLeft: 50, + fontSize: '0.9em', + }, + }, 'Transaction Error. Exception thrown in contract code.') : null, - state.insufficientBalance - ? h('span.error', { - style: { - marginLeft: 50, - fontSize: '0.9em', - }, - }, 'Insufficient balance for transaction') + state.insufficientBalance ? + h('span.error', { + style: { + marginLeft: 50, + fontSize: '0.9em', + }, + }, 'Insufficient balance for transaction') : null, // send + cancel @@ -57,10 +57,10 @@ PendingTx.prototype.render = function () { }, }, [ - state.insufficientBalance - ? h('button.btn-green', { - onClick: state.buyEth, - }, 'Buy Ether') + state.insufficientBalance ? + h('button.btn-green', { + onClick: state.buyEth, + }, 'Buy Ether') : null, h('button.confirm', { -- cgit From 7de6b12aad4a674bdbb0749d2e61d9fd5f69c536 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Mon, 14 Nov 2016 16:49:16 -0800 Subject: Re-enable disclaimer screen. Rename variables to reflect role more clearly. --- ui/app/app.js | 6 +++--- ui/app/reducers/metamask.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'ui') diff --git a/ui/app/app.js b/ui/app/app.js index abe609eca..977392c57 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -39,7 +39,7 @@ function mapStateToProps (state) { return { // state from plugin isLoading: state.appState.isLoading, - isConfirmed: state.metamask.isConfirmed, + isDisclaimerConfirmed: state.metamask.isDisclaimerConfirmed, isInitialized: state.metamask.isInitialized, isUnlocked: state.metamask.isUnlocked, currentView: state.appState.currentView, @@ -323,7 +323,7 @@ App.prototype.renderBackButton = function (style, justArrow = false) { App.prototype.renderBackToInitButton = function () { var props = this.props var button = null - if (!props.isConfirmed) return button + if (!props.isDisclaimerConfirmed) return button if (!props.isUnlocked) { if (props.currentView.name === 'InitMenu') { @@ -356,7 +356,7 @@ App.prototype.renderBackToInitButton = function () { App.prototype.renderPrimary = function () { var props = this.props - if (!props.isConfirmed) { + if (!props.isDisclaimerConfirmed) { return h(DisclaimerScreen, {key: 'disclaimerScreen'}) } diff --git a/ui/app/reducers/metamask.js b/ui/app/reducers/metamask.js index aa809b333..82904dcc6 100644 --- a/ui/app/reducers/metamask.js +++ b/ui/app/reducers/metamask.js @@ -30,7 +30,7 @@ function reduceMetamask (state, action) { case actions.AGREE_TO_DISCLAIMER: return extend(metamaskState, { - isConfirmed: true, + isDisclaimerConfirmed: true, }) case actions.UNLOCK_METAMASK: -- cgit From 5bfb700fa833a415a541a959736d6184d3c07753 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Tue, 15 Nov 2016 17:12:13 -0800 Subject: Minimize dispatches by using emitters and relying on state updates. --- ui/app/actions.js | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) (limited to 'ui') diff --git a/ui/app/actions.js b/ui/app/actions.js index 7021c69db..12ba8fffa 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -161,12 +161,11 @@ function tryUnlockMetamask (password) { return (dispatch) => { dispatch(actions.showLoadingIndication()) dispatch(actions.unlockInProgress()) - background.submitPassword(password, (err, newState) => { + background.submitPassword(password, (err) => { dispatch(actions.hideLoadingIndication()) if (err) { dispatch(actions.unlockFailed(err.message)) } else { - dispatch(this.updateMetamaskState(newState)) let selectedAccount try { selectedAccount = newState.metamask.selectedAccount @@ -195,23 +194,19 @@ function confirmSeedWords () { function createNewVaultAndRestore (password, seed) { return (dispatch) => { dispatch(actions.showLoadingIndication()) - background.createNewVaultAndRestore(password, seed, (err, newState) => { + background.createNewVaultAndRestore(password, seed, (err) => { dispatch(actions.hideLoadingIndication()) if (err) return dispatch(actions.displayWarning(err.message)) - dispatch(this.updateMetamaskState(newState)) }) } } function createNewVaultAndKeychain (password, entropy) { return (dispatch) => { - background.createNewVaultAndKeychain(password, entropy, (err, newState) => { + background.createNewVaultAndKeychain(password, entropy, (err) => { if (err) { return dispatch(actions.showWarning(err.message)) } - - dispatch(this.updateMetamaskState(newState)) - dispatch(this.showNewVaultSeed()) }) } } @@ -225,11 +220,10 @@ function revealSeedConfirmation () { function requestRevealSeed (password) { return (dispatch) => { dispatch(actions.showLoadingIndication()) - background.submitPassword(password, (err, newState) => { + background.submitPassword(password, (err) => { dispatch(actions.hideLoadingIndication()) if (err) return dispatch(actions.displayWarning(err.message)) background.placeSeedWords() - dispatch(actions.showNewVaultSeed()) }) } } @@ -238,13 +232,11 @@ function requestRevealSeed (password) { function addNewKeyring (type, opts) { return (dispatch) => { dispatch(actions.showLoadingIndication()) - background.addNewKeyring(type, opts, (err, newState) => { + background.addNewKeyring(type, opts, (err) => { dispatch(this.hideLoadingIndication()) if (err) { return dispatch(actions.showWarning(err)) } - dispatch(this.updateMetamaskState(newState)) - dispatch(this.showAccountsPage()) }) } } @@ -252,12 +244,11 @@ function addNewKeyring (type, opts) { function addNewAccount (ringNumber = 0) { return (dispatch) => { dispatch(actions.showLoadingIndication()) - background.addNewAccount(ringNumber, (err, newState) => { + background.addNewAccount(ringNumber, (err) => { dispatch(this.hideLoadingIndication()) if (err) { return dispatch(actions.showWarning(err)) } - dispatch(this.updateMetamaskState(newState)) }) } } @@ -457,10 +448,6 @@ function lockMetamask () { if (err) { return dispatch(actions.displayWarning(err.message)) } - - dispatch({ - type: actions.LOCK_METAMASK, - }) }) } } -- cgit From 592b64a19fd7001d965aa1a1c329b24f55d2ea90 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Tue, 15 Nov 2016 17:13:33 -0800 Subject: Revert one cb to previous state. --- ui/app/actions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui') diff --git a/ui/app/actions.js b/ui/app/actions.js index 12ba8fffa..e69b743e9 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -161,7 +161,7 @@ function tryUnlockMetamask (password) { return (dispatch) => { dispatch(actions.showLoadingIndication()) dispatch(actions.unlockInProgress()) - background.submitPassword(password, (err) => { + background.submitPassword(password, (err, newState) => { dispatch(actions.hideLoadingIndication()) if (err) { dispatch(actions.unlockFailed(err.message)) -- cgit