Skip to content

Commit

Permalink
Merge pull request #1 from redDwarf03/main
Browse files Browse the repository at this point in the history
feat: Add a method to validate a specific mnemonic word
  • Loading branch information
ethicnology authored Jul 7, 2022
2 parents 34ec7c7 + 08b689c commit 286964d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,7 @@
- tests update -> 100% coverage

## 3.0.1
- README update
- README update

## 3.0.2
- Add a method to validate a specific menmonic word
5 changes: 5 additions & 0 deletions lib/src/language.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,9 @@ enum Language {
return '\u{0020}'; // space (SP)
}
}

/// isValid checks the provided word presence in the wordlist
bool isValid(String word) {
return list.contains(word);
}
}
6 changes: 3 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: bip39_mnemonic
description: Mnemonic code for generating deterministic keys a.k.a. BIP39.
version: 3.0.1
version: 3.0.2
homepage: https://github.com/ethicnology/dart-bip39-mnemonic

environment:
sdk: '>=2.17.0 <3.0.0'
dev_dependencies:
lints: ^2.0.0
test: ^1.21.1
convert: ^3.0.1
test: ^1.21.3
convert: ^3.0.2
dependencies:
pointycastle: ^3.6.0
unorm_dart: ^0.2.0
23 changes: 23 additions & 0 deletions test/language_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,27 @@ void main() {
}
});
});

group('isValid', () {
test('check if word exists in a list', () {
expect(Language.english.isValid('admit'), true);
});

test('check if word doesn\'t exist in a wrong list', () {
expect(Language.simplifiedChinese.isValid('admit'), false);
});

test('check if word doesn\'t exist in a list', () {
expect(Language.english.isValid('hey'), false);
});

// https://github.com/flutter/flutter/issues/104927#issuecomment-1141319254
test('check if word is NFKD, no', () {
expect(Language.french.isValid('échelle'), false); // non NFKD
});

test('check if word is NFKD, yes', () {
expect(Language.french.isValid('échelle'), true); // NFKD
});
});
}

0 comments on commit 286964d

Please sign in to comment.