forked from trent_larson/crowd-funder-for-time-pwa
refactor DB organization (prepping for more tables)
This commit is contained in:
@@ -111,8 +111,8 @@
|
||||
<div class="text-slate-500 text-sm font-bold">Derivation Path</div>
|
||||
<div class="text-sm text-slate-500 mb-1">
|
||||
<span
|
||||
><code>{{ UPORT_ROOT_DERIVATION_PATH }}</code>
|
||||
<button @click="copy(UPORT_ROOT_DERIVATION_PATH)">
|
||||
><code>{{ derivationPath }}</code>
|
||||
<button @click="copy(derivationPath)">
|
||||
<fa icon="copy" class="text-slate-400 fa-fw ml-1"></fa>
|
||||
</button>
|
||||
</span>
|
||||
@@ -174,10 +174,9 @@
|
||||
<script lang="ts">
|
||||
import { Options, Vue } from "vue-class-component";
|
||||
import { useClipboard } from "@vueuse/core";
|
||||
import { createIdentifier, deriveAddress, newIdentifier } from "../libs/crypto";
|
||||
import { deriveAddress, generateSeed, newIdentifier } from "../libs/crypto";
|
||||
import { db } from "../db";
|
||||
import { useAppStore } from "@/store/app";
|
||||
import { ref } from "vue";
|
||||
//import { testServerRegisterUser } from "../test";
|
||||
|
||||
@Options({
|
||||
@@ -196,8 +195,7 @@ export default class AccountViewView extends Vue {
|
||||
address = "";
|
||||
privateHex = "";
|
||||
publicHex = "";
|
||||
UPORT_ROOT_DERIVATION_PATH = "";
|
||||
source = ref("Hello");
|
||||
derivationPath = "";
|
||||
copy = useClipboard().copy;
|
||||
|
||||
// This registers current user in vue plugin with: $vm.ctx.testRegisterUser()
|
||||
@@ -207,29 +205,26 @@ export default class AccountViewView extends Vue {
|
||||
async created() {
|
||||
const appCondition = useAppStore().condition;
|
||||
if (appCondition == "uninitialized") {
|
||||
this.mnemonic = createIdentifier();
|
||||
[
|
||||
this.address,
|
||||
this.privateHex,
|
||||
this.publicHex,
|
||||
this.UPORT_ROOT_DERIVATION_PATH,
|
||||
] = deriveAddress(this.mnemonic);
|
||||
this.mnemonic = generateSeed();
|
||||
[this.address, this.privateHex, this.publicHex, this.derivationPath] =
|
||||
deriveAddress(this.mnemonic);
|
||||
|
||||
const newId = newIdentifier(
|
||||
this.address,
|
||||
this.publicHex,
|
||||
this.privateHex,
|
||||
this.UPORT_ROOT_DERIVATION_PATH
|
||||
this.derivationPath
|
||||
);
|
||||
try {
|
||||
await db.open();
|
||||
const num_accounts = await db.accounts.count();
|
||||
if (num_accounts === 0) {
|
||||
await db.accounts.add({
|
||||
publicKey: newId.keys[0].publicKeyHex,
|
||||
mnemonic: this.mnemonic,
|
||||
dateCreated: new Date(),
|
||||
derivationPath: this.derivationPath,
|
||||
identity: JSON.stringify(newId),
|
||||
dateCreated: new Date().getTime(),
|
||||
mnemonic: this.mnemonic,
|
||||
publicKeyHex: newId.keys[0].publicKeyHex,
|
||||
});
|
||||
}
|
||||
useAppStore().setCondition("registered");
|
||||
@@ -246,7 +241,7 @@ export default class AccountViewView extends Vue {
|
||||
const identity = JSON.parse(accounts[0].identity);
|
||||
this.address = identity.did;
|
||||
this.publicHex = identity.keys[0].publicKeyHex;
|
||||
this.UPORT_ROOT_DERIVATION_PATH = identity.keys[0].meta.derivationPath;
|
||||
this.derivationPath = identity.keys[0].meta.derivationPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user