From d0611741a2ca0ef027238bc9022c728e973ce827 Mon Sep 17 00:00:00 2001 From: Whymarrh Whitby Date: Tue, 7 Aug 2018 02:07:16 -0230 Subject: [PATCH] Show invalid seed phrase error when importing new account --- app/_locales/en/messages.json | 3 +++ mascara/src/app/first-time/import-seed-phrase-screen.js | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 8d65bc596..1b0183c92 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -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." }, diff --git a/mascara/src/app/first-time/import-seed-phrase-screen.js b/mascara/src/app/first-time/import-seed-phrase-screen.js index fd2516ad4..883893e88 100644 --- a/mascara/src/app/first-time/import-seed-phrase-screen.js +++ b/mascara/src/app/first-time/import-seed-phrase-screen.js @@ -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 })