Refactored wordlist exports to export Wordlist directly.
This commit is contained in:
parent
8a3397dedb
commit
746d255b74
|
@ -11,19 +11,16 @@ import * as constants from "@ethersproject/constants";
|
|||
import * as errors from "@ethersproject/errors";
|
||||
|
||||
import * as providers from "@ethersproject/providers";
|
||||
import * as wordlists from "@ethersproject/wordlists";
|
||||
import { Wordlist, wordlists} from "@ethersproject/wordlists";
|
||||
|
||||
import * as utils from "./utils";
|
||||
|
||||
import { version } from "./_version";
|
||||
|
||||
////////////////////////
|
||||
// Types
|
||||
|
||||
import { BigNumberish } from "@ethersproject/bignumber";
|
||||
import { Bytes, BytesLike, Signature } from "@ethersproject/bytes";
|
||||
import { Transaction, UnsignedTransaction } from "@ethersproject/transactions";
|
||||
import { Wordlist } from "@ethersproject/wordlists/wordlist";
|
||||
|
||||
|
||||
////////////////////////
|
||||
|
@ -33,7 +30,7 @@ import { Wordlist } from "@ethersproject/wordlists/wordlist";
|
|||
import { platform } from "./platform";
|
||||
|
||||
// This is generated by "npm run dist"
|
||||
//import { version } from "./_version";
|
||||
import { version } from "./_version";
|
||||
|
||||
|
||||
////////////////////////
|
||||
|
|
|
@ -4,10 +4,6 @@
|
|||
// See: https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki
|
||||
|
||||
|
||||
// The English language word list.
|
||||
// For additional word lists, please see @ethersproject//wordlists
|
||||
import { langEn } from "@ethersproject/wordlists/lang-en";
|
||||
|
||||
import { ExternallyOwnedAccount } from "@ethersproject/abstract-signer";
|
||||
import { Base58 } from "@ethersproject/basex";
|
||||
import * as errors from "@ethersproject/errors";
|
||||
|
@ -19,11 +15,10 @@ import { defineReadOnly } from "@ethersproject/properties";
|
|||
import { SigningKey } from "@ethersproject/signing-key";
|
||||
import { computeHmac, ripemd160, sha256, SupportedAlgorithms } from "@ethersproject/sha2";
|
||||
import { computeAddress } from "@ethersproject/transactions";
|
||||
import { Wordlist, wordlists } from "@ethersproject/wordlists";
|
||||
|
||||
const N = BigNumber.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141");
|
||||
|
||||
import { Wordlist } from "@ethersproject/wordlists/wordlist";
|
||||
|
||||
|
||||
// "Bitcoin seed"
|
||||
const MasterSecret = toUtf8Bytes("Bitcoin seed");
|
||||
|
@ -271,7 +266,7 @@ export function mnemonicToSeed(mnemonic: string, password?: string): string {
|
|||
}
|
||||
|
||||
export function mnemonicToEntropy(mnemonic: string, wordlist?: Wordlist): string {
|
||||
if (!wordlist) { wordlist = langEn; }
|
||||
if (!wordlist) { wordlist = wordlists["en"]; }
|
||||
|
||||
errors.checkNormalize();
|
||||
|
||||
|
@ -348,7 +343,7 @@ export function entropyToMnemonic(entropy: BytesLike, wordlist?: Wordlist): stri
|
|||
indices[indices.length - 1] <<= checksumBits;
|
||||
indices[indices.length - 1] |= (checksum >> (8 - checksumBits));
|
||||
|
||||
if (!wordlist) { wordlist = langEn; }
|
||||
if (!wordlist) { wordlist = wordlists["en"]; }
|
||||
|
||||
return wordlist.join(indices.map((index) => wordlist.getWord(index)));
|
||||
}
|
||||
|
|
|
@ -6,10 +6,11 @@
|
|||
|
||||
import { Wordlist } from "./wordlist";
|
||||
|
||||
import { langEn as _en } from "./lang-en";
|
||||
import { langEn as en } from "./lang-en";
|
||||
|
||||
const en: Wordlist = _en;
|
||||
const wordlists: { en: Wordlist } = { en: en };
|
||||
|
||||
export {
|
||||
en
|
||||
Wordlist,
|
||||
wordlists
|
||||
}
|
||||
|
|
|
@ -3,27 +3,29 @@
|
|||
// Wordlists
|
||||
// See: https://github.com/bitcoin/bips/blob/master/bip-0039/bip-0039-wordlists.md
|
||||
|
||||
|
||||
import { Wordlist } from "./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 { langZhCn as _zh_cn, langZhTw as _zh_tw } from "./lang-zh";
|
||||
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 { langZhCn as zh_cn, langZhTw as zh_tw } from "./lang-zh";
|
||||
|
||||
const en: Wordlist = _en;
|
||||
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;
|
||||
const wordlists: { [ locale: string ]: Wordlist } = {
|
||||
en: en,
|
||||
es: es,
|
||||
fr: fr,
|
||||
it: it,
|
||||
ja: ja,
|
||||
ko: ko,
|
||||
zh: zh_cn,
|
||||
zh_cn: zh_cn,
|
||||
zh_tw: zh_tw
|
||||
};
|
||||
|
||||
export {
|
||||
en, es, fr, it, ja, ko, zh, zh_cn, zh_tw
|
||||
Wordlist,
|
||||
wordlists
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue