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
simple-signer
Matthew Aaron Raymer 2 years ago
parent
commit
3687e5e282
  1. 13
      src/views/AccountViewView.vue
  2. 42
      src/views/ImportAccountView.vue

13
src/views/AccountViewView.vue

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

42
src/views/ImportAccountView.vue

@ -21,8 +21,9 @@
type="text" type="text"
placeholder="Seed Phrase" placeholder="Seed Phrase"
class="block w-full rounded border border-slate-400 mb-4 px-3 py-2" 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"> <div class="mt-8">
<button <button
@click="from_mnemonic()" @click="from_mnemonic()"
@ -43,7 +44,9 @@
<script lang="ts"> <script lang="ts">
import { Options, Vue } from "vue-class-component"; 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({ @Options({
components: {}, components: {},
@ -58,15 +61,44 @@ export default class ImportAccountView extends Vue {
public onCancelClick() { public onCancelClick() {
this.$router.back(); this.$router.back();
} }
public from_mnemonic() {
public async from_mnemonic() {
const mne: string = this.mnemonic.trim().toLowerCase();
if (this.mnemonic.trim().length > 0) { if (this.mnemonic.trim().length > 0) {
this.mnemonic = this.mnemonic.trim().toLowerCase();
[ [
this.address, this.address,
this.privateHex, this.privateHex,
this.publicHex, this.publicHex,
this.UPORT_ROOT_DERIVATION_PATH, 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