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.
44 lines
1.5 KiB
44 lines
1.5 KiB
3 years ago
|
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)
|
||
|
}
|