Skip to content

Commit cd5385c

Browse files
mikespositoMajorLift
authored andcommitted
KeyringController.verifySeedPhrase should return a Uint8Array (#1338)
* refactor: verifySeedPhrase should return a Uint8Array * refactor: verifySeedPhrase should return a Uint8Array * docs: update jsdoc
1 parent ccbf1ff commit cd5385c

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

packages/keyring-controller/src/KeyringController.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,11 @@ describe('KeyringController', () => {
877877
const seedPhrase = await keyringController.verifySeedPhrase();
878878
expect(seedPhrase).toBeDefined();
879879
});
880+
881+
it('should return current seedphrase as Uint8Array', async () => {
882+
const seedPhrase = await keyringController.verifySeedPhrase();
883+
expect(seedPhrase).toBeInstanceOf(Uint8Array);
884+
});
880885
});
881886

882887
describe('validatePassword', () => {

packages/keyring-controller/src/KeyringController.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -621,16 +621,16 @@ export class KeyringController extends BaseController<
621621
/**
622622
* Verifies the that the seed phrase restores the current keychain's accounts.
623623
*
624-
* @returns Whether the verification succeeds.
624+
* @returns Promise resolving to the seed phrase as Uint8Array.
625625
*/
626-
async verifySeedPhrase(): Promise<string> {
626+
async verifySeedPhrase(): Promise<Uint8Array> {
627627
const primaryKeyring = this.#keyring.getKeyringsByType(KeyringTypes.hd)[0];
628628
/* istanbul ignore if */
629629
if (!primaryKeyring) {
630630
throw new Error('No HD keyring found.');
631631
}
632632

633-
const seedWords = (await primaryKeyring.serialize()).mnemonic;
633+
const seedWords = primaryKeyring.mnemonic;
634634
const accounts = await primaryKeyring.getAccounts();
635635
/* istanbul ignore if */
636636
if (accounts.length === 0) {

0 commit comments

Comments
 (0)