Browse Source

Stil fixing database writes

experimental_plugin
Matthew Aaron Raymer 2 years ago
parent
commit
aad6b8273b
  1. 1
      src/main.ts
  2. 5
      src/router/index.ts
  3. 15
      src/views/AccountViewView.vue

1
src/main.ts

@ -45,6 +45,7 @@ library.add(
); );
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import { db } from "./libs/db";
createApp(App) createApp(App)
.component("fa", FontAwesomeIcon) .component("fa", FontAwesomeIcon)

5
src/router/index.ts

@ -111,14 +111,12 @@ const router = createRouter({
}); });
router.beforeEach(async (to) => { router.beforeEach(async (to) => {
// redirect to start page if app is uninitialized
const publicPages = ["/start", "/account", "/import-account"]; const publicPages = ["/start", "/account", "/import-account"];
const isPublic = publicPages.includes(to.path); const isPublic = publicPages.includes(to.path);
const appStore = useAppStore(); const appStore = useAppStore();
console.log("to:", to.path);
let return_path = "/start"; let return_path = "/start";
if (isPublic) { if (isPublic) {
console.log(appStore.condition);
switch (appStore.condition) { switch (appStore.condition) {
case "uninitialized": case "uninitialized":
return_path = ""; return_path = "";
@ -139,4 +137,5 @@ router.beforeEach(async (to) => {
return return_path; return return_path;
} }
}); });
export default router; export default router;

15
src/views/AccountViewView.vue

@ -171,7 +171,8 @@ import { useAppStore } from "../store/app";
import { useAccountStore } from "../store/account"; import { useAccountStore } from "../store/account";
import { createIdentifier, deriveAddress, newIdentifier } from "../libs/crypto"; import { createIdentifier, deriveAddress, newIdentifier } from "../libs/crypto";
import { IIdentifier } from "@veramo/core"; import { IIdentifier } from "@veramo/core";
import R from "ramda"; import * as R from "ramda";
import { db } from "../libs/db";
@Options({ @Options({
components: {}, components: {},
@ -219,6 +220,18 @@ export default class AccountViewView extends Vue {
privateHex, privateHex,
UPORT_ROOT_DERIVATION_PATH UPORT_ROOT_DERIVATION_PATH
); );
console.log(newId);
db.open();
db.accounts.add({
did: address,
kid: newId.keys[0].kid,
kms: newId.keys[0].kms,
meta: "",
privateKeyHex: privateHex,
publicKeyHex: publicHex,
type: "Secp256k1",
});
db.close();
//appStore.dispatch(appSlice.actions.addLog({log: false, msg: "... created new ID..."})) //appStore.dispatch(appSlice.actions.addLog({log: false, msg: "... created new ID..."}))
accountStore.account = JSON.stringify(newId); accountStore.account = JSON.stringify(newId);
//appStore.dispatch(appSlice.actions.addLog({log: false, msg: "... stored new ID..."})) //appStore.dispatch(appSlice.actions.addLog({log: false, msg: "... stored new ID..."}))

Loading…
Cancel
Save