A Metamask fork with Infura removed and default networks editable
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
ciphermask/patches/eth-keyring-controller+6.2....

37 lines
1.5 KiB

diff --git a/node_modules/eth-keyring-controller/index.js b/node_modules/eth-keyring-controller/index.js
index 250ab98..38615aa 100644
--- a/node_modules/eth-keyring-controller/index.js
+++ b/node_modules/eth-keyring-controller/index.js
@@ -84,15 +84,20 @@ class KeyringController extends EventEmitter {
*
* @emits KeyringController#unlock
* @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') {
return Promise.reject(new Error('Password must be text.'))
}
- if (!bip39.validateMnemonic(seed)) {
+ if (!bip39.validateMnemonic(seedPhraseAsBuffer)) {
return Promise.reject(new Error('Seed phrase is invalid.'))
}
@@ -101,7 +106,7 @@ class KeyringController extends EventEmitter {
return this.persistAllKeyrings(password)
.then(() => {
return this.addNewKeyring('HD Key Tree', {
- mnemonic: seed,
+ mnemonic: seedPhraseAsBuffer,
numberOfAccounts: 1,
})
})