-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
2DT
committed
Dec 15, 2020
1 parent
c98de3c
commit 077aa49
Showing
13 changed files
with
448 additions
and
476 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import EducateModals from './EducateModals.vue'; | ||
|
||
export { | ||
EducateModals, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<template> | ||
<b-modal | ||
id="keystore" | ||
:visible="visible" | ||
hide-header | ||
hide-footer | ||
no-close-on-backdrop | ||
no-close-on-esc | ||
> | ||
<b-container> | ||
<fa class="success-icon mx-auto d-block my-4" icon="key" /> | ||
<h4 class="text-center">Protect Wallet</h4> | ||
|
||
<b-form-group | ||
id="password" | ||
label="Your Password" | ||
label-for="password" | ||
> | ||
<b-form-input | ||
id="password" | ||
type="password" | ||
v-model="password" | ||
:state="passwordState" | ||
trim | ||
/> | ||
<b-form-invalid-feedback :state="passwordState"> | ||
Please enter at least 9 characters. | ||
</b-form-invalid-feedback> | ||
</b-form-group> | ||
|
||
<b-alert show variant="warning" class= "my-4"> | ||
<span class="text-danger"><strong>DO NOT FORGET</strong></span> to save your password.<br> | ||
You will need this | ||
<span class="text-danger"><strong>Password + Keystore File</strong></span> | ||
to unlock your wallet. | ||
</b-alert> | ||
<b-row class="mb-2"> | ||
<b-col xs="12" md="6"> | ||
<b-button | ||
size="lg" | ||
variant="light" | ||
class="mx-auto my-2" | ||
@click="backToAuthenticationChoice" | ||
block | ||
> | ||
Back | ||
</b-button> | ||
</b-col> | ||
<b-col xs="12" md="6"> | ||
<b-button | ||
size="lg" | ||
variant="primary" | ||
class="mx-auto my-2" | ||
:disabled="passwordState !== true" | ||
@click="generateKeystore" | ||
block | ||
> | ||
Generate Wallet | ||
</b-button> | ||
</b-col> | ||
</b-row> | ||
</b-container> | ||
</b-modal> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { Component, Prop, Vue } from 'vue-property-decorator'; | ||
import { sdk } from '@/sdk'; | ||
@Component | ||
export default class KeystoreModal extends Vue { | ||
@Prop({ type: Boolean, required: true }) visible = false; | ||
private mnemonic = ''; | ||
private password = ''; | ||
get passwordState(): boolean | null { | ||
if (this.password === '') { | ||
return null; | ||
} | ||
return this.password.length >= 9; | ||
} | ||
private generateMnemonic(): void { | ||
this.mnemonic = new sdk.Crypto.Bip39('en').generate().phrase; | ||
} | ||
private generateKeystore(): void { | ||
this.generateMnemonic(); | ||
const vault = sdk.Crypto.Vault.create(this.mnemonic, '', this.password); | ||
const state = vault.save(); | ||
const fileName = `hyd-wallet-UTC-${new Date().toISOString().replace(/:/g, '_')}.json`; | ||
const blob = new Blob([JSON.stringify(state)], { type: 'application/json' }); | ||
const link = document.createElement('a'); | ||
link.href = URL.createObjectURL(blob); | ||
link.download = fileName; | ||
link.click(); | ||
URL.revokeObjectURL(link.href); | ||
this.$emit('success', true); | ||
} | ||
private backToAuthenticationChoice(): void { | ||
this.$emit('back', true); | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import KeystoreModal from './KeystoreModal.vue'; | ||
|
||
export { | ||
KeystoreModal, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.input-group-text { | ||
min-width: 3rem; | ||
} | ||
|
||
@media (max-width:425px) { | ||
.input-group-text { | ||
font-size: 0.7rem; | ||
} | ||
} |
Oops, something went wrong.