eth-keyring-controller
Advanced tools
Comparing version 7.0.1 to 7.0.2
@@ -9,2 +9,6 @@ # Changelog | ||
## [7.0.2] | ||
### Fixed | ||
- `createNewVaultAndRestore` now accepts a seedphrase formatted as an array of numbers ([#138](https://github.com/MetaMask/KeyringController/pull/138)) | ||
## [7.0.1] | ||
@@ -27,4 +31,5 @@ ### Fixed | ||
[Unreleased]: https://github.com/MetaMask/KeyringController/compare/v7.0.1...HEAD | ||
[Unreleased]: https://github.com/MetaMask/KeyringController/compare/v7.0.2...HEAD | ||
[7.0.2]: https://github.com/MetaMask/KeyringController/compare/v7.0.1...v7.0.2 | ||
[7.0.1]: https://github.com/MetaMask/KeyringController/compare/v7.0.0...v7.0.1 | ||
[7.0.0]: https://github.com/MetaMask/KeyringController/releases/tag/v7.0.0 |
19
index.js
const { EventEmitter } = require('events'); | ||
const bip39 = require('bip39'); | ||
const { Buffer } = require('buffer'); | ||
const bip39 = require('@metamask/bip39'); | ||
const ObservableStore = require('obs-store'); | ||
@@ -95,6 +96,12 @@ const encryptor = require('browser-passworder'); | ||
* @param {string} password - The password to encrypt the vault with | ||
* @param {string} seed - The BIP44-compliant seed phrase. | ||
* @param {string|Array<number>} seedPhrase - The BIP39-compliant seed phrase, | ||
* either as a string or an array of UTF-8 bytes that represent the string. | ||
* @returns {Promise<Object>} A Promise that resolves to the state. | ||
*/ | ||
createNewVaultAndRestore(password, seed) { | ||
createNewVaultAndRestore(password, seedPhrase) { | ||
const seedPhraseAsBuffer = | ||
typeof seedPhrase === 'string' | ||
? Buffer.from(seedPhrase, 'utf8') | ||
: Buffer.from(seedPhrase); | ||
if (typeof password !== 'string') { | ||
@@ -106,3 +113,5 @@ return Promise.reject(new Error('Password must be text.')); | ||
if ( | ||
wordlists.every((wordlist) => !bip39.validateMnemonic(seed, wordlist)) | ||
wordlists.every( | ||
(wordlist) => !bip39.validateMnemonic(seedPhraseAsBuffer, wordlist), | ||
) | ||
) { | ||
@@ -117,3 +126,3 @@ return Promise.reject(new Error('Seed phrase is invalid.')); | ||
return this.addNewKeyring(KEYRINGS_TYPE_MAP.HD_KEYRING, { | ||
mnemonic: seed, | ||
mnemonic: seedPhraseAsBuffer, | ||
numberOfAccounts: 1, | ||
@@ -120,0 +129,0 @@ }); |
{ | ||
"name": "eth-keyring-controller", | ||
"version": "7.0.1", | ||
"version": "7.0.2", | ||
"description": "A module for managing various keyrings of Ethereum accounts, encrypting them, and using them.", | ||
@@ -34,4 +34,4 @@ "keywords": [ | ||
"dependencies": { | ||
"@metamask/bip39": "^4.0.0", | ||
"@metamask/eth-hd-keyring": "^4.0.2", | ||
"bip39": "^3.0.4", | ||
"browser-passworder": "^2.0.3", | ||
@@ -38,0 +38,0 @@ "eth-sig-util": "^3.0.1", |
31468
745
+ Added@metamask/bip39@^4.0.0
- Removedbip39@^3.0.4
- Removed@noble/hashes@1.7.1(transitive)
- Removedbip39@3.1.0(transitive)