Refactor wordlists.
This commit is contained in:
parent
c11c2e2e33
commit
abab9f6aa2
130
packages/wordlists/dist/wordlist-es.esm.js
vendored
130
packages/wordlists/dist/wordlist-es.esm.js
vendored
File diff suppressed because one or more lines are too long
217
packages/wordlists/dist/wordlist-es.umd.js
vendored
217
packages/wordlists/dist/wordlist-es.umd.js
vendored
File diff suppressed because one or more lines are too long
129
packages/wordlists/dist/wordlist-fr.esm.js
vendored
129
packages/wordlists/dist/wordlist-fr.esm.js
vendored
File diff suppressed because one or more lines are too long
220
packages/wordlists/dist/wordlist-fr.umd.js
vendored
220
packages/wordlists/dist/wordlist-fr.umd.js
vendored
File diff suppressed because one or more lines are too long
95
packages/wordlists/dist/wordlist-it.esm.js
vendored
95
packages/wordlists/dist/wordlist-it.esm.js
vendored
File diff suppressed because one or more lines are too long
152
packages/wordlists/dist/wordlist-it.umd.js
vendored
152
packages/wordlists/dist/wordlist-it.umd.js
vendored
File diff suppressed because one or more lines are too long
187
packages/wordlists/dist/wordlist-ja.esm.js
vendored
187
packages/wordlists/dist/wordlist-ja.esm.js
vendored
@ -1,187 +0,0 @@
|
||||
var global$1 = (typeof global !== "undefined" ? global :
|
||||
typeof self !== "undefined" ? self :
|
||||
typeof window !== "undefined" ? window : {});
|
||||
|
||||
"use strict";
|
||||
const ethers = global$1._ethers;
|
||||
const hexlify = ethers.utils.hexlify;
|
||||
const id = ethers.utils.id;
|
||||
const Logger = ethers.utils.Logger;
|
||||
const defineReadOnly = ethers.utils.defineReadOnly;
|
||||
const toUtf8Bytes = ethers.utils.toUtf8Bytes;
|
||||
const toUtf8String = ethers.utils.toUtf8String;
|
||||
|
||||
const version = "wordlists/5.0.0-beta.133";
|
||||
|
||||
"use strict";
|
||||
// This gets overridden by rollup
|
||||
const exportWordlist = true ;
|
||||
const logger = new Logger(version);
|
||||
function check(wordlist) {
|
||||
const words = [];
|
||||
for (let i = 0; i < 2048; i++) {
|
||||
const word = wordlist.getWord(i);
|
||||
if (i !== wordlist.getWordIndex(word)) {
|
||||
return "0x";
|
||||
}
|
||||
words.push(word);
|
||||
}
|
||||
return id(words.join("\n") + "\n");
|
||||
}
|
||||
class Wordlist {
|
||||
constructor(locale) {
|
||||
logger.checkAbstract(new.target, Wordlist);
|
||||
defineReadOnly(this, "locale", locale);
|
||||
}
|
||||
// Subclasses may override this
|
||||
split(mnemonic) {
|
||||
return mnemonic.toLowerCase().split(/ +/g);
|
||||
}
|
||||
// Subclasses may override this
|
||||
join(words) {
|
||||
return words.join(" ");
|
||||
}
|
||||
}
|
||||
function register(lang, name) {
|
||||
if (!name) {
|
||||
name = lang.locale;
|
||||
}
|
||||
if (exportWordlist) {
|
||||
const g = global$1;
|
||||
if (g._ethers && g._ethers.wordlists) {
|
||||
if (!g._ethers.wordlists[name]) {
|
||||
defineReadOnly(g._ethers.wordlists, name, lang);
|
||||
}
|
||||
/*
|
||||
if (g.wordlists == null) {
|
||||
g.wordlists = g._ethers.wordlists;
|
||||
} else if (g.wordlists[name] == null) {
|
||||
g.wordlists[name] = lang;
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
"use strict";
|
||||
const logger$1 = new Logger(version);
|
||||
const data = [
|
||||
// 4-kana words
|
||||
"AQRASRAGBAGUAIRAHBAghAURAdBAdcAnoAMEAFBAFCBKFBQRBSFBCXBCDBCHBGFBEQBpBBpQBIkBHNBeOBgFBVCBhBBhNBmOBmRBiHBiFBUFBZDBvFBsXBkFBlcBjYBwDBMBBTBBTRBWBBWXXaQXaRXQWXSRXCFXYBXpHXOQXHRXhRXuRXmXXbRXlXXwDXTRXrCXWQXWGaBWaKcaYgasFadQalmaMBacAKaRKKBKKXKKjKQRKDRKCYKCRKIDKeVKHcKlXKjHKrYNAHNBWNaRNKcNIBNIONmXNsXNdXNnBNMBNRBNrXNWDNWMNFOQABQAHQBrQXBQXFQaRQKXQKDQKOQKFQNBQNDQQgQCXQCDQGBQGDQGdQYXQpBQpQQpHQLXQHuQgBQhBQhCQuFQmXQ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gJCCxOEJqXxOwXUJyDJBVRuscisciJBiJBieUtqXiJFDJkiFsJXQUGEZJcUJFsJXZtXIrXZDZJDrZJFNJDZJFstXvJFQqXvJFCJEsJXQJqkhkNGBbDJdTRbYJMEBlDwXUJMEFiJFcfXNJDRcNJWMTBLJXC",
|
||||
// 8-kana words
|
||||
"BraFUtHBFSJFdbNBLJXVJQoYJNEBSJBEJfHSJHwXUJCJdAZJMGjaFVJXEJPNJBlEJfFiJFpFbFEJqIJBVJCrIBdHiJhOPFChvJVJZJNJWxGFNIFLueIBQJqUHEJfUFstOZJDrlXEASJRlXVJXSFwVJNJWD",
|
||||
// 9-kana words
|
||||
"QJEJNNJDQJEJIBSFQJEJxegBQJEJfHEPSJBmXEJFSJCDEJqXLXNJFQqXIcQsFNJFIFEJqXUJgFsJXIJBUJEJfHNFvJxEqXNJnXUJFQqD",
|
||||
// 10-kana words
|
||||
"IJBEJqXZJ"
|
||||
];
|
||||
// Maps each character into its kana value (the index)
|
||||
const mapping = "~~AzB~X~a~KN~Q~D~S~C~G~E~Y~p~L~I~O~eH~g~V~hxyumi~~U~~Z~~v~~s~~dkoblPjfnqwMcRTr~W~~~F~~~~~Jt";
|
||||
let wordlist = null;
|
||||
function hex(word) {
|
||||
return hexlify(toUtf8Bytes(word));
|
||||
}
|
||||
const KiYoKu = "0xe3818de38284e3818f";
|
||||
const KyoKu = "0xe3818de38283e3818f";
|
||||
function loadWords(lang) {
|
||||
if (wordlist !== null) {
|
||||
return;
|
||||
}
|
||||
wordlist = [];
|
||||
// Transforms for normalizing (sort is a not quite UTF-8)
|
||||
const transform = {};
|
||||
// Delete the diacritic marks
|
||||
transform[toUtf8String([227, 130, 154])] = false;
|
||||
transform[toUtf8String([227, 130, 153])] = false;
|
||||
// Some simple transforms that sort out most of the order
|
||||
transform[toUtf8String([227, 130, 133])] = toUtf8String([227, 130, 134]);
|
||||
transform[toUtf8String([227, 129, 163])] = toUtf8String([227, 129, 164]);
|
||||
transform[toUtf8String([227, 130, 131])] = toUtf8String([227, 130, 132]);
|
||||
transform[toUtf8String([227, 130, 135])] = toUtf8String([227, 130, 136]);
|
||||
// Normalize words using the transform
|
||||
function normalize(word) {
|
||||
let result = "";
|
||||
for (let i = 0; i < word.length; i++) {
|
||||
let kana = word[i];
|
||||
const target = transform[kana];
|
||||
if (target === false) {
|
||||
continue;
|
||||
}
|
||||
if (target) {
|
||||
kana = target;
|
||||
}
|
||||
result += kana;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// Sort how the Japanese list is sorted
|
||||
function sortJapanese(a, b) {
|
||||
a = normalize(a);
|
||||
b = normalize(b);
|
||||
if (a < b) {
|
||||
return -1;
|
||||
}
|
||||
if (a > b) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
// Load all the words
|
||||
for (let length = 3; length <= 9; length++) {
|
||||
const d = data[length - 3];
|
||||
for (let offset = 0; offset < d.length; offset += length) {
|
||||
const word = [];
|
||||
for (let i = 0; i < length; i++) {
|
||||
const k = mapping.indexOf(d[offset + i]);
|
||||
word.push(227);
|
||||
word.push((k & 0x40) ? 130 : 129);
|
||||
word.push((k & 0x3f) + 128);
|
||||
}
|
||||
wordlist.push(toUtf8String(word));
|
||||
}
|
||||
}
|
||||
wordlist.sort(sortJapanese);
|
||||
// For some reason kyoku and kiyoku are flipped in node (!!).
|
||||
// The order SHOULD be:
|
||||
// - kyoku
|
||||
// - kiyoku
|
||||
if (hex(wordlist[442]) === KiYoKu && hex(wordlist[443]) === KyoKu) {
|
||||
const tmp = wordlist[442];
|
||||
wordlist[442] = wordlist[443];
|
||||
wordlist[443] = tmp;
|
||||
}
|
||||
if (check(lang) !== "0xcb36b09e6baa935787fd762ce65e80b0c6a8dabdfbc3a7f86ac0e2c4fd111600") {
|
||||
wordlist = null;
|
||||
throw new Error("BIP39 Wordlist for ja (Japanese) FAILED");
|
||||
}
|
||||
}
|
||||
class LangJa extends Wordlist {
|
||||
constructor() {
|
||||
super("ja");
|
||||
}
|
||||
getWord(index) {
|
||||
loadWords(this);
|
||||
return wordlist[index];
|
||||
}
|
||||
getWordIndex(word) {
|
||||
loadWords(this);
|
||||
return wordlist.indexOf(word);
|
||||
}
|
||||
split(mnemonic) {
|
||||
logger$1.checkNormalize();
|
||||
return mnemonic.split(/(?:\u3000| )+/g);
|
||||
}
|
||||
join(words) {
|
||||
return words.join("\u3000");
|
||||
}
|
||||
}
|
||||
const langJa = new LangJa();
|
||||
register(langJa);
|
||||
|
||||
export { langJa };
|
279
packages/wordlists/dist/wordlist-ja.umd.js
vendored
279
packages/wordlists/dist/wordlist-ja.umd.js
vendored
@ -1,279 +0,0 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||
(global = global || self, factory(global._ethers_ja = {}));
|
||||
}(this, function (exports) { 'use strict';
|
||||
|
||||
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
||||
|
||||
function commonjsRequire () {
|
||||
throw new Error('Dynamic requires are not currently supported by rollup-plugin-commonjs');
|
||||
}
|
||||
|
||||
function unwrapExports (x) {
|
||||
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
||||
}
|
||||
|
||||
function createCommonjsModule(fn, module) {
|
||||
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
||||
}
|
||||
|
||||
function getCjsExportFromNamespace (n) {
|
||||
return n && n['default'] || n;
|
||||
}
|
||||
|
||||
var global$1 = (typeof global !== "undefined" ? global :
|
||||
typeof self !== "undefined" ? self :
|
||||
typeof window !== "undefined" ? window : {});
|
||||
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var ethers = global$1._ethers;
|
||||
var hexlify = ethers.utils.hexlify;
|
||||
exports.hexlify = hexlify;
|
||||
var id = ethers.utils.id;
|
||||
exports.id = id;
|
||||
var Logger = ethers.utils.Logger;
|
||||
exports.Logger = Logger;
|
||||
var defineReadOnly = ethers.utils.defineReadOnly;
|
||||
exports.defineReadOnly = defineReadOnly;
|
||||
var toUtf8Bytes = ethers.utils.toUtf8Bytes;
|
||||
exports.toUtf8Bytes = toUtf8Bytes;
|
||||
var toUtf8String = ethers.utils.toUtf8String;
|
||||
exports.toUtf8String = toUtf8String;
|
||||
|
||||
var browserUtils = /*#__PURE__*/Object.freeze({
|
||||
|
||||
});
|
||||
|
||||
var _version = createCommonjsModule(function (module, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.version = "wordlists/5.0.0-beta.133";
|
||||
});
|
||||
|
||||
var _version$1 = unwrapExports(_version);
|
||||
var _version_1 = _version.version;
|
||||
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
// This gets overridden by rollup
|
||||
var exportWordlist = true ;
|
||||
var hash_1 = require("@ethersproject/hash");
|
||||
var properties_1 = require("@ethersproject/properties");
|
||||
var logger_1 = require("@ethersproject/logger");
|
||||
var _version_1$1 = require("./_version");
|
||||
var logger = new logger_1.Logger(_version_1$1.version);
|
||||
function check(wordlist) {
|
||||
var words = [];
|
||||
for (var i = 0; i < 2048; i++) {
|
||||
var word = wordlist.getWord(i);
|
||||
if (i !== wordlist.getWordIndex(word)) {
|
||||
return "0x";
|
||||
}
|
||||
words.push(word);
|
||||
}
|
||||
return hash_1.id(words.join("\n") + "\n");
|
||||
}
|
||||
exports.check = check;
|
||||
var Wordlist = /** @class */ (function () {
|
||||
function Wordlist(locale) {
|
||||
var _newTarget = this.constructor;
|
||||
logger.checkAbstract(_newTarget, Wordlist);
|
||||
properties_1.defineReadOnly(this, "locale", locale);
|
||||
}
|
||||
// Subclasses may override this
|
||||
Wordlist.prototype.split = function (mnemonic) {
|
||||
return mnemonic.toLowerCase().split(/ +/g);
|
||||
};
|
||||
// Subclasses may override this
|
||||
Wordlist.prototype.join = function (words) {
|
||||
return words.join(" ");
|
||||
};
|
||||
return Wordlist;
|
||||
}());
|
||||
exports.Wordlist = Wordlist;
|
||||
function register(lang, name) {
|
||||
if (!name) {
|
||||
name = lang.locale;
|
||||
}
|
||||
if (exportWordlist) {
|
||||
var g = global$1;
|
||||
if (g._ethers && g._ethers.wordlists) {
|
||||
if (!g._ethers.wordlists[name]) {
|
||||
properties_1.defineReadOnly(g._ethers.wordlists, name, lang);
|
||||
}
|
||||
/*
|
||||
if (g.wordlists == null) {
|
||||
g.wordlists = g._ethers.wordlists;
|
||||
} else if (g.wordlists[name] == null) {
|
||||
g.wordlists[name] = lang;
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.register = register;
|
||||
|
||||
var wordlist = /*#__PURE__*/Object.freeze({
|
||||
|
||||
});
|
||||
|
||||
var strings_1 = getCjsExportFromNamespace(browserUtils);
|
||||
|
||||
var wordlist_1 = getCjsExportFromNamespace(wordlist);
|
||||
|
||||
var langJa_1 = createCommonjsModule(function (module, exports) {
|
||||
"use strict";
|
||||
var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
|
||||
|
||||
|
||||
|
||||
var logger = new strings_1.Logger(_version.version);
|
||||
|
||||
var data = [
|
||||
// 4-kana words
|
||||
"AQRASRAGBAGUAIRAHBAghAURAdBAdcAnoAMEAFBAFCBKFBQRBSFBCXB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SBNBYBwDNJeQfXNJeEqXNhGJWENJFiJRQlIJbEQJfXxDQqXcfXQFNDEJQFwXUJDYcnUJDJIBgQDIUJTRDJFEqDSJQSJFSJQIJFSOPeZtSJFZJHCJXQfXCTDEqFGJBSJFGJBOfXGJBcqXGJHNJDGJRLiJEJfXEqEJFEJPEFpBEJYJBZJFYBwXUJYiJMEBYJZJyTYTONJXpQMFXFpeGIDdpJFstXpJFcPDLBVSJRLHQJqXLJFZJFIJBNJDIJBUqXIBkFDJIJEJPTIYJGWRIJeQPDIJeEfHIJFsJXOqGDSFHXEJqXgJCsJCgGQJqXgdQYJEgFMFNBgJFcqDVJwXUJVJFZJchIgJCCxOEJqXxOwXUJyDJBVRuscisciJBiJBieUtqXiJFDJkiFsJXQUGEZJcUJFsJXZtXIrXZDZJDrZJFNJDZJFstXvJFQqXvJFCJEsJXQJqkhkNGBbDJdTRbYJMEBlDwXUJMEFiJFcfXNJDRcNJWMTBLJXC",
|
||||
// 8-kana words
|
||||
"BraFUtHBFSJFdbNBLJXVJQoYJNEBSJBEJfHSJHwXUJCJdAZJMGjaFVJXEJPNJBlEJfFiJFpFbFEJqIJBVJCrIBdHiJhOPFChvJVJZJNJWxGFNIFLueIBQJqUHEJfUFstOZJDrlXEASJRlXVJXSFwVJNJWD",
|
||||
// 9-kana words
|
||||
"QJEJNNJDQJEJIBSFQJEJxegBQJEJfHEPSJBmXEJFSJCDEJqXLXNJFQqXIcQsFNJFIFEJqXUJgFsJXIJBUJEJfHNFvJxEqXNJnXUJFQqD",
|
||||
// 10-kana words
|
||||
"IJBEJqXZJ"
|
||||
];
|
||||
// Maps each character into its kana value (the index)
|
||||
var mapping = "~~AzB~X~a~KN~Q~D~S~C~G~E~Y~p~L~I~O~eH~g~V~hxyumi~~U~~Z~~v~~s~~dkoblPjfnqwMcRTr~W~~~F~~~~~Jt";
|
||||
var wordlist = null;
|
||||
function hex(word) {
|
||||
return strings_1.hexlify(strings_1.toUtf8Bytes(word));
|
||||
}
|
||||
var KiYoKu = "0xe3818de38284e3818f";
|
||||
var KyoKu = "0xe3818de38283e3818f";
|
||||
function loadWords(lang) {
|
||||
if (wordlist !== null) {
|
||||
return;
|
||||
}
|
||||
wordlist = [];
|
||||
// Transforms for normalizing (sort is a not quite UTF-8)
|
||||
var transform = {};
|
||||
// Delete the diacritic marks
|
||||
transform[strings_1.toUtf8String([227, 130, 154])] = false;
|
||||
transform[strings_1.toUtf8String([227, 130, 153])] = false;
|
||||
// Some simple transforms that sort out most of the order
|
||||
transform[strings_1.toUtf8String([227, 130, 133])] = strings_1.toUtf8String([227, 130, 134]);
|
||||
transform[strings_1.toUtf8String([227, 129, 163])] = strings_1.toUtf8String([227, 129, 164]);
|
||||
transform[strings_1.toUtf8String([227, 130, 131])] = strings_1.toUtf8String([227, 130, 132]);
|
||||
transform[strings_1.toUtf8String([227, 130, 135])] = strings_1.toUtf8String([227, 130, 136]);
|
||||
// Normalize words using the transform
|
||||
function normalize(word) {
|
||||
var result = "";
|
||||
for (var i = 0; i < word.length; i++) {
|
||||
var kana = word[i];
|
||||
var target = transform[kana];
|
||||
if (target === false) {
|
||||
continue;
|
||||
}
|
||||
if (target) {
|
||||
kana = target;
|
||||
}
|
||||
result += kana;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// Sort how the Japanese list is sorted
|
||||
function sortJapanese(a, b) {
|
||||
a = normalize(a);
|
||||
b = normalize(b);
|
||||
if (a < b) {
|
||||
return -1;
|
||||
}
|
||||
if (a > b) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
// Load all the words
|
||||
for (var length_1 = 3; length_1 <= 9; length_1++) {
|
||||
var d = data[length_1 - 3];
|
||||
for (var offset = 0; offset < d.length; offset += length_1) {
|
||||
var word = [];
|
||||
for (var i = 0; i < length_1; i++) {
|
||||
var k = mapping.indexOf(d[offset + i]);
|
||||
word.push(227);
|
||||
word.push((k & 0x40) ? 130 : 129);
|
||||
word.push((k & 0x3f) + 128);
|
||||
}
|
||||
wordlist.push(strings_1.toUtf8String(word));
|
||||
}
|
||||
}
|
||||
wordlist.sort(sortJapanese);
|
||||
// For some reason kyoku and kiyoku are flipped in node (!!).
|
||||
// The order SHOULD be:
|
||||
// - kyoku
|
||||
// - kiyoku
|
||||
if (hex(wordlist[442]) === KiYoKu && hex(wordlist[443]) === KyoKu) {
|
||||
var tmp = wordlist[442];
|
||||
wordlist[442] = wordlist[443];
|
||||
wordlist[443] = tmp;
|
||||
}
|
||||
if (wordlist_1.check(lang) !== "0xcb36b09e6baa935787fd762ce65e80b0c6a8dabdfbc3a7f86ac0e2c4fd111600") {
|
||||
wordlist = null;
|
||||
throw new Error("BIP39 Wordlist for ja (Japanese) FAILED");
|
||||
}
|
||||
}
|
||||
var LangJa = /** @class */ (function (_super) {
|
||||
__extends(LangJa, _super);
|
||||
function LangJa() {
|
||||
return _super.call(this, "ja") || this;
|
||||
}
|
||||
LangJa.prototype.getWord = function (index) {
|
||||
loadWords(this);
|
||||
return wordlist[index];
|
||||
};
|
||||
LangJa.prototype.getWordIndex = function (word) {
|
||||
loadWords(this);
|
||||
return wordlist.indexOf(word);
|
||||
};
|
||||
LangJa.prototype.split = function (mnemonic) {
|
||||
logger.checkNormalize();
|
||||
return mnemonic.split(/(?:\u3000| )+/g);
|
||||
};
|
||||
LangJa.prototype.join = function (words) {
|
||||
return words.join("\u3000");
|
||||
};
|
||||
return LangJa;
|
||||
}(wordlist_1.Wordlist));
|
||||
var langJa = new LangJa();
|
||||
exports.langJa = langJa;
|
||||
wordlist_1.register(langJa);
|
||||
});
|
||||
|
||||
var langJa = unwrapExports(langJa_1);
|
||||
var langJa_2 = langJa_1.langJa;
|
||||
|
||||
exports.default = langJa;
|
||||
exports.langJa = langJa_2;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
}));
|
125
packages/wordlists/dist/wordlist-ko.esm.js
vendored
125
packages/wordlists/dist/wordlist-ko.esm.js
vendored
File diff suppressed because one or more lines are too long
205
packages/wordlists/dist/wordlist-ko.umd.js
vendored
205
packages/wordlists/dist/wordlist-ko.umd.js
vendored
File diff suppressed because one or more lines are too long
129
packages/wordlists/dist/wordlist-zh.esm.js
vendored
129
packages/wordlists/dist/wordlist-zh.esm.js
vendored
File diff suppressed because one or more lines are too long
212
packages/wordlists/dist/wordlist-zh.umd.js
vendored
212
packages/wordlists/dist/wordlist-zh.umd.js
vendored
File diff suppressed because one or more lines are too long
@ -3,7 +3,7 @@
|
||||
// Wordlists
|
||||
// See: https://github.com/bitcoin/bips/blob/master/bip-0039/bip-0039-wordlists.md
|
||||
|
||||
import { Wordlist } from "./wordlist";
|
||||
import { logger, Wordlist } from "./wordlist";
|
||||
|
||||
import { langEn as en } from "./lang-en";
|
||||
import { langEs as es } from "./lang-es";
|
||||
@ -26,6 +26,7 @@ const wordlists: { [ locale: string ]: Wordlist } = {
|
||||
};
|
||||
|
||||
export {
|
||||
logger,
|
||||
Wordlist,
|
||||
wordlists
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -3,11 +3,7 @@
|
||||
import { hexlify } from "@ethersproject/bytes";
|
||||
import { toUtf8Bytes, toUtf8String } from "@ethersproject/strings";
|
||||
|
||||
import { Logger } from "@ethersproject/logger";
|
||||
import { version } from "./_version";
|
||||
const logger = new Logger(version);
|
||||
|
||||
import { check, register, Wordlist } from "./wordlist";
|
||||
import { logger, Wordlist } from "./wordlist";
|
||||
|
||||
|
||||
const data = [
|
||||
@ -114,7 +110,7 @@ function loadWords(lang: Wordlist) {
|
||||
wordlist[443] = tmp;
|
||||
}
|
||||
|
||||
if (check(lang) !== "0xcb36b09e6baa935787fd762ce65e80b0c6a8dabdfbc3a7f86ac0e2c4fd111600") {
|
||||
if (Wordlist.check(lang) !== "0xcb36b09e6baa935787fd762ce65e80b0c6a8dabdfbc3a7f86ac0e2c4fd111600") {
|
||||
wordlist = null;
|
||||
throw new Error("BIP39 Wordlist for ja (Japanese) FAILED");
|
||||
}
|
||||
@ -146,7 +142,7 @@ class LangJa extends Wordlist {
|
||||
}
|
||||
|
||||
const langJa = new LangJa();
|
||||
register(langJa);
|
||||
Wordlist.register(langJa);
|
||||
|
||||
export { langJa };
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
import { toUtf8String } from "@ethersproject/strings";
|
||||
|
||||
import { check, register, Wordlist } from "./wordlist";
|
||||
import { Wordlist } from "./wordlist";
|
||||
|
||||
|
||||
const data = [
|
||||
@ -48,7 +48,7 @@ function loadWords(lang: Wordlist): void {
|
||||
|
||||
wordlist.sort();
|
||||
|
||||
if (check(lang) !== "0xf9eddeace9c5d3da9c93cf7d3cd38f6a13ed3affb933259ae865714e8a3ae71a") {
|
||||
if (Wordlist.check(lang) !== "0xf9eddeace9c5d3da9c93cf7d3cd38f6a13ed3affb933259ae865714e8a3ae71a") {
|
||||
wordlist = null;
|
||||
throw new Error("BIP39 Wordlist for ko (Korean) FAILED");
|
||||
}
|
||||
@ -72,6 +72,6 @@ class LangKo extends Wordlist {
|
||||
}
|
||||
|
||||
const langKo = new LangKo();
|
||||
register(langKo);
|
||||
Wordlist.register(langKo);
|
||||
|
||||
export { langKo }
|
||||
|
File diff suppressed because one or more lines are too long
@ -8,17 +8,7 @@ import { defineReadOnly } from "@ethersproject/properties";
|
||||
|
||||
import { Logger } from "@ethersproject/logger";
|
||||
import { version } from "./_version";
|
||||
const logger = new Logger(version);
|
||||
|
||||
export function check(wordlist: Wordlist): string {
|
||||
const words = [];
|
||||
for (let i = 0; i < 2048; i++) {
|
||||
const word = wordlist.getWord(i);
|
||||
if (i !== wordlist.getWordIndex(word)) { return "0x"; }
|
||||
words.push(word);
|
||||
}
|
||||
return id(words.join("\n") + "\n");
|
||||
}
|
||||
export const logger = new Logger(version);
|
||||
|
||||
export abstract class Wordlist {
|
||||
readonly locale: string;
|
||||
@ -40,23 +30,28 @@ export abstract class Wordlist {
|
||||
join(words: Array<string>): string {
|
||||
return words.join(" ");
|
||||
}
|
||||
}
|
||||
|
||||
export function register(lang: Wordlist, name?: string): void {
|
||||
if (!name) { name = lang.locale; }
|
||||
if (exportWordlist) {
|
||||
const g: any = (<any>global)
|
||||
if (g._ethers && g._ethers.wordlists) {
|
||||
if (!g._ethers.wordlists[name]) {
|
||||
defineReadOnly(g._ethers.wordlists, name, lang);
|
||||
static check(wordlist: Wordlist): string {
|
||||
const words = [];
|
||||
for (let i = 0; i < 2048; i++) {
|
||||
const word = wordlist.getWord(i);
|
||||
if (i !== wordlist.getWordIndex(word)) { return "0x"; }
|
||||
words.push(word);
|
||||
}
|
||||
return id(words.join("\n") + "\n");
|
||||
}
|
||||
|
||||
static register(lang: Wordlist, name?: string): void {
|
||||
if (!name) { name = lang.locale; }
|
||||
if (exportWordlist) {
|
||||
const g: any = (<any>global)
|
||||
if (g._ethers && g._ethers.wordlists) {
|
||||
if (!g._ethers.wordlists[name]) {
|
||||
defineReadOnly(g._ethers.wordlists, name, lang);
|
||||
}
|
||||
}
|
||||
/*
|
||||
if (g.wordlists == null) {
|
||||
g.wordlists = g._ethers.wordlists;
|
||||
} else if (g.wordlists[name] == null) {
|
||||
g.wordlists[name] = lang;
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user