|
|
@ -72,12 +72,21 @@ import { |
|
|
|
import { accountsDB, db } from "@/db/index"; |
|
|
|
import { MASTER_SETTINGS_KEY } from "@/db/tables/settings"; |
|
|
|
|
|
|
|
interface Notification { |
|
|
|
group: string; |
|
|
|
type: string; |
|
|
|
title: string; |
|
|
|
text: string; |
|
|
|
} |
|
|
|
|
|
|
|
@Component({ |
|
|
|
components: {}, |
|
|
|
}) |
|
|
|
export default class ImportAccountView extends Vue { |
|
|
|
UPORT_DERIVATION_PATH = "m/7696500'/0'/0'/0'"; // for legacy imports, likely never used |
|
|
|
|
|
|
|
$notify!: (notification: Notification, timeout?: number) => void; |
|
|
|
|
|
|
|
mnemonic = ""; |
|
|
|
address = ""; |
|
|
|
privateHex = ""; |
|
|
@ -91,7 +100,7 @@ export default class ImportAccountView extends Vue { |
|
|
|
|
|
|
|
public async from_mnemonic() { |
|
|
|
const mne: string = this.mnemonic.trim().toLowerCase(); |
|
|
|
if (this.mnemonic.trim().length > 0) { |
|
|
|
try { |
|
|
|
[this.address, this.privateHex, this.publicHex] = deriveAddress( |
|
|
|
mne, |
|
|
|
this.derivationPath, |
|
|
@ -104,7 +113,6 @@ export default class ImportAccountView extends Vue { |
|
|
|
this.derivationPath, |
|
|
|
); |
|
|
|
|
|
|
|
try { |
|
|
|
await accountsDB.open(); |
|
|
|
await accountsDB.accounts.add({ |
|
|
|
dateCreated: new Date().toISOString(), |
|
|
@ -121,8 +129,29 @@ export default class ImportAccountView extends Vue { |
|
|
|
activeDid: newId.did, |
|
|
|
}); |
|
|
|
this.$router.push({ name: "account" }); |
|
|
|
} catch (err) { |
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any |
|
|
|
} catch (err: any) { |
|
|
|
console.error("Error saving mnemonic & updating settings:", err); |
|
|
|
if (err == "Error: invalid mnemonic") { |
|
|
|
this.$notify( |
|
|
|
{ |
|
|
|
group: "alert", |
|
|
|
type: "danger", |
|
|
|
title: "Invalid Mnemonic", |
|
|
|
text: "Please check your mnemonic and try again.", |
|
|
|
}, |
|
|
|
-1, |
|
|
|
); |
|
|
|
} else { |
|
|
|
this.$notify( |
|
|
|
{ |
|
|
|
group: "alert", |
|
|
|
type: "danger", |
|
|
|
title: "Error", |
|
|
|
text: "Got an error creating that identity.", |
|
|
|
}, |
|
|
|
-1, |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|