Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce lint errors / improve TS support #21

Merged
merged 2 commits into from
Jul 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ module.exports = {
quotes: ['warn', 'single', { avoidEscape: true }],
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/ban-ts-comment': 'off',

// allow debugger during development only
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"typescript.tsdk": "node_modules/typescript/lib",
"vetur.experimental.templateInterpolationService": true,
"vetur.validation.template": false,
"vetur.validation.script": false,
"html.format.enable": true,
"json.format.enable": true,
"javascript.format.enable": true,
Expand Down
15 changes: 15 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
},
"dependencies": {
"@quasar/extras": "^1.0.0",
"@vue/composition-api": "^1.0.0-beta.2",
"bitcore-lib-cash": "^8.20.5",
"bitcore-mnemonic": "^8.20.5",
"browser-passworder": "^2.0.3",
Expand Down
74 changes: 42 additions & 32 deletions src/components/WalletBackupPrompt.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,25 @@
<!-- Prompt user for password to unlock wallet -->
<q-card-section v-if="!isPasswordVerified" class="q-pt-none">
<div class="text-center q-mt-md q-mb-lg">
Your wallet is accessible by a seed. The seed is an ordered 12-word secret phrase.
Your wallet is accessible by a seed phrase. The seed phrase is an ordered 12-word secret
phrase.
<br /><br />
To create a backup of this seed phrase, enter your password below. This will save a file
containting the encrypted contents to your device, and it can be decrypted using the
same password.
</div>
<base-input
v-model="password"
hint="Enter your password to continue"
:icon-append="isPasswordVisible ? 'fas fa-eye-slash' : 'fas fa-eye'"
label="Password"
style="min-width: 250px; max-width: 400px;"
:type="isPasswordVisible ? 'text' : 'password'"
@iconClicked="isPasswordVisible = !isPasswordVisible"
/>
<div class="row justify-center">
<base-input
v-model="password"
class="col"
hint="Enter your password to continue"
:icon-append="isPasswordVisible ? 'fas fa-eye-slash' : 'fas fa-eye'"
label="Password"
style="min-width: 250px; max-width: 400px;"
:type="isPasswordVisible ? 'text' : 'password'"
@iconClicked="isPasswordVisible = !isPasswordVisible"
/>
</div>
</q-card-section>

<div v-else-if="isBackupComplete" class="text-center">
Expand Down Expand Up @@ -99,19 +103,24 @@
<!-- Prompt user for password to unlock wallet -->
<q-card-section v-if="!isPasswordVerified" class="q-pt-none">
<div class="text-center q-mt-md q-mb-lg">
Your wallet is accessible by a seed. The seed is an ordered 12-word secret phrase.
Your wallet is accessible by a seed phrase. The seed phrase is an ordered 12-word secret
phrase.
<br /><br />
Make sure no one is looking, and enter your password to reveal your seed phrase.
Enter your password to reveal your seed phrase. Make sure no one is looking, as anyone
with your seed phrase can access your wallet your funds. Keep it safe!
</div>
<div class="row justify-center">
<base-input
v-model="password"
class="col"
hint="Enter your password to continue"
:icon-append="isPasswordVisible ? 'fas fa-eye-slash' : 'fas fa-eye'"
label="Password"
style="min-width: 250px; max-width: 400px;"
:type="isPasswordVisible ? 'text' : 'password'"
@iconClicked="isPasswordVisible = !isPasswordVisible"
/>
</div>
<base-input
v-model="password"
hint="Enter your password to continue"
:icon-append="isPasswordVisible ? 'fas fa-eye-slash' : 'fas fa-eye'"
label="Password"
style="min-width: 250px; max-width: 400px;"
:type="isPasswordVisible ? 'text' : 'password'"
@iconClicked="isPasswordVisible = !isPasswordVisible"
/>
</q-card-section>

<!-- If user verified password, show them the seed phrase -->
Expand Down Expand Up @@ -208,8 +217,7 @@
<script lang="ts">
import Vue from 'vue';
import { mapState } from 'vuex';
import { StoreInterface } from 'src/store/index';
import { exportFile } from 'quasar';
import { exportFile, LocalStorage } from 'quasar';
import Wallet from 'src/wallet/Wallet';
import helpers from 'src/utils/mixin-helpers';

Expand Down Expand Up @@ -273,8 +281,9 @@ export default Vue.extend({

computed: {
...mapState({
seedPhrase(state: StoreInterface): string {
return state.main.wallet.mnemonic;
seedPhrase(state): string {
// @ts-ignore
return String(state.main.wallet.mnemonic); // eslint-disable-line
},
}),

Expand Down Expand Up @@ -351,11 +360,12 @@ export default Vue.extend({

async checkPassword() {
try {
const encryptedMnemonic = this.$q.localStorage.getItem('kaspa-wallet-data');
await Wallet.import(this.password, encryptedMnemonic);
const encryptedMnemonic = LocalStorage.getItem('kaspa-wallet-data');
await Wallet.import(this.password, encryptedMnemonic); // eslint-disable-line
this.isPasswordVerified = true;
} catch (err) {
this.showError(err);
// @ts-ignore
this.showError(err); // eslint-disable-line
}
},

Expand All @@ -377,19 +387,19 @@ export default Vue.extend({

async saveWalletFile() {
await this.checkPassword();
const encryptedMnemonic = this.$q.localStorage.getItem('kaspa-wallet-data');
const encryptedMnemonic = String(LocalStorage.getItem('kaspa-wallet-data'));
const status = exportFile('kaspa-wallet-data.dag', encryptedMnemonic);
if (!status) {
// browser denied it
this.showError('Browser denied file download');
// @ts-ignore
this.showError('Browser denied file download'); // eslint-disable-line
} else {
this.onVerificationComplete();
}
},

onVerificationComplete() {
this.isBackupComplete = true;
this.$q.localStorage.set('is-backed-up', true);
LocalStorage.set('is-backed-up', true);
},
},
});
Expand Down
12 changes: 8 additions & 4 deletions src/components/WalletBalanceTransactions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
import Vue from 'vue';
import { mapState } from 'vuex';
import TransactionAmount from 'components/TransactionAmount.vue';
import { StoreInterface } from 'src/store/index';
import { partialAddress } from 'src/utils/formatters';
import { Transaction } from '../../types/custom-types';

export default Vue.extend({
name: 'WalletBalanceTransactions',
Expand Down Expand Up @@ -102,18 +102,22 @@ export default Vue.extend({
},

computed: {
/* eslint-disable */
...mapState({
balance(state: StoreInterface) {
balance(state): string {
// @ts-ignore
return state.main.wallet.balance;
},
transactions(state: StoreInterface) {
transactions(state): Array<Transaction> {
// @ts-ignore
return state.main.wallet.transactions;
},
}),
/* eslint-enable */
},

methods: {
partialAddress,
partialAddress, // eslint-disable-line
},
});
</script>
8 changes: 5 additions & 3 deletions src/pages/WalletBalance.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<q-page padding class="page-margin">
<!-- Wallet backup prompt -->
<wallet-backup-prompt @backupComplete="getBackupStatus" v-if="!isBackedUp" />
<wallet-backup-prompt v-if="!isBackedUp" @backupComplete="getBackupStatus" />
<!-- Wallet balance -->
<div class="text-primary text-center">
<transaction-amount :amount="balance" :is-balance="true" />
Expand All @@ -17,7 +17,6 @@
<script lang="ts">
import Vue from 'vue';
import { mapState } from 'vuex';
import { StoreInterface } from 'src/store/index';
import TransactionAmount from 'components/TransactionAmount.vue';
import WalletBalanceTransactions from 'components/WalletBalanceTransactions.vue';

Expand All @@ -36,11 +35,14 @@ export default Vue.extend({
},

computed: {
/* eslint-disable */
...mapState({
balance(state: StoreInterface) {
balance(state) {
// @ts-ignore
return state.main.wallet.balance || '0';
},
}),
/* eslint-enable */
},

mounted() {
Expand Down
7 changes: 4 additions & 3 deletions src/pages/WalletCreate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,16 @@ export default Vue.extend({
async handleCreate() {
try {
this.isLoading = true;
const wallet = new Wallet();
const encryptedMnemonic = await wallet.export(this.password1);
const wallet = new Wallet(); // eslint-disable-line
const encryptedMnemonic = await wallet.export(this.password1); // eslint-disable-line
this.$q.localStorage.set('kaspa-wallet-data', encryptedMnemonic);
this.$q.localStorage.set('is-backed-up', false);
await this.$store.dispatch('main/getWalletInfo', wallet);
await this.$router.push({ name: 'walletBalance' });
} catch (err) {
this.isLoading = false;
this.showError(err);
// @ts-ignore
this.showError(err); // eslint-disable-line
}
},

Expand Down
6 changes: 4 additions & 2 deletions src/pages/WalletHandler.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

<script lang="ts">
import Vue from 'vue';
import { StoreInterface } from 'src/store/index';
import { mapState } from 'vuex';
import WalletCreate from 'pages/WalletCreate.vue';
import WalletOpen from 'pages/WalletOpen.vue';
Expand All @@ -18,11 +17,14 @@ export default Vue.extend({
},

computed: {
/* eslint-disable */
...mapState({
hasWallet(state: StoreInterface) {
hasWallet(state) {
// @ts-ignore
return state.main.hasWallet;
},
}),
/* eslint-enable */

pageToShow() {
return this.hasWallet ? 'WalletOpen' : 'WalletCreate';
Expand Down
5 changes: 3 additions & 2 deletions src/pages/WalletOpen.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@ export default Vue.extend({
try {
this.isLoading = true;
const encryptedMnemonic = this.$q.localStorage.getItem('kaspa-wallet-data');
const wallet = await Wallet.import(this.password, encryptedMnemonic);
const wallet = await Wallet.import(this.password, encryptedMnemonic); // eslint-disable-line
await this.$store.dispatch('main/getWalletInfo', wallet);
await this.$router.push({ name: 'walletBalance' });
} catch (err) {
this.isLoading = false;
this.showError(err);
// @ts-ignore
this.showError(err); // eslint-disable-line
}
},
},
Expand Down
7 changes: 5 additions & 2 deletions src/pages/WalletReceive.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<script lang="ts">
import Vue from 'vue';
import { mapState } from 'vuex';
import { StoreInterface } from 'src/store/index';
import { copyToClipboard } from 'quasar';
import helpers from 'src/utils/mixin-helpers';

Expand All @@ -25,18 +24,22 @@ export default Vue.extend({
mixins: [helpers],

computed: {
/* eslint-disable */
...mapState({
address(state: StoreInterface): string {
address(state): string {
// @ts-ignore
return state.main.wallet.address;
},
}),
/* eslint-enable */
},

methods: {
copyToClipboard,

async copyAddressToClipboard() {
await this.copyToClipboard(this.address);
// @ts-ignore
this.notifyUser('positive', 'Address has been copied to the clipboard'); // eslint-disable-line
},
},
Expand Down
Loading