Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support BIP39 mnemonic for other languages #191

Closed
zhaozhiming opened this issue Jun 5, 2018 · 7 comments
Closed

Support BIP39 mnemonic for other languages #191

zhaozhiming opened this issue Jun 5, 2018 · 7 comments
Assignees
Labels
enhancement New feature or improvement.

Comments

@zhaozhiming
Copy link

Hi, I found BIP39 not only have English mnemonic, but also have Chinese and so on.
Could ethers.js support other language mnemonic?
I found current stage only have English mnemonic.
If yes, I will be happy to submit a PR to add this feature. Thanks.

@ricmoo
Copy link
Member

ricmoo commented Jun 5, 2018

This cannot be added to the standard package, as the keyword lists are very large and do not compress well, so it would add 3-4Kb for just that one file.

I can make additional packages though which include the other languages, and add support to extend the mnemonic wordlist library. Perhaps something like:

var zh = require('ethers-bip39-zh');
ethers.HDNode.addWordlist(zh);

Would that work for your purposes? I would also include dist files so they can be easily loaded for websites.

@zhaozhiming
Copy link
Author

Sounds good! Yes, I think it's very useful for me. Thanks.

@ricmoo ricmoo self-assigned this Jun 5, 2018
@ricmoo ricmoo added enhancement New feature or improvement. on-deck This Enhancement or Bug is currently being worked on. labels Jun 5, 2018
@ricmoo
Copy link
Member

ricmoo commented Jun 21, 2018

If you are adventurous, this has been added to the TypeScript branch.

// Simplified
const langZh = require('./src/wordlists/lang-zh').langZhCn;

// ...or Traditional
//const langZh = require('./src/wordlists/lang-zh').langZhTw;

var w = ethers.Wallet.createRandom({ locale: lang });
console.log(w.mnemonic);
// 轻 赏 衰 站 蜡 撑 席 顾 闭 咨 冲 抱

Tha API may change, since this is for the next major version, but for now this will suffice, and change will be minor. :)

There are also dist files for using this in a browser. Just include script tags for any language you would like after including ethers.min.js.

<html>
    <body>
        <script src="dist/ethers.min.js"></script>
        <script src="dist/wordlist-zh.js"></script>
    </body>
</html>

Currently supported

  • English
  • Italian
  • Japanese
  • Korean
  • Simplified Chinese
  • Traditional Chinese

@zhaozhiming
Copy link
Author

It's Amazing! I can't wait to use the new version.
So I only have to npm install ethers after the new version publish? Or should I have to install other things?

@ricmoo
Copy link
Member

ricmoo commented Jun 21, 2018

Yupp, after v4 is released, the npm install ethers will be sufficient. All word lists are available in node.

For the browser, we split them out into individual files, since they add about 6-12kb each.

@zhaozhiming
Copy link
Author

That's cool. Thanks.

@ricmoo ricmoo added v4.0 and removed enhancement New feature or improvement. labels Jun 29, 2018
@ricmoo ricmoo removed the v4.0 label Sep 30, 2018
@ricmoo ricmoo added enhancement New feature or improvement. and removed on-deck This Enhancement or Bug is currently being worked on. labels Oct 4, 2018
@ricmoo
Copy link
Member

ricmoo commented Oct 4, 2018

French and Spanish have been added, so all official wordlists are now fully supported. :)

Thanks! :)

@ricmoo ricmoo closed this as completed Oct 4, 2018
asnov added a commit to asnov/ethers.js that referenced this issue Oct 14, 2018
Merge commit '3736a1571480a0f69d632d6fc3bde549cbe46162' into fix/tslib

* commit '3736a1571480a0f69d632d6fc3bde549cbe46162': (41 commits)
  Updated dist files.
  Added automatic event parsing for contract transaction receipts from tx.wait.
  Added ability to wait for a specific number of confirmations (ethers-io#229).
  Fix for geth-etc (official geth is fine), which returns Receipts before the blockHash is synced to the database.
  Fixed confirmations tests and bootstrap fast blockNumber.
  Added confirmations to TransactionResponse (ethers-io#156, ethers-io#238).
  Fixed nested errors for providers that were masking true error (ethers-io#292).
  Updated dist files.
  Added version to errors.
  Fixed French and Spanish for browsers without Uint8Array.forEach.
  Added French and Spanish includes to phantomjs test page.
  Increased timeout for querying npm registry.
  Updated dist files.
  Added French and Spanish wordlist dist files.
  Added French and Spanish BIP-39 wordlists (ethers-io#191).
  Added support for JSON serialized BigNumbers in the constructor (ethers-io#288).
  Fixed scrypt for long passwords (ethers-io#223).
  Updated dist files.
  Added chainId as supported override for contract transactions.
  Fixed wildcard events and made nested events more robust (ethers-io#289).
  ...

Conflicts:
	dist/ethers.min.js
	dist/ethers.min.js.map
	package-lock.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement.
Projects
None yet
Development

No branches or pull requests

2 participants