From 6c05d3105ff55544fe7192732c2976913b44249b Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Sat, 25 Mar 2023 21:43:51 -0600 Subject: [PATCH] parameterize main identifier (to prepare the way for multiple) --- project.yaml | 2 ++ src/db/tables/accounts.ts | 3 +- src/db/tables/settings.ts | 3 +- src/test/index.ts | 12 +++---- src/views/AccountViewView.vue | 45 +++++++++++++++++-------- src/views/ContactAmountsView.vue | 17 ++++++---- src/views/ContactsView.vue | 56 ++++++++++++++++++++------------ src/views/ImportAccountView.vue | 13 +++++++- src/views/NewEditProjectView.vue | 26 ++++++++++----- src/views/ProjectViewView.vue | 18 +++++++--- src/views/ProjectsView.vue | 14 ++++++-- 11 files changed, 142 insertions(+), 67 deletions(-) diff --git a/project.yaml b/project.yaml index b6ed7a253..7cfc3cdcc 100644 --- a/project.yaml +++ b/project.yaml @@ -24,6 +24,8 @@ - get 'copy' to work on account page - contacts v+ : + - .2 warn about amounts when you cannot see them + - .2 confirmed direction is wrong on ContactAmounts screen - .5 make advanced "show/hide amounts" button into a nice UI toggle - .2 show error to user when adding a duplicate contact - parse input more robustly (with CSV lib and not commas) diff --git a/src/db/tables/accounts.ts b/src/db/tables/accounts.ts index 960243966..b42e55ac7 100644 --- a/src/db/tables/accounts.ts +++ b/src/db/tables/accounts.ts @@ -2,6 +2,7 @@ export type Account = { id?: number; // auto-generated by Dexie dateCreated: string; derivationPath: string; + did: string; identity: string; publicKeyHex: string; mnemonic: string; @@ -11,5 +12,5 @@ export type Account = { // see https://github.com/PVermeer/dexie-addon-suite-monorepo/tree/master/packages/dexie-encrypted-addon export const AccountsSchema = { accounts: - "++id, dateCreated, derivationPath, $identity, $mnemonic, publicKeyHex", + "++id, dateCreated, derivationPath, did, $identity, $mnemonic, publicKeyHex", }; diff --git a/src/db/tables/settings.ts b/src/db/tables/settings.ts index 1da602aa9..a2233ece9 100644 --- a/src/db/tables/settings.ts +++ b/src/db/tables/settings.ts @@ -1,6 +1,7 @@ // a singleton export type Settings = { - id: number; + id: number; // there's only one entry: MASTER_SETTINGS_KEY + activeDid?: string; firstName?: string; lastName?: string; showContactGivesInline?: boolean; diff --git a/src/test/index.ts b/src/test/index.ts index fe593da56..2403a9f19 100644 --- a/src/test/index.ts +++ b/src/test/index.ts @@ -1,9 +1,10 @@ import axios from "axios"; import * as didJwt from "did-jwt"; import { AppString } from "@/constants/app"; -import { accountsDB } from "../db"; +import { db } from "../db"; import { SERVICE_ID } from "../libs/veramo/setup"; import { deriveAddress, newIdentifier } from "../libs/crypto"; +import { MASTER_SETTINGS_KEY } from "@/db/tables/settings"; export async function testServerRegisterUser() { const testUser0Mnem = @@ -13,9 +14,8 @@ export async function testServerRegisterUser() { const identity0 = newIdentifier(addr, publicHex, privateHex, deriPath); - await accountsDB.open(); - const accounts = await accountsDB.accounts.toArray(); - const thisIdentity = JSON.parse(accounts[0].identity); + await db.open(); + const settings = await db.settings.get(MASTER_SETTINGS_KEY); // Make a claim const vcClaim = { @@ -23,7 +23,7 @@ export async function testServerRegisterUser() { "@type": "RegisterAction", agent: { did: identity0.did }, object: SERVICE_ID, - participant: { did: thisIdentity.did }, + participant: { did: settings?.activeDid }, }; // Make a payload for the claim const vcPayload = { @@ -56,5 +56,5 @@ export async function testServerRegisterUser() { }; const resp = await axios.post(url, payload, { headers }); - console.log("Result:", resp); + console.log("User registration result:", resp); } diff --git a/src/views/AccountViewView.vue b/src/views/AccountViewView.vue index 243cc4694..75465891f 100644 --- a/src/views/AccountViewView.vue +++ b/src/views/AccountViewView.vue @@ -240,8 +240,11 @@