fix import for derived accounts and hopefully make other account-access code more robust

This commit is contained in:
2025-06-08 19:14:41 -06:00
parent f79568cc5d
commit 26951cc472
6 changed files with 70 additions and 107 deletions

View File

@@ -1356,18 +1356,7 @@ export default class AccountViewView extends Vue {
* Processes the identity and updates the component's state.
*/
async processIdentity() {
let account: Account | undefined = undefined;
const platformService = PlatformServiceFactory.getInstance();
const dbAccount = await platformService.dbQuery(
"SELECT * FROM accounts WHERE did = ?",
[this.activeDid],
);
if (dbAccount) {
account = databaseUtil.mapQueryResultToValues(dbAccount)[0] as Account;
}
if (USE_DEXIE_DB) {
account = await retrieveAccountMetadata(this.activeDid);
}
const account = await retrieveAccountMetadata(this.activeDid);
if (account?.identity) {
const identity = JSON.parse(account.identity as string) as IIdentifier;
this.publicHex = identity.keys[0].publicKeyHex;
@@ -1375,8 +1364,10 @@ export default class AccountViewView extends Vue {
this.derivationPath = identity.keys[0].meta?.derivationPath as string;
await this.checkLimits();
} else if (account?.publicKeyHex) {
// use the backup values in the top level of the account object
this.publicHex = account.publicKeyHex as string;
this.publicBase64 = Buffer.from(this.publicHex, "hex").toString("base64");
this.derivationPath = account.derivationPath as string;
await this.checkLimits();
}
}