1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 02:10:12 +01:00
metamask-extension/patches/eth-keyring-controller+6.2.1.patch
Mark Stacey 98f187c301 Update SRP representation
An array of integers is now used to represent the SRP in three cases:

* In the import wallet flow, the UI uses it to pass the user-provided
  SRP to the background (which converts the array to a buffer).
* In the create wallet flow, the UI uses it to retrieve the generated
  SRP from the background.
* When persisting the wallet to state, the background uses it to
  serialize the SRP.

Co-authored-by: Elliot Winkler <elliot.winkler@gmail.com>
2022-03-30 21:01:26 -02:30

38 lines
1.5 KiB
Diff

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,
})
})