Subject line: Added v-model for input box on seed input.

Also completed recovery from seed.  Should be ready to move to Make commitment
This commit is contained in:
Matthew Aaron Raymer
2022-12-22 15:24:17 +08:00
parent 65381e103c
commit 3687e5e282
2 changed files with 44 additions and 15 deletions

View File

@@ -21,8 +21,9 @@
type="text"
placeholder="Seed Phrase"
class="block w-full rounded border border-slate-400 mb-4 px-3 py-2"
v-bind="mnemonic"
v-model="mnemonic"
/>
{{ mnemonic }}
<div class="mt-8">
<button
@click="from_mnemonic()"
@@ -43,7 +44,9 @@
<script lang="ts">
import { Options, Vue } from "vue-class-component";
import { deriveAddress } from "../libs/crypto";
import { deriveAddress, newIdentifier } from "../libs/crypto";
import { db } from "@/db";
import { useAppStore } from "@/store/app";
@Options({
components: {},
@@ -58,15 +61,44 @@ export default class ImportAccountView extends Vue {
public onCancelClick() {
this.$router.back();
}
public from_mnemonic() {
public async from_mnemonic() {
const mne: string = this.mnemonic.trim().toLowerCase();
if (this.mnemonic.trim().length > 0) {
this.mnemonic = this.mnemonic.trim().toLowerCase();
[
this.address,
this.privateHex,
this.publicHex,
this.UPORT_ROOT_DERIVATION_PATH,
] = deriveAddress(this.mnemonic);
] = deriveAddress(mne);
const newId = newIdentifier(
this.address,
this.publicHex,
this.privateHex,
this.UPORT_ROOT_DERIVATION_PATH
);
console.log(newId);
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,
identity: JSON.stringify(newId),
dateCreated: new Date().getTime(),
});
}
useAppStore().setCondition("registered");
this.$router.push({ name: "account" });
} catch (err) {
console.log("Error!");
console.log(err);
}
}
}
}