Added French and Spanish BIP-39 wordlists (#191).

This commit is contained in:
Richard Moore 2018-10-03 19:58:45 -04:00
parent 281bd0613d
commit c34a1f73c6
No known key found for this signature in database
GPG Key ID: 525F70A6FCABC295
10 changed files with 4355 additions and 4 deletions

View File

@ -270,6 +270,8 @@ function taskLang(locale) {
});
}
taskLang("es");
taskLang("fr");
taskLang("it");
taskLang("ja");
taskLang("ko");

View File

@ -9,7 +9,7 @@
"auto-build": "npm run build -- -w",
"dist": "npm run dist-version && npm run build && gulp default minified && npm run dist-types",
"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-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",

View File

@ -1,21 +1,29 @@
'use strict';
// Wordlists
// See: https://github.com/bitcoin/bips/blob/master/bip-0039/bip-0039-wordlists.md
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 { langKo as _ko } from './lang-ko';
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';
const en: Wordlist = _en;
const ko: Wordlist = _ko;
const es: Wordlist = _es;
const fr: Wordlist = _fr;
const it: Wordlist = _it;
const ja: Wordlist = _ja;
const ko: Wordlist = _ko;
const zh: Wordlist = _zh_cn;
const zh_cn: Wordlist = _zh_cn;
const zh_tw: Wordlist = _zh_tw;
export {
en, it, ja, ko, zh, zh_cn, zh_tw
en, es, fr, it, ja, ko, zh, zh_cn, zh_tw
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -19,6 +19,8 @@ function checkWordlist(filename, wordlist) {
describe('Check Wordlists', function() {
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-ja.txt', ethers.wordlists.ja);
checkWordlist('./wordlist-generation/lang-ko.txt', ethers.wordlists.ko);

View 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);

View 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);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff