Skip to content

Commit

Permalink
refactor: apply @mcmire suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
mikesposito committed Aug 1, 2023
1 parent 285c2fb commit fc64a7b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2921,7 +2921,7 @@ export default class MetamaskController extends EventEmitter {
// create new vault
const vault = await this.coreKeyringController.createNewVaultAndRestore(
password,
this._bufferToUint8Array(seedPhraseAsBuffer),
this._convertMnemonicToWordlistIndices(seedPhraseAsBuffer),
);

const ethQuery = new EthQuery(this.provider);
Expand Down Expand Up @@ -2964,17 +2964,17 @@ export default class MetamaskController extends EventEmitter {
}

/**
* Get a Uint8Array mnemonic from Buffer.
* Encodes a BIP-39 mnemonic as the indices of words in the English BIP-39 wordlist.
*
* @param {Buffer} mnemonic - The mnemonic phrase as a Buffer
* @returns {Uint8Array} The mnemonic phrase as a Uint8Array
* @param {Buffer} mnemonic - The BIP-39 mnemonic.
* @returns {Buffer} The Unicode code points for the seed phrase formed from the words in the wordlist.
*/
_bufferToUint8Array(mnemonic) {
_convertMnemonicToWordlistIndices(mnemonic) {
const indices = mnemonic
.toString()
.split(' ')
.map((word) => wordlist.indexOf(word));
return new Uint8Array(new Uint16Array(indices).buffer);
return new Uint8Array(indices);
}

/**
Expand Down

0 comments on commit fc64a7b

Please sign in to comment.