Skip to content

Commit

Permalink
Refactored CreateWallet
Browse files Browse the repository at this point in the history
  • Loading branch information
2DT committed Dec 15, 2020
1 parent c98de3c commit 077aa49
Show file tree
Hide file tree
Showing 13 changed files with 448 additions and 476 deletions.
5 changes: 0 additions & 5 deletions src/components/EducateModal/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<template>
<div>
<b-modal
<div>
<b-modal
id="educate-1"
hide-header
hide-footer
no-close-on-esc
hide-header-close
no-close-on-backdrop
>
<h4 class="text-center mt-4">Welcome to the Hydra Web Wallet</h4>
<h6 class="text-center">
<h4 class="text-center my-4">Welcome to the Hydra Web Wallet</h4>
<p class="text-justify">
Please take a moment to read through this short introduction.
It’s very important for your own security that you understand these warnings.
Ignoring this step will highly increase the chances of your funds being lost or stolen,
in which case we won’t be able to help you.
<b-link @click="advanceEducateFlowTo(0)">Skip</b-link> at your own risk.
</h6>
</p>
<b-row no-gutters>
<b-col class="text-center">
<b-button @click="advanceEducateFlowTo(2)" variant="outline-primary" class="my-4">
<b-button @click="advanceEducateFlowTo(2)" variant="primary" class="my-2">
Continue
</b-button>
</b-col>
Expand All @@ -33,8 +33,8 @@
hide-header-close
no-close-on-backdrop
>
<h4 class="text-center mt-4">What is Hydra Web Wallet?</h4>
<p>
<h4 class="text-center my-4">What is Hydra Web Wallet?</h4>
<p class="text-justify">
Hydra Web Wallet (HWW) is an open-source, client-side interface.
HWW allows you to interact directly with the Hydra network,
while you remain in full control of your keys and funds.
Expand All @@ -43,13 +43,13 @@
This means we can't access accounts,
recover keys, reset passwords, or reverse transactions.
</p>
<b-alert show variant="danger" class="small">
<b-alert show variant="danger" class="small mt-2">
<strong>WARNING: You And Only You Are Responsible For Your Security.</strong>
</b-alert>

<b-row no-gutters>
<b-col class="text-center">
<b-button @click="advanceEducateFlowTo(3)" variant="outline-primary" class="my-4">
<b-button @click="advanceEducateFlowTo(3)" variant="primary" class="my-2">
Continue
</b-button>
</b-col>
Expand All @@ -64,8 +64,8 @@
hide-header-close
no-close-on-backdrop
>
<h4 class="text-center mt-4">Where are my funds stored?</h4>
<p>
<h4 class="text-center my-4">Where are my funds stored?</h4>
<p class="text-justify">
Your Hydras are not on HWW.
Just like they aren't on your hardware wallet or on blockchain explorers.
All funds are on the blockchain itself. This means that we do not control them.
Expand All @@ -77,7 +77,7 @@

<b-row no-gutters>
<b-col class="text-center">
<b-button @click="advanceEducateFlowTo(4)" variant="outline-primary" class="my-4">
<b-button @click="advanceEducateFlowTo(4)" variant="primary" class="my-2">
Continue
</b-button>
</b-col>
Expand All @@ -92,8 +92,8 @@
hide-header-close
no-close-on-backdrop
>
<h4 class="text-center mt-4">What if I lose my keys or password?</h4>
<p>
<h4 class="text-center my-4">What if I lose my keys or password?</h4>
<p class="text-justify">
We can not recover your information for you.
If you lose your information, it's GONE FOREVER.
HWW doesn't store any data.
Expand All @@ -104,7 +104,7 @@

<b-row no-gutters>
<b-col class="text-center">
<b-button @click="advanceEducateFlowTo(5)" variant="outline-primary" class="my-4">
<b-button @click="advanceEducateFlowTo(5)" variant="primary" class="my-2">
Continue
</b-button>
</b-col>
Expand All @@ -119,9 +119,9 @@
hide-header-close
no-close-on-backdrop
>
<h4 class="text-center mt-4">Thanks for reading through our introduction!</h4>
<h4 class="text-center my-4">Thanks for reading through our introduction!</h4>
<fa class="success-icon mx-auto d-block my-4" icon="glass-cheers" />
<p>
<p class="text-justify">
Now you're ready to dive in. If you want to know more,
please join our <b-link href="https://discord.gg/xENSXwk">Discord channel</b-link>,
where we are to help you have the most secure and
Expand All @@ -130,7 +130,7 @@

<b-row no-gutters>
<b-col class="text-center">
<b-button @click="advanceEducateFlowTo(0)" variant="outline-success" class="my-4">
<b-button @click="advanceEducateFlowTo(0)" variant="success" class="my-2">
Get Started
</b-button>
</b-col>
Expand All @@ -143,7 +143,13 @@
import { Component, Vue } from 'vue-property-decorator';
@Component
export default class EducateModal extends Vue {
export default class EducateModals extends Vue {
private mounted(): void {
if (!localStorage.getItem('completed_tutorial')) {
this.$bvModal.show('educate-1');
}
}
private advanceEducateFlowTo(to: number): void {
this.$bvModal.hide('educate-1');
this.$bvModal.hide('educate-2');
Expand All @@ -153,9 +159,8 @@ export default class EducateModal extends Vue {
if (to > 0) {
this.$bvModal.show(`educate-${to}`);
} else {
localStorage.setItem('completed_tutorial', JSON.stringify(false));
localStorage.setItem('completed_tutorial', JSON.stringify(true));
}
}
}
</script>
5 changes: 5 additions & 0 deletions src/components/EducateModals/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import EducateModals from './EducateModals.vue';

export {
EducateModals,
};
107 changes: 107 additions & 0 deletions src/components/KeystoreModal/KeystoreModal.vue
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>
5 changes: 5 additions & 0 deletions src/components/KeystoreModal/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import KeystoreModal from './KeystoreModal.vue';

export {
KeystoreModal,
};
9 changes: 9 additions & 0 deletions src/components/MnemonicModals/MnemonicModals.scss
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;
}
}
Loading

0 comments on commit 077aa49

Please sign in to comment.