forked from JSKitty/scc-web3
-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathExportPrivKey.vue
More file actions
91 lines (87 loc) · 2.78 KB
/
ExportPrivKey.vue
File metadata and controls
91 lines (87 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<script setup>
import Modal from '../Modal.vue';
import { ref } from 'vue';
import { translation } from '../i18n.js';
import { downloadBlob } from '../misc';
import pIconExport from '../../assets/icons/icon-export.svg';
const props = defineProps({
privateKey: String,
show: Boolean,
});
const blur = ref(true);
const emit = defineEmits(['close']);
function downloadWalletFile() {
let isJSON = false;
try {
JSON.parse(props.privateKey);
isJSON = true;
} catch {
isJSON = false;
}
downloadBlob(
props.privateKey,
isJSON ? 'wallet.json' : 'wallet.txt',
`${isJSON ? application / json : 'text/plain'};charset=utf-8;`
);
}
function close() {
blur.value = true;
emit('close');
}
</script>
<template>
<Teleport to="body">
<Modal :show="show" modalClass="exportKeysModalColor">
<template #header>
<h5 class="modal-title modal-title-new">
{{ translation.privateKey }}
</h5>
</template>
<template #body>
<div class="dcWallet-privateKeyDiv text-center">
<span class="span2"
>{{ translation.privateWarning1 }}
{{ translation.privateWarning2 }}</span
>
<code
:class="{ blurred: blur }"
data-testid="privateKeyText"
>{{ privateKey }}</code
>
</div>
</template>
<template #footer>
<center>
<button
type="button"
class="pivx-button-big-cancel"
data-testid="closeBtn"
@click="close()"
>
{{ translation.popupClose }}
</button>
<button
class="pivx-button-big"
@click="blur = !blur"
data-testid="blurBtn"
>
<span data-i18n="viewKey" class="buttoni-text"
>{{ translation.viewKey }}
</span>
</button>
<button
class="pivx-button-big"
@click="downloadWalletFile()"
>
<span
data-i18n="saveWalletFile"
class="buttoni-icon"
v-html="pIconExport"
>
</span>
</button>
</center>
</template>
</Modal>
</Teleport>
</template>