Browse Source

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

Also completed recovery from seed.  Should be ready to move to Make commitment
kb/add-usage-guide
Matthew Aaron Raymer 2 years ago
parent
commit
3687e5e282
  1. 17
      src/views/AccountViewView.vue
  2. 42
      src/views/ImportAccountView.vue

17
src/views/AccountViewView.vue

@ -206,27 +206,24 @@ export default class AccountViewView extends Vue {
this.publicHex,
this.UPORT_ROOT_DERIVATION_PATH,
] = deriveAddress(this.mnemonic);
//appStore.dispatch(appSlice.actions.addLog({log: false, msg: "... derived keys and address..."}))
const prevIds = previousIdentifiers || [];
if (toLowercase) {
const foundEqual = R.find(
(id: IIdentifier) => id.did.split(":")[2] === this.address,
prevIds
);
if (foundEqual) {
// appStore.dispatch(appSlice.actions.addLog({log: true, msg: "Will create a normal-case version of the DID since a regular version exists."}))
} else {
const foundEqual =
R.find(
(id: IIdentifier) => id.did.split(":")[2] === this.address,
prevIds
) || false;
if (foundEqual === false) {
this.address = this.address.toLowerCase();
}
} else {
// They're not trying to convert to lowercase.
const foundLower = R.find(
(id: IIdentifier) =>
id.did.split(":")[2] === this.address.toLowerCase(),
prevIds
);
if (foundLower) {
// appStore.dispatch(appSlice.actions.addLog({log: true, msg: "Will create a lowercase version of the DID since a lowercase version exists."}))
this.address = this.address.toLowerCase();
}
}

42
src/views/ImportAccountView.vue

@ -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);
}
}
}
}

Loading…
Cancel
Save