@ -200,17 +200,17 @@
< script lang = "ts" >
import { Options , Vue } from "vue-class-component" ;
import { useClipboard } from "@vueuse/core" ;
import { db } from "@/db" ;
import { MASTER_SETTINGS } from "@/db/tables" ;
import { db , accountsDB } from "@/db" ;
import { MASTER_SETTINGS_KEY } from "@/db/tables/setting s" ;
import { deriveAddress , generateSeed , newIdentifier } from "@/libs/crypto" ;
/ / i m p o r t { t e s t S e r v e r R e g i s t e r U s e r } f r o m " . . / t e s t " ;
import { testServerRegisterUser } from "../test" ;
@ Options ( {
components : { } ,
} )
export default class AccountViewView extends Vue {
/ / T h i s r e g i s t e r s c u r r e n t u s e r i n v u e p l u g i n w i t h : $ v m . c t x . t e s t R e g i s t e r U s e r ( )
/ / t e s t R e g i s t e r U s e r = t e s t S e r v e r R e g i s t e r U s e r ;
testRegisterUser = testServerRegisterUser ;
address = "" ;
firstName = "" ;
@ -224,16 +224,17 @@ export default class AccountViewView extends Vue {
/ / ' c r e a t e d ' h o o k r u n s w h e n t h e V u e i n s t a n c e i s f i r s t c r e a t e d
async created ( ) {
await db . open ( ) ;
try {
const settings = await db . settings . get ( MASTER_SETTINGS ) ;
await db . open ( ) ;
const settings = await db . settings . get ( MASTER_SETTINGS_KEY ) ;
if ( settings ) {
this . firstName = settings . firstName || "" ;
this . lastName = settings . lastName || "" ;
this . showContactGives = ! ! settings . showContactGivesInline ;
}
const numAccounts = await db . accounts . count ( ) ;
await accountsDB . open ( ) ;
const numAccounts = await accountsDB . accounts . count ( ) ;
if ( numAccounts === 0 ) {
let privateHex = "" ;
this . mnemonic = generateSeed ( ) ;
@ -246,7 +247,7 @@ export default class AccountViewView extends Vue {
privateHex ,
this . derivationPath
) ;
await db . accounts . add ( {
await accountsDB . accounts . add ( {
dateCreated : new Date ( ) . toISOString ( ) ,
derivationPath : this . derivationPath ,
identity : JSON . stringify ( newId ) ,
@ -254,6 +255,12 @@ export default class AccountViewView extends Vue {
publicKeyHex : newId . keys [ 0 ] . publicKeyHex ,
} ) ;
}
const accounts = await accountsDB . accounts . toArray ( ) ;
const identity = JSON . parse ( accounts [ 0 ] . identity ) ;
this . address = identity . did ;
this . publicHex = identity . keys [ 0 ] . publicKeyHex ;
this . derivationPath = identity . keys [ 0 ] . meta . derivationPath ;
} catch ( err ) {
this . alertMessage =
"Clear your cache and start over (after data backup). See console log for more info." ;
@ -261,21 +268,15 @@ export default class AccountViewView extends Vue {
this . alertTitle = "Error Creating Account" ;
this . isAlertVisible = true ;
}
const accounts = await db . accounts . toArray ( ) ;
const identity = JSON . parse ( accounts [ 0 ] . identity ) ;
this . address = identity . did ;
this . publicHex = identity . keys [ 0 ] . publicKeyHex ;
this . derivationPath = identity . keys [ 0 ] . meta . derivationPath ;
}
public async toggleShowContactAmounts ( ) {
this . showContactGives = ! this . showContactGives ;
try {
await db . open ( ) ;
const settings = await db . settings . get ( MASTER_SETTINGS ) ;
const settings = await db . settings . get ( MASTER_SETTINGS_KEY ) ;
if ( settings ) {
db . settings . update ( MASTER_SETTINGS , {
db . settings . update ( MASTER_SETTINGS_KEY , {
showContactGivesInline : this . showContactGives ,
} ) ;
}