|
@ -185,46 +185,47 @@ |
|
|
<script lang="ts"> |
|
|
<script lang="ts"> |
|
|
import { Options, Vue } from "vue-class-component"; |
|
|
import { Options, Vue } from "vue-class-component"; |
|
|
import { useClipboard } from "@vueuse/core"; |
|
|
import { useClipboard } from "@vueuse/core"; |
|
|
import { deriveAddress, generateSeed, newIdentifier } from "../libs/crypto"; |
|
|
import { db } from "@/db"; |
|
|
import { db } from "../db"; |
|
|
import { MASTER_SETTINGS } from "@/db/tables"; |
|
|
|
|
|
import { deriveAddress, generateSeed, newIdentifier } from "@/libs/crypto"; |
|
|
//import { testServerRegisterUser } from "../test"; |
|
|
//import { testServerRegisterUser } from "../test"; |
|
|
|
|
|
|
|
|
@Options({ |
|
|
@Options({ |
|
|
components: {}, |
|
|
components: {}, |
|
|
}) |
|
|
}) |
|
|
export default class AccountViewView extends Vue { |
|
|
export default class AccountViewView extends Vue { |
|
|
firstName = |
|
|
// This registers current user in vue plugin with: $vm.ctx.testRegisterUser() |
|
|
localStorage.getItem("firstName") === null |
|
|
//testRegisterUser = testServerRegisterUser; |
|
|
? "--" |
|
|
|
|
|
: localStorage.getItem("firstName"); |
|
|
|
|
|
lastName = |
|
|
|
|
|
localStorage.getItem("lastName") === null |
|
|
|
|
|
? "--" |
|
|
|
|
|
: localStorage.getItem("lastName"); |
|
|
|
|
|
mnemonic = ""; |
|
|
|
|
|
address = ""; |
|
|
address = ""; |
|
|
privateHex = ""; |
|
|
firstName = ""; |
|
|
|
|
|
lastName = ""; |
|
|
|
|
|
mnemonic = ""; |
|
|
publicHex = ""; |
|
|
publicHex = ""; |
|
|
derivationPath = ""; |
|
|
derivationPath = ""; |
|
|
copy = useClipboard().copy; |
|
|
copy = useClipboard().copy; |
|
|
|
|
|
|
|
|
// This registers current user in vue plugin with: $vm.ctx.testRegisterUser() |
|
|
|
|
|
//testRegisterUser = testServerRegisterUser; |
|
|
|
|
|
|
|
|
|
|
|
// 'created' hook runs when the Vue instance is first created |
|
|
// 'created' hook runs when the Vue instance is first created |
|
|
async created() { |
|
|
async created() { |
|
|
await db.open(); |
|
|
await db.open(); |
|
|
const num_accounts = await db.accounts.count(); |
|
|
|
|
|
if (num_accounts === 0) { |
|
|
|
|
|
try { |
|
|
try { |
|
|
|
|
|
const settings = await db.settings.get(MASTER_SETTINGS); |
|
|
|
|
|
if (settings) { |
|
|
|
|
|
this.firstName = settings.firstName || ""; |
|
|
|
|
|
this.lastName = settings.lastName || ""; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const numAccounts = await db.accounts.count(); |
|
|
|
|
|
if (numAccounts === 0) { |
|
|
|
|
|
let privateHex = ""; |
|
|
this.mnemonic = generateSeed(); |
|
|
this.mnemonic = generateSeed(); |
|
|
[this.address, this.privateHex, this.publicHex, this.derivationPath] = |
|
|
[this.address, privateHex, this.publicHex, this.derivationPath] = |
|
|
deriveAddress(this.mnemonic); |
|
|
deriveAddress(this.mnemonic); |
|
|
|
|
|
|
|
|
const newId = newIdentifier( |
|
|
const newId = newIdentifier( |
|
|
this.address, |
|
|
this.address, |
|
|
this.publicHex, |
|
|
this.publicHex, |
|
|
this.privateHex, |
|
|
privateHex, |
|
|
this.derivationPath |
|
|
this.derivationPath |
|
|
); |
|
|
); |
|
|
await db.accounts.add({ |
|
|
await db.accounts.add({ |
|
@ -234,13 +235,13 @@ export default class AccountViewView extends Vue { |
|
|
mnemonic: this.mnemonic, |
|
|
mnemonic: this.mnemonic, |
|
|
publicKeyHex: newId.keys[0].publicKeyHex, |
|
|
publicKeyHex: newId.keys[0].publicKeyHex, |
|
|
}); |
|
|
}); |
|
|
|
|
|
} |
|
|
} catch (err) { |
|
|
} catch (err) { |
|
|
this.alertMessage = |
|
|
this.alertMessage = |
|
|
"Clear your cache and start over. Root Cause: " + err; |
|
|
"Clear your cache and start over (after data backup). See console log for more info."; |
|
|
|
|
|
console.log("Telling user to clear cache because:", err); |
|
|
this.alertTitle = "Error Creating Account"; |
|
|
this.alertTitle = "Error Creating Account"; |
|
|
this.isAlertVisible = true; |
|
|
this.isAlertVisible = true; |
|
|
console.log(err); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const accounts = await db.accounts.toArray(); |
|
|
const accounts = await db.accounts.toArray(); |
|
|