mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-30 08:09:15 +01:00
44 lines
1.5 KiB
Diff
44 lines
1.5 KiB
Diff
|
diff --git a/node_modules/eth-hd-keyring/index.js b/node_modules/eth-hd-keyring/index.js
|
||
|
index 19d1d7f..350d6b8 100644
|
||
|
--- a/node_modules/eth-hd-keyring/index.js
|
||
|
+++ b/node_modules/eth-hd-keyring/index.js
|
||
|
@@ -17,8 +17,11 @@ class HdKeyring extends SimpleKeyring {
|
||
|
}
|
||
|
|
||
|
serialize () {
|
||
|
+ const mnemonicAsBuffer = typeof this.mnemonic === 'string'
|
||
|
+ ? Buffer.from(this.mnemonic, 'utf8')
|
||
|
+ : this.mnemonic
|
||
|
return Promise.resolve({
|
||
|
- mnemonic: this.mnemonic,
|
||
|
+ mnemonic: Array.from(mnemonicAsBuffer.values()),
|
||
|
numberOfAccounts: this.wallets.length,
|
||
|
hdPath: this.hdPath,
|
||
|
})
|
||
|
@@ -69,9 +72,22 @@ class HdKeyring extends SimpleKeyring {
|
||
|
|
||
|
/* PRIVATE METHODS */
|
||
|
|
||
|
- _initFromMnemonic (mnemonic) {
|
||
|
- this.mnemonic = mnemonic
|
||
|
- const seed = bip39.mnemonicToSeed(mnemonic)
|
||
|
+ /**
|
||
|
+ * Sets appropriate properties for the keyring based on the given
|
||
|
+ * BIP39-compliant mnemonic.
|
||
|
+ *
|
||
|
+ * @param {string|Array<number>|Buffer} mnemonic - A seed phrase represented
|
||
|
+ * as a string, an array of UTF-8 bytes, or a Buffer.
|
||
|
+ */
|
||
|
+ _initFromMnemonic(mnemonic) {
|
||
|
+ if (typeof mnemonic === 'string') {
|
||
|
+ this.mnemonic = Buffer.from(mnemonic, 'utf8')
|
||
|
+ } else if (Array.isArray(mnemonic)) {
|
||
|
+ this.mnemonic = Buffer.from(mnemonic)
|
||
|
+ } else {
|
||
|
+ this.mnemonic = mnemonic
|
||
|
+ }
|
||
|
+ const seed = bip39.mnemonicToSeed(this.mnemonic)
|
||
|
this.hdWallet = hdkey.fromMasterSeed(seed)
|
||
|
this.root = this.hdWallet.derivePath(this.hdPath)
|
||
|
}
|