1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-26 04:20:53 +01:00

Use ethers to validate mnemonic during import (#9463)

This commit is contained in:
ricky 2020-09-28 17:13:42 -04:00 committed by GitHub
parent b3d3518bc0
commit b00cd344d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

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

View File

@ -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')
}
}