feat: move database migration link from account view to start view
- Remove database migration link from AccountViewView.vue - Add new "Database Tools" section to StartView.vue - Improve user flow by making database tools accessible from start page - Maintain consistent styling and functionality - Clean up account view to focus on account-specific settings The database migration feature is now logically grouped with other identity-related operations and more discoverable for users.
This commit is contained in:
@@ -45,6 +45,7 @@ import { PlatformServiceFactory } from "@/services/PlatformServiceFactory";
|
||||
import { sha256 } from "ethereum-cryptography/sha256";
|
||||
import { IIdentifier } from "@veramo/core";
|
||||
import { insertDidSpecificSettings, parseJsonField } from "../db/databaseUtil";
|
||||
import { DEFAULT_ROOT_DERIVATION_PATH } from "./crypto";
|
||||
|
||||
export interface GiverReceiverInputInfo {
|
||||
did?: string;
|
||||
@@ -998,3 +999,38 @@ export const contactsToExportJson = (contacts: Contact[]): DatabaseExport => {
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Imports an account from a mnemonic phrase
|
||||
* @param mnemonic - The seed phrase to import from
|
||||
* @param derivationPath - The derivation path to use (defaults to DEFAULT_ROOT_DERIVATION_PATH)
|
||||
* @param shouldErase - Whether to erase existing accounts before importing
|
||||
* @returns Promise that resolves when import is complete
|
||||
* @throws Error if mnemonic is invalid or import fails
|
||||
*/
|
||||
export async function importFromMnemonic(
|
||||
mnemonic: string,
|
||||
derivationPath: string = DEFAULT_ROOT_DERIVATION_PATH,
|
||||
shouldErase: boolean = false,
|
||||
): Promise<void> {
|
||||
const mne: string = mnemonic.trim().toLowerCase();
|
||||
|
||||
// Derive address and keys from mnemonic
|
||||
const [address, privateHex, publicHex] = deriveAddress(mne, derivationPath);
|
||||
|
||||
// Create new identifier
|
||||
const newId = newIdentifier(address, publicHex, privateHex, derivationPath);
|
||||
|
||||
// Handle database operations
|
||||
const accountsDB = await accountsDBPromise;
|
||||
if (shouldErase) {
|
||||
const platformService = PlatformServiceFactory.getInstance();
|
||||
await platformService.dbExec("DELETE FROM accounts");
|
||||
if (USE_DEXIE_DB) {
|
||||
await accountsDB.accounts.clear();
|
||||
}
|
||||
}
|
||||
|
||||
// Save the new identity
|
||||
await saveNewIdentity(newId, mne, derivationPath);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user