|
|
@ -617,14 +617,13 @@ export const retrieveAllAccountsMetadata = async (): Promise< |
|
|
|
export const DUPLICATE_ACCOUNT_ERROR = "Cannot import duplicate account."; |
|
|
|
|
|
|
|
/** |
|
|
|
* Saves a new identity to both SQL and Dexie databases |
|
|
|
* Saves a new identity to SQL database |
|
|
|
*/ |
|
|
|
export async function saveNewIdentity( |
|
|
|
identity: IIdentifier, |
|
|
|
mnemonic: string, |
|
|
|
derivationPath: string, |
|
|
|
): Promise<void> { |
|
|
|
try { |
|
|
|
// add to the new sql db
|
|
|
|
const platformService = await getPlatformService(); |
|
|
|
|
|
|
@ -673,10 +672,6 @@ export async function saveNewIdentity( |
|
|
|
await platformService.updateDefaultSettings({ activeDid: identity.did }); |
|
|
|
|
|
|
|
await platformService.insertNewDidIntoSettings(identity.did); |
|
|
|
} catch (error) { |
|
|
|
logger.error("Failed to save new identity:", error); |
|
|
|
throw error; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -1074,7 +1069,6 @@ export async function checkForDuplicateAccount( |
|
|
|
didOrMnemonic: string, |
|
|
|
derivationPath?: string, |
|
|
|
): Promise<boolean> { |
|
|
|
try { |
|
|
|
let didToCheck: string; |
|
|
|
|
|
|
|
if (derivationPath) { |
|
|
@ -1084,12 +1078,7 @@ export async function checkForDuplicateAccount( |
|
|
|
derivationPath, |
|
|
|
); |
|
|
|
|
|
|
|
const newId = newIdentifier( |
|
|
|
address, |
|
|
|
privateHex, |
|
|
|
publicHex, |
|
|
|
derivationPath, |
|
|
|
); |
|
|
|
const newId = newIdentifier(address, privateHex, publicHex, derivationPath); |
|
|
|
didToCheck = newId.did; |
|
|
|
} else { |
|
|
|
// Use the provided DID directly
|
|
|
@ -1104,9 +1093,4 @@ export async function checkForDuplicateAccount( |
|
|
|
); |
|
|
|
|
|
|
|
return (existingAccount?.values?.length ?? 0) > 0; |
|
|
|
} catch (error) { |
|
|
|
// If we can't check for duplicates, let the calling process handle the error
|
|
|
|
logger.error("Error checking for duplicate account:", error); |
|
|
|
throw error; |
|
|
|
} |
|
|
|
} |
|
|
|