Added French and Spanish BIP-39 wordlists (#191).
This commit is contained in:
parent
281bd0613d
commit
c34a1f73c6
@ -270,6 +270,8 @@ function taskLang(locale) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taskLang("es");
|
||||||
|
taskLang("fr");
|
||||||
taskLang("it");
|
taskLang("it");
|
||||||
taskLang("ja");
|
taskLang("ja");
|
||||||
taskLang("ko");
|
taskLang("ko");
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
"auto-build": "npm run build -- -w",
|
"auto-build": "npm run build -- -w",
|
||||||
"dist": "npm run dist-version && npm run build && gulp default minified && npm run dist-types",
|
"dist": "npm run dist-version && npm run build && gulp default minified && npm run dist-types",
|
||||||
"dist-test": "gulp default-test minified-test",
|
"dist-test": "gulp default-test minified-test",
|
||||||
"dist-bip39": "gulp bip39-it bip39-ja bip39-ko bip39-zh",
|
"dist-bip39": "gulp bip39-es bip39-fr bip39-it bip39-ja bip39-ko bip39-zh",
|
||||||
"dist-types": "dts-bundle --name ethers --main ./index.d.ts --out ./dist/ethers.types.txt",
|
"dist-types": "dts-bundle --name ethers --main ./index.d.ts --out ./dist/ethers.types.txt",
|
||||||
"dist-version": "node -e \"let v = require('./package.json').version; require('fs').writeFileSync('./src.ts/_version.ts', 'export const version = \\\"' + v +'\\\";\\n')\"",
|
"dist-version": "node -e \"let v = require('./package.json').version; require('fs').writeFileSync('./src.ts/_version.ts', 'export const version = \\\"' + v +'\\\";\\n')\"",
|
||||||
"eslint": "eslint index.js contracts/*.js providers/*.js utils/*.js wallet/*.js wordlists/*.js",
|
"eslint": "eslint index.js contracts/*.js providers/*.js utils/*.js wallet/*.js wordlists/*.js",
|
||||||
|
@ -1,21 +1,29 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
// Wordlists
|
||||||
|
// See: https://github.com/bitcoin/bips/blob/master/bip-0039/bip-0039-wordlists.md
|
||||||
|
|
||||||
|
|
||||||
import { Wordlist } from '../utils/wordlist';
|
import { Wordlist } from '../utils/wordlist';
|
||||||
|
|
||||||
|
import { langEn as _en } from './lang-en';
|
||||||
|
import { langEs as _es } from './lang-es';
|
||||||
|
import { langFr as _fr } from './lang-fr';
|
||||||
import { langJa as _ja } from './lang-ja';
|
import { langJa as _ja } from './lang-ja';
|
||||||
import { langKo as _ko } from './lang-ko';
|
import { langKo as _ko } from './lang-ko';
|
||||||
import { langIt as _it } from './lang-it';
|
import { langIt as _it } from './lang-it';
|
||||||
import { langEn as _en } from './lang-en';
|
|
||||||
import { langZhCn as _zh_cn, langZhTw as _zh_tw } from './lang-zh';
|
import { langZhCn as _zh_cn, langZhTw as _zh_tw } from './lang-zh';
|
||||||
|
|
||||||
const en: Wordlist = _en;
|
const en: Wordlist = _en;
|
||||||
const ko: Wordlist = _ko;
|
const es: Wordlist = _es;
|
||||||
|
const fr: Wordlist = _fr;
|
||||||
const it: Wordlist = _it;
|
const it: Wordlist = _it;
|
||||||
const ja: Wordlist = _ja;
|
const ja: Wordlist = _ja;
|
||||||
|
const ko: Wordlist = _ko;
|
||||||
const zh: Wordlist = _zh_cn;
|
const zh: Wordlist = _zh_cn;
|
||||||
const zh_cn: Wordlist = _zh_cn;
|
const zh_cn: Wordlist = _zh_cn;
|
||||||
const zh_tw: Wordlist = _zh_tw;
|
const zh_tw: Wordlist = _zh_tw;
|
||||||
|
|
||||||
export {
|
export {
|
||||||
en, it, ja, ko, zh, zh_cn, zh_tw
|
en, es, fr, it, ja, ko, zh, zh_cn, zh_tw
|
||||||
}
|
}
|
||||||
|
75
src.ts/wordlists/lang-es.ts
Normal file
75
src.ts/wordlists/lang-es.ts
Normal file
File diff suppressed because one or more lines are too long
76
src.ts/wordlists/lang-fr.ts
Normal file
76
src.ts/wordlists/lang-fr.ts
Normal file
File diff suppressed because one or more lines are too long
@ -19,6 +19,8 @@ function checkWordlist(filename, wordlist) {
|
|||||||
|
|
||||||
describe('Check Wordlists', function() {
|
describe('Check Wordlists', function() {
|
||||||
checkWordlist('./wordlist-generation/lang-en.txt', ethers.wordlists.en);
|
checkWordlist('./wordlist-generation/lang-en.txt', ethers.wordlists.en);
|
||||||
|
checkWordlist('./wordlist-generation/lang-es.txt', ethers.wordlists.es);
|
||||||
|
checkWordlist('./wordlist-generation/lang-fr.txt', ethers.wordlists.fr);
|
||||||
checkWordlist('./wordlist-generation/lang-it.txt', ethers.wordlists.it);
|
checkWordlist('./wordlist-generation/lang-it.txt', ethers.wordlists.it);
|
||||||
checkWordlist('./wordlist-generation/lang-ja.txt', ethers.wordlists.ja);
|
checkWordlist('./wordlist-generation/lang-ja.txt', ethers.wordlists.ja);
|
||||||
checkWordlist('./wordlist-generation/lang-ko.txt', ethers.wordlists.ko);
|
checkWordlist('./wordlist-generation/lang-ko.txt', ethers.wordlists.ko);
|
||||||
|
49
tests/wordlist-generation/analyse-es.js
Normal file
49
tests/wordlist-generation/analyse-es.js
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
var fs = require('fs');
|
||||||
|
var ethers = require('../../');
|
||||||
|
|
||||||
|
var words = fs.readFileSync('./lang-es.txt').toString();
|
||||||
|
console.log(ethers.utils.id(words));
|
||||||
|
|
||||||
|
words = words.split('\x0a');
|
||||||
|
|
||||||
|
var chars = {};
|
||||||
|
var charsByte = {};
|
||||||
|
|
||||||
|
var data = words.map((word) => {
|
||||||
|
if (!word) { return ''; }
|
||||||
|
word = word[0].toUpperCase() + word.substring(1);
|
||||||
|
/*
|
||||||
|
for (var i = 0; i < word.length; i++) {
|
||||||
|
chars[word[i]] = (chars[word[i]] || 0) + 1;
|
||||||
|
charsByte[word[i]] = [ word, ethers.utils.toUtf8Bytes(word) ];
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
return word;
|
||||||
|
}).join('');
|
||||||
|
|
||||||
|
data = ethers.utils.toUtf8Bytes(data);
|
||||||
|
|
||||||
|
var output= []
|
||||||
|
|
||||||
|
for (var i = 0; i < data.length; i++) {
|
||||||
|
var c = data[i];
|
||||||
|
chars[data[i]] = (chars[data[i]] || 0) + 1;
|
||||||
|
if ((c >= 65 && c <= 90) || (c >= 97 && c <= 123)) {
|
||||||
|
output.push(c);
|
||||||
|
} else if (c === 129) {
|
||||||
|
output.push(0x30);
|
||||||
|
} else if (c === 131) {
|
||||||
|
output.push(0x31);
|
||||||
|
} else if (c === 204) {
|
||||||
|
output.push(0x32);
|
||||||
|
} else {
|
||||||
|
console.log(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//console.log(chars);
|
||||||
|
|
||||||
|
output = ethers.utils.toUtf8String(output);
|
||||||
|
output = output.replace(/n21/g, '~').replace(/20/g, '/')
|
||||||
|
|
||||||
|
console.log('Output:', output);
|
43
tests/wordlist-generation/analyse-fr.js
Normal file
43
tests/wordlist-generation/analyse-fr.js
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
var fs = require('fs');
|
||||||
|
var ethers = require('../../');
|
||||||
|
|
||||||
|
var words = fs.readFileSync('./lang-fr.txt').toString();
|
||||||
|
console.log(ethers.utils.id(words));
|
||||||
|
|
||||||
|
words = words.split('\x0a');
|
||||||
|
|
||||||
|
var chars = {};
|
||||||
|
var charsByte = {};
|
||||||
|
|
||||||
|
var data = words.map((word) => {
|
||||||
|
if (!word) { return ''; }
|
||||||
|
word = word[0].toUpperCase() + word.substring(1);
|
||||||
|
return word;
|
||||||
|
}).join('');
|
||||||
|
|
||||||
|
data = ethers.utils.toUtf8Bytes(data);
|
||||||
|
|
||||||
|
var output= []
|
||||||
|
|
||||||
|
for (var i = 0; i < data.length; i++) {
|
||||||
|
var c = data[i];
|
||||||
|
chars[data[i]] = (chars[data[i]] || 0) + 1;
|
||||||
|
if ((c >= 65 && c <= 90) || (c >= 97 && c <= 123)) {
|
||||||
|
output.push(c);
|
||||||
|
} else if (c === 128) {
|
||||||
|
output.push(0x31);
|
||||||
|
} else if (c === 129) {
|
||||||
|
output.push(0x30);
|
||||||
|
} else if (c === 204) {
|
||||||
|
output.push(0x32);
|
||||||
|
} else {
|
||||||
|
console.log(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//console.log(chars);
|
||||||
|
|
||||||
|
output = ethers.utils.toUtf8String(output);
|
||||||
|
output = output.replace(/21/g, '-').replace(/20/g, '/')
|
||||||
|
|
||||||
|
console.log('Output:', output);
|
2048
tests/wordlist-generation/lang-es.txt
Normal file
2048
tests/wordlist-generation/lang-es.txt
Normal file
File diff suppressed because it is too large
Load Diff
2048
tests/wordlist-generation/lang-fr.txt
Normal file
2048
tests/wordlist-generation/lang-fr.txt
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user