-
Notifications
You must be signed in to change notification settings - Fork 4
/
ConfirmTransaction.vue
80 lines (68 loc) · 1.96 KB
/
ConfirmTransaction.vue
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
<template>
<div class="dialog-step">
<div class="dialog-step__header">
<p-button
v-if="timeout"
class="dialog-step__button ml-auto"
icon="pi pi-times"
@click="onClose"
/>
</div>
<div class="dialog-step__content">
<div class="confirmation">
<ProgressSpinner
fill="#16162D"
stroke-width="2px"
:style="{ width: '60px', height: '60px' }"
/>
<h3 class="confirmation__title">Waiting For Confirmation</h3>
<slot name="description" v-bind="{ description }">
<p v-if="description" class="confirmation__description">
{{ description }}
</p>
</slot>
<p class="confirmation__help">
Confirm this transaction in your wallet
</p>
</div>
</div>
<div v-if="timeout" class="dialog-step__footer">
<p-button class="justify-content-center w-full" @click="onClose">
Close
</p-button>
</div>
</div>
</template>
<script setup lang="ts">
import { computed, onMounted, watch } from 'vue';
import { AptosCreateTx } from '@/types/aptosResources';
import { useSendTransaction } from '@/composables/useSendTransaction';
import { useTimeout } from '@vueuse/core';
import ProgressSpinner from 'primevue/progressspinner';
import PButton from "primevue/button";
interface IProps {
tx: AptosCreateTx;
description?: string;
}
const props = defineProps<IProps>();
const emits = defineEmits(['rejected', 'submitted', 'close']);
const { state, error, execute } = useSendTransaction();
const timeout = useTimeout(30000, { immediate: true });
const tx = computed(() => {
return props.tx;
});
const description = computed(() => {
return props.description;
});
onMounted(() => execute(tx));
watch(error, () => {
emits('rejected', error.value);
});
watch(state, () => {
emits('submitted', state.value);
});
function onClose() {
emits('rejected', 'Time out');
emits('close');
}
</script>