Use ethers to validate mnemonic during import (#9463)

feature/default_network_editable
ricky 4 years ago committed by GitHub
parent b3d3518bc0
commit b00cd344d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      package.json
  2. 6
      ui/app/pages/first-time-flow/create-password/import-with-seed-phrase/import-with-seed-phrase.component.js

@ -85,7 +85,6 @@
"analytics-node": "^3.4.0-beta.2",
"await-semaphore": "^0.1.1",
"bignumber.js": "^4.1.0",
"bip39": "^2.2.0",
"bn.js": "^4.11.7",
"c3": "^0.7.10",
"classnames": "^2.2.6",

@ -1,4 +1,4 @@
import { validateMnemonic } from 'bip39'
import { ethers } from 'ethers'
import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
import TextField from '../../../../components/ui/text-field'
@ -8,6 +8,8 @@ import {
INITIALIZE_END_OF_FLOW_ROUTE,
} from '../../../../helpers/constants/routes'
const { isValidMnemonic } = ethers.utils
export default class ImportWithSeedPhrase extends PureComponent {
static contextTypes = {
t: PropTypes.func,
@ -62,7 +64,7 @@ export default class ImportWithSeedPhrase extends PureComponent {
const wordCount = parsedSeedPhrase.split(/\s/u).length
if (wordCount % 3 !== 0 || wordCount > 24 || wordCount < 12) {
seedPhraseError = this.context.t('seedPhraseReq')
} else if (!validateMnemonic(parsedSeedPhrase)) {
} else if (!isValidMnemonic(parsedSeedPhrase)) {
seedPhraseError = this.context.t('invalidSeedPhrase')
}
}

Loading…
Cancel
Save