Skip to content

Commit

Permalink
Validate mnemonic with ethers
Browse files Browse the repository at this point in the history
  • Loading branch information
rickycodes committed Sep 25, 2020
1 parent f424edc commit d3ab579
Show file tree
Hide file tree
Showing 3 changed files with 391 additions and 30 deletions.
12 changes: 5 additions & 7 deletions app/components/Views/ImportFromSeed/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ import {
METRICS_OPT_IN,
TRUE
} from '../../../constants/storage';
// TODO:
// import { validateMnemonic } from 'bip39';
import { ethers } from 'ethers';
import Logger from '../../../util/Logger';

const { isValidMnemonic } = ethers.utils;

const styles = StyleSheet.create({
mainWrapper: {
backgroundColor: colors.white,
Expand Down Expand Up @@ -252,13 +253,10 @@ class ImportFromSeed extends PureComponent {

if (failedSeedPhraseRequirements(seed)) {
error = strings('import_from_seed.seed_phrase_requirements');
} else if (!isValidMnemonic(seed)) {
error = strings('import_from_seed.invalid_seed_phrase');
}

// TODO: do bip39 validate
// else if (!validateMnemonic(seed)) {
// error = strings('import_from_seed.invalid_seed_phrase');
// }

if (error) {
Alert.alert(strings('import_from_seed.error'), error);
} else {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"eth-url-parser": "1.0.2",
"ethereumjs-abi": "0.6.6",
"ethereumjs-util": "6.1.0",
"ethers": "4.0.27",
"ethers": "^5.0.14",
"ethjs-contract": "0.2.3",
"ethjs-ens": "2.0.1",
"ethjs-query": "0.3.8",
Expand Down
Loading

0 comments on commit d3ab579

Please sign in to comment.