refactor DB organization (prepping for more tables)

This commit is contained in:
2023-03-18 17:04:14 -06:00
parent 53204179a2
commit cfeabf05a4
6 changed files with 48 additions and 50 deletions

View File

@@ -56,7 +56,7 @@ export default class ImportAccountView extends Vue {
address = "";
privateHex = "";
publicHex = "";
UPORT_ROOT_DERIVATION_PATH = "";
derivationPath = "";
public onCancelClick() {
this.$router.back();
@@ -65,30 +65,26 @@ export default class ImportAccountView extends Vue {
public async from_mnemonic() {
const mne: string = this.mnemonic.trim().toLowerCase();
if (this.mnemonic.trim().length > 0) {
[
this.address,
this.privateHex,
this.publicHex,
this.UPORT_ROOT_DERIVATION_PATH,
] = deriveAddress(mne);
[this.address, this.privateHex, this.publicHex, this.derivationPath] =
deriveAddress(mne);
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) {
console.log("...");
await db.accounts.add({
publicKey: newId.keys[0].publicKeyHex,
mnemonic: mne,
dateCreated: new Date(),
derivationPath: this.derivationPath,
identity: JSON.stringify(newId),
dateCreated: new Date().getTime(),
mnemonic: mne,
publicKeyHex: newId.keys[0].publicKeyHex,
});
}
useAppStore().setCondition("registered");