Merge pull request #4960 from whymarrh/import-account-error

Show invalid seed phrase error when importing new account
feature/default_network_editable
Whymarrh Whitby 6 years ago committed by GitHub
commit 564fb9f563
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      app/_locales/en/messages.json
  2. 9
      mascara/src/app/first-time/import-seed-phrase-screen.js

@ -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."
},

@ -1,3 +1,4 @@
import {validateMnemonic} from 'bip39'
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import {connect} from 'react-redux'
@ -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 })

Loading…
Cancel
Save