Skip to content

Commit

Permalink
chore: update example and README
Browse files Browse the repository at this point in the history
  • Loading branch information
ethicnology committed Jul 7, 2022
1 parent 286964d commit 01901cb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ void main() {
// 7e71249c8ebf603afb68e1b4c6fc18c8
print(hex.encode(mnemonic3.seed));
// ad926f1f185ba7745f2c98733a83e51717a58ec83ef52c5cd12048aa8fbe4b2511cf12c2a514d2886510f7020b8a0c1c75bedacfbb3b34cd2f3d8d2c038d531e
// Check if a word is BIP39 compatible
print(Language.english.isValid('baguette')); // false
// NFKD word formatting is mandatory in BIP39, please take care: https://github.com/flutter/flutter/issues/104927#issuecomment-1141140735
var french = Language.french;
String nfkdDisabled = 'échelle';
String nfkdEnabled = 'échelle';
print(french.isValid(nfkdDisabled)); // false
print(french.isValid(nfkdEnabled)); // true
print(french.isValid(nfkd(nfkdDisabled))); // NFKD formatted using unorm
}
```
12 changes: 12 additions & 0 deletions example/bip39_mnemonic_example.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:bip39_mnemonic/bip39_mnemonic.dart';
import 'package:convert/convert.dart'; // convert bytes to hexadecimal and vice-versa
import 'package:unorm_dart/unorm_dart.dart';

void main() {
// DO NOT USE THESE DATA!
Expand Down Expand Up @@ -29,4 +30,15 @@ void main() {
// 7e71249c8ebf603afb68e1b4c6fc18c8
print(hex.encode(mnemonic3.seed));
// ad926f1f185ba7745f2c98733a83e51717a58ec83ef52c5cd12048aa8fbe4b2511cf12c2a514d2886510f7020b8a0c1c75bedacfbb3b34cd2f3d8d2c038d531e

// Check if a word is BIP39 compatible
print(Language.english.isValid('baguette')); // false

// NFKD word formatting is mandatory in BIP39, please take care: https://github.com/flutter/flutter/issues/104927#issuecomment-1141140735
var french = Language.french;
String nfkdDisabled = 'échelle';
String nfkdEnabled = 'échelle';
print(french.isValid(nfkdDisabled)); // false
print(french.isValid(nfkdEnabled)); // true
print(french.isValid(nfkd(nfkdDisabled))); // NFKD formatted using unorm
}

0 comments on commit 01901cb

Please sign in to comment.