Skip to content

Commit

Permalink
Show invalid seed phrase error when importing new account
Browse files Browse the repository at this point in the history
  • Loading branch information
whymarrh committed Aug 7, 2018
1 parent 7325ccf commit d061174
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions app/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,9 @@
"invalidRPC": {
"message": "Invalid RPC URI"
},
"invalidSeedPhrase": {
"message": "Invalid seed phrase"
},
"jsonFail": {
"message": "Something went wrong. Please make sure your JSON file is properly formatted."
},
Expand Down
9 changes: 7 additions & 2 deletions mascara/src/app/first-time/import-seed-phrase-screen.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {validateMnemonic} from 'bip39'
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import {connect} from 'react-redux'
Expand Down Expand Up @@ -39,8 +40,12 @@ class ImportSeedPhraseScreen extends Component {
handleSeedPhraseChange (seedPhrase) {
let seedPhraseError = null

if (seedPhrase && this.parseSeedPhrase(seedPhrase).split(' ').length !== 12) {
seedPhraseError = this.context.t('seedPhraseReq')
if (seedPhrase) {
if (this.parseSeedPhrase(seedPhrase).split(' ').length !== 12) {
seedPhraseError = this.context.t('seedPhraseReq')
} else if (!validateMnemonic(seedPhrase)) {
seedPhraseError = this.context.t('invalidSeedPhrase')
}
}

this.setState({ seedPhrase, seedPhraseError })
Expand Down

0 comments on commit d061174

Please sign in to comment.