Skip to content

Commit 52646a9

Browse files
committed
fix: removed 'addNewSrpBackup' method
1 parent 055a4f5 commit 52646a9

File tree

2 files changed

+10
-123
lines changed

2 files changed

+10
-123
lines changed

packages/seedless-onboarding-controller/src/SeedlessOnboardingController.test.ts

+10-100
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,11 @@ describe('SeedlessOnboardingController', () => {
530530
);
531531

532532
expect(expectedVaultValue).toStrictEqual(resultedVaultValue);
533+
534+
// should be able to get the hash of the seed phrase backup from the state
535+
expect(
536+
controller.getSeedPhraseBackupHash(MOCK_SEED_PHRASE),
537+
).toBeDefined();
533538
},
534539
);
535540
});
@@ -586,6 +591,11 @@ describe('SeedlessOnboardingController', () => {
586591
);
587592

588593
expect(expectedVaultValue).toStrictEqual(resultedVaultValue);
594+
595+
// should be able to get the hash of the seed phrase backup from the state
596+
expect(
597+
controller.getSeedPhraseBackupHash(MOCK_SEED_PHRASE),
598+
).toBeDefined();
589599
},
590600
);
591601
});
@@ -710,106 +720,6 @@ describe('SeedlessOnboardingController', () => {
710720
});
711721
});
712722

713-
describe('addNewSeedPhraseBackup', () => {
714-
const MOCK_PASSWORD = 'mock-password';
715-
const NEW_SEED_PHRASE_1 = 'new mock seed phrase 1';
716-
const NEW_SEED_PHRASE_2 = 'new mock seed phrase 2';
717-
const NEW_SEED_PHRASE_3 = 'new mock seed phrase 3';
718-
let MOCK_VAULT = '';
719-
720-
beforeEach(async () => {
721-
const mockToprfEncryptor = createMockToprfEncryptor();
722-
723-
const MOCK_ENCRYPTION_KEY =
724-
mockToprfEncryptor.deriveEncKey(MOCK_PASSWORD);
725-
const MOCK_AUTH_KEY_PAIR =
726-
mockToprfEncryptor.deriveAuthKeyPair(MOCK_PASSWORD);
727-
728-
MOCK_VAULT = await createMockVault(
729-
MOCK_ENCRYPTION_KEY,
730-
MOCK_AUTH_KEY_PAIR,
731-
MOCK_PASSWORD,
732-
MOCK_NODE_AUTH_TOKENS,
733-
);
734-
});
735-
736-
it('should be able to add a new seed phrase backup', async () => {
737-
await withController(
738-
{ state: getMockInitialControllerState({ vault: MOCK_VAULT }) },
739-
async ({ controller }) => {
740-
// encrypt and store the secret data
741-
const mockSecretDataAdd = handleMockSecretDataAdd();
742-
await controller.addNewSeedPhraseBackup(
743-
stringToBytes(NEW_SEED_PHRASE_1),
744-
MOCK_PASSWORD,
745-
);
746-
747-
expect(mockSecretDataAdd.isDone()).toBe(true);
748-
expect(controller.state.nodeAuthTokens).toBeDefined();
749-
expect(controller.state.nodeAuthTokens).toStrictEqual(
750-
MOCK_NODE_AUTH_TOKENS,
751-
);
752-
},
753-
);
754-
});
755-
756-
it('should be able to add a new seed phrase backup to the existing seed phrase backups', async () => {
757-
await withController(
758-
{ state: getMockInitialControllerState({ vault: MOCK_VAULT }) },
759-
async ({ controller }) => {
760-
// encrypt and store the secret data
761-
const mockSecretDataAdd = handleMockSecretDataAdd();
762-
await controller.addNewSeedPhraseBackup(
763-
stringToBytes(NEW_SEED_PHRASE_1),
764-
MOCK_PASSWORD,
765-
);
766-
767-
expect(mockSecretDataAdd.isDone()).toBe(true);
768-
expect(controller.state.nodeAuthTokens).toBeDefined();
769-
expect(controller.state.nodeAuthTokens).toStrictEqual(
770-
MOCK_NODE_AUTH_TOKENS,
771-
);
772-
expect(controller.state.backupHashes).toStrictEqual([
773-
keccak256AndHexify(stringToBytes(NEW_SEED_PHRASE_1)),
774-
]);
775-
776-
// add another seed phrase backup
777-
const mockSecretDataAdd2 = handleMockSecretDataAdd();
778-
await controller.addNewSeedPhraseBackup(
779-
stringToBytes(NEW_SEED_PHRASE_2),
780-
MOCK_PASSWORD,
781-
);
782-
783-
expect(mockSecretDataAdd2.isDone()).toBe(true);
784-
expect(controller.state.nodeAuthTokens).toBeDefined();
785-
expect(controller.state.nodeAuthTokens).toStrictEqual(
786-
MOCK_NODE_AUTH_TOKENS,
787-
);
788-
789-
const { backupHashes } = controller.state;
790-
expect(backupHashes).toStrictEqual([
791-
keccak256AndHexify(stringToBytes(NEW_SEED_PHRASE_1)),
792-
keccak256AndHexify(stringToBytes(NEW_SEED_PHRASE_2)),
793-
]);
794-
795-
// should be able to get the hash of the seed phrase backup from the state
796-
expect(
797-
controller.getSeedPhraseBackupHash(
798-
stringToBytes(NEW_SEED_PHRASE_1),
799-
),
800-
).toBeDefined();
801-
802-
// should return undefined if the seed phrase is not backed up
803-
expect(
804-
controller.getSeedPhraseBackupHash(
805-
stringToBytes(NEW_SEED_PHRASE_3),
806-
),
807-
).toBeUndefined();
808-
},
809-
);
810-
});
811-
});
812-
813723
describe('fetchAndRestoreSeedPhrase', () => {
814724
const MOCK_PASSWORD = 'mock-password';
815725

packages/seedless-onboarding-controller/src/SeedlessOnboardingController.ts

-23
Original file line numberDiff line numberDiff line change
@@ -212,29 +212,6 @@ export class SeedlessOnboardingController extends BaseController<
212212
});
213213
}
214214

215-
/**
216-
* Add a new seed phrase backup to the metadata store.
217-
*
218-
* @param seedPhrase - The seed phrase to backup.
219-
* @param password - The password used to create new wallet and seedphrase
220-
* @returns A promise that resolves to the success of the operation.
221-
*/
222-
async addNewSeedPhraseBackup(
223-
seedPhrase: Uint8Array,
224-
password: string, // TODO: to verify whether we need the password here, check how multi-srp is handled in the keyring first.
225-
): Promise<void> {
226-
// verify the password and unlock the vault
227-
const { toprfEncryptionKey, toprfAuthKeyPair } =
228-
await this.#unlockVaultWithPassword(password);
229-
230-
// encrypt and store the seed phrase backup
231-
await this.#encryptAndStoreSeedPhraseBackup(
232-
seedPhrase,
233-
toprfEncryptionKey,
234-
toprfAuthKeyPair,
235-
);
236-
}
237-
238215
/**
239216
* Fetches all encrypted seed phrases and metadata for user's account from the metadata store.
240217
*

0 commit comments

Comments
 (0)