Skip to content

Commit

Permalink
KeyringController.verifySeedPhrase should return a Uint8Array (#1338)
Browse files Browse the repository at this point in the history
* refactor: verifySeedPhrase should return a Uint8Array

* refactor: verifySeedPhrase should return a Uint8Array

* docs: update jsdoc
  • Loading branch information
mikesposito authored and MajorLift committed Oct 11, 2023
1 parent e65de2e commit c6aae6d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions packages/keyring-controller/src/KeyringController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,11 @@ describe('KeyringController', () => {
const seedPhrase = await keyringController.verifySeedPhrase();
expect(seedPhrase).toBeDefined();
});

it('should return current seedphrase as Uint8Array', async () => {
const seedPhrase = await keyringController.verifySeedPhrase();
expect(seedPhrase).toBeInstanceOf(Uint8Array);
});
});

describe('validatePassword', () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/keyring-controller/src/KeyringController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -621,16 +621,16 @@ export class KeyringController extends BaseController<
/**
* Verifies the that the seed phrase restores the current keychain's accounts.
*
* @returns Whether the verification succeeds.
* @returns Promise resolving to the seed phrase as Uint8Array.
*/
async verifySeedPhrase(): Promise<string> {
async verifySeedPhrase(): Promise<Uint8Array> {
const primaryKeyring = this.#keyring.getKeyringsByType(KeyringTypes.hd)[0];
/* istanbul ignore if */
if (!primaryKeyring) {
throw new Error('No HD keyring found.');
}

const seedWords = (await primaryKeyring.serialize()).mnemonic;
const seedWords = primaryKeyring.mnemonic;
const accounts = await primaryKeyring.getAccounts();
/* istanbul ignore if */
if (accounts.length === 0) {
Expand Down

0 comments on commit c6aae6d

Please sign in to comment.