| 
						
						
							
								
							
						
						
					 | 
					@ -81,7 +81,11 @@ import { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					} from "../libs/crypto"; | 
					 | 
					 | 
					} from "../libs/crypto"; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import { accountsDBPromise, db } from "../db/index"; | 
					 | 
					 | 
					import { accountsDBPromise, db } from "../db/index"; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import { MASTER_SETTINGS_KEY } from "../db/tables/settings"; | 
					 | 
					 | 
					import { MASTER_SETTINGS_KEY } from "../db/tables/settings"; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					import { retrieveAllAccountsMetadata, retrieveFullyDecryptedAccount, saveNewIdentity } from "../libs/util"; | 
					 | 
					 | 
					import { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					  retrieveAllAccountsMetadata, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					  retrieveFullyDecryptedAccount, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					  saveNewIdentity, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					} from "../libs/util"; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import { logger } from "../utils/logger"; | 
					 | 
					 | 
					import { logger } from "../utils/logger"; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import { Account, AccountEncrypted } from "../db/tables/accounts"; | 
					 | 
					 | 
					import { Account, AccountEncrypted } from "../db/tables/accounts"; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import { PlatformServiceFactory } from "@/services/PlatformServiceFactory"; | 
					 | 
					 | 
					import { PlatformServiceFactory } from "@/services/PlatformServiceFactory"; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -100,13 +104,20 @@ export default class ImportAccountView extends Vue { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  async mounted() { | 
					 | 
					 | 
					  async mounted() { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    const accounts: AccountEncrypted[] = await retrieveAllAccountsMetadata(); | 
					 | 
					 | 
					    const accounts: AccountEncrypted[] = await retrieveAllAccountsMetadata(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					    const decryptedAccounts: (Account | undefined)[] = await Promise.all(accounts.map(async (account) => { | 
					 | 
					 | 
					    const decryptedAccounts: (Account | undefined)[] = await Promise.all( | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      accounts.map(async (account) => { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        return retrieveFullyDecryptedAccount(account.did); | 
					 | 
					 | 
					        return retrieveFullyDecryptedAccount(account.did); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					    })); | 
					 | 
					 | 
					      }), | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					    const filteredDecryptedAccounts: Account[] = decryptedAccounts.filter((account) => account !== undefined); | 
					 | 
					 | 
					    ); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    const filteredDecryptedAccounts: Account[] = decryptedAccounts.filter( | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      (account) => account !== undefined, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    ); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    // group by account.mnemonic | 
					 | 
					 | 
					    // group by account.mnemonic | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					    const groupedAccounts: Record<string, Account[]> = R.groupBy((a) => a.mnemonic || "", filteredDecryptedAccounts) as Record<string, Account[]>; | 
					 | 
					 | 
					    const groupedAccounts: Record<string, Account[]> = R.groupBy( | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      (a) => a.mnemonic || "", | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      filteredDecryptedAccounts, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    ) as Record<string, Account[]>; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    this.didArrays = groupedAccounts; | 
					 | 
					 | 
					    this.didArrays = groupedAccounts; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    if (Object.keys(this.didArrays).length > 0) { | 
					 | 
					 | 
					    if (Object.keys(this.didArrays).length > 0) { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -125,10 +136,13 @@ export default class ImportAccountView extends Vue { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  public async incrementDerivation() { | 
					 | 
					 | 
					  public async incrementDerivation() { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    // find the maximum derivation path for the selected DIDs | 
					 | 
					 | 
					    // find the maximum derivation path for the selected DIDs | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    const selectedArray: Array<Account> = | 
					 | 
					 | 
					    const selectedArray: Array<Account> = | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					      Object.values(this.didArrays).find((dids) => dids[0].did === this.selectedArrayFirstDid) || | 
					 | 
					 | 
					      Object.values(this.didArrays).find( | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					      []; | 
					 | 
					 | 
					        (dids) => dids[0].did === this.selectedArrayFirstDid, | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      ) || []; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    // extract the derivationPath array and sort it | 
					 | 
					 | 
					    // extract the derivationPath array and sort it | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					    const derivationPaths = selectedArray.map((account) => account.derivationPath); | 
					 | 
					 | 
					    const derivationPaths = selectedArray.map( | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      (account) => account.derivationPath, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    ); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    derivationPaths.sort((a, b) => { | 
					 | 
					 | 
					    derivationPaths.sort((a, b) => { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      const aParts = a?.split("/"); | 
					 | 
					 | 
					      const aParts = a?.split("/"); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      const aLast = aParts?.[aParts.length - 1]; | 
					 | 
					 | 
					      const aLast = aParts?.[aParts.length - 1]; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -137,7 +151,9 @@ export default class ImportAccountView extends Vue { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      return parseInt(aLast || "0") - parseInt(bLast || "0"); | 
					 | 
					 | 
					      return parseInt(aLast || "0") - parseInt(bLast || "0"); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    }); | 
					 | 
					 | 
					    }); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    // we're sure there's at least one | 
					 | 
					 | 
					    // we're sure there's at least one | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					    const maxDerivPath: string = derivationPaths[derivationPaths.length - 1] as string; | 
					 | 
					 | 
					    const maxDerivPath: string = derivationPaths[ | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      derivationPaths.length - 1 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    ] as string; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    const newDerivPath = nextDerivationPath(maxDerivPath); | 
					 | 
					 | 
					    const newDerivPath = nextDerivationPath(maxDerivPath); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					
  |