12
12
:inconsistent-status =" inconsistentStatus"
13
13
:adm-tx =" admTx"
14
14
:crypto =" crypto"
15
+ :feeCrypto =" AllCryptos.ETH"
15
16
@refetch-status =" refetch"
16
17
/>
17
18
</template >
18
19
19
- <script lang="ts">
20
- import { computed , defineComponent , PropType } from ' vue'
20
+ <script lang="ts" setup >
21
+ import { computed , PropType } from ' vue'
21
22
import { useStore } from ' vuex'
22
23
import TransactionTemplate from ' ./TransactionTemplate.vue'
23
24
import { getExplorerTxUrl } from ' @/config/utils'
@@ -32,93 +33,66 @@ import { useErc20TransactionQuery } from '@/hooks/queries/transaction'
32
33
import { useClearPendingTransaction } from ' ./hooks/useClearPendingTransaction'
33
34
import { getPartnerAddress } from ' ./utils/getPartnerAddress'
34
35
35
- export default defineComponent ({
36
- name: ' Erc20Transaction ' ,
37
- components: {
38
- TransactionTemplate
36
+ const props = defineProps ({
37
+ crypto: {
38
+ required: true ,
39
+ type: String as PropType < CryptoSymbol >
39
40
},
40
- props: {
41
- crypto: {
42
- required: true ,
43
- type: String as PropType <CryptoSymbol >
44
- },
45
- id: {
46
- required: true ,
47
- type: String
48
- }
49
- },
50
- setup(props ) {
51
- const store = useStore ()
52
-
53
- const cryptoAddress = computed (() => store .state .eth .address )
41
+ id: {
42
+ required: true ,
43
+ type: String
44
+ }
45
+ })
54
46
55
- const {
56
- status : queryStatus,
57
- isFetching,
58
- data : transaction,
59
- refetch
60
- } = useErc20TransactionQuery (props .crypto )(props .id )
61
- const inconsistentStatus = useInconsistentStatus (transaction , props .crypto )
62
- const transactionStatus = useTransactionStatus (isFetching , queryStatus , inconsistentStatus )
63
- useClearPendingTransaction (props .crypto , transaction )
47
+ const store = useStore ()
64
48
65
- const admTx = useFindAdmTransaction (props .id )
66
- const senderAdmAddress = computed (() => admTx .value ?.senderId || ' ' )
67
- const recipientAdmAddress = computed (() => admTx .value ?.recipientId || ' ' )
68
- const partnerAdmAddress = computed (() =>
69
- admTx .value
70
- ? getPartnerAddress (admTx .value ?.senderId , admTx .value ?.recipientId , cryptoAddress .value )
71
- : ' '
72
- )
49
+ const cryptoAddress = computed (() => store .state .eth .address )
73
50
74
- const senderFormatted = useCryptoAddressPretty (
75
- transaction ,
76
- cryptoAddress ,
77
- senderAdmAddress ,
78
- ' sender'
79
- )
80
- const recipientFormatted = useCryptoAddressPretty (
81
- transaction ,
82
- cryptoAddress ,
83
- recipientAdmAddress ,
84
- ' recipient'
85
- )
51
+ const {
52
+ status : queryStatus,
53
+ isFetching,
54
+ data : transaction,
55
+ refetch
56
+ } = useErc20TransactionQuery (props .crypto )(props .id )
57
+ const inconsistentStatus = useInconsistentStatus (transaction , props .crypto )
58
+ const transactionStatus = useTransactionStatus (isFetching , queryStatus , inconsistentStatus )
59
+ useClearPendingTransaction (props .crypto , transaction )
86
60
87
- const explorerLink = computed (() => getExplorerTxUrl (Cryptos .ETH , props .id ))
88
- const blockHeight = useBlockHeight (' ETH' , {
89
- enabled : () => transactionStatus .value === ' CONFIRMED'
90
- })
91
- const confirmations = computed (() => {
92
- if (! blockHeight .value || ! transaction .value ) return NaN
61
+ const admTx = useFindAdmTransaction (props .id )
62
+ const senderAdmAddress = computed (() => admTx .value ?.senderId || ' ' )
63
+ const recipientAdmAddress = computed (() => admTx .value ?.recipientId || ' ' )
64
+ const partnerAdmAddress = computed (() =>
65
+ admTx .value
66
+ ? getPartnerAddress (admTx .value ?.senderId , admTx .value ?.recipientId , cryptoAddress .value )
67
+ : ' '
68
+ )
93
69
94
- if (' blockNumber' in transaction .value && transaction .value .blockNumber ) {
95
- return blockHeight .value - transaction .value .blockNumber + 1
96
- }
70
+ const senderFormatted = useCryptoAddressPretty (
71
+ transaction ,
72
+ cryptoAddress ,
73
+ senderAdmAddress ,
74
+ ' sender'
75
+ )
76
+ const recipientFormatted = useCryptoAddressPretty (
77
+ transaction ,
78
+ cryptoAddress ,
79
+ recipientAdmAddress ,
80
+ ' recipient'
81
+ )
97
82
98
- return transaction .value ?.confirmations
99
- })
100
- const fee = computed (() => {
101
- const ethFee = transaction .value ?.fee || 0
102
- const currentCurrency = store .state .options .currentRate
103
- const currentRate = store .state .rate .rates [` ${AllCryptos .ETH }/${currentCurrency } ` ]
104
- const feeRate = (ethFee * currentRate ).toFixed (2 )
105
- return + feeRate
106
- })
83
+ const explorerLink = computed (() => getExplorerTxUrl (Cryptos .ETH , props .id ))
84
+ const blockHeight = useBlockHeight (' ETH' , {
85
+ enabled : () => transactionStatus .value === ' CONFIRMED'
86
+ })
87
+ const confirmations = computed (() => {
88
+ if (! blockHeight .value || ! transaction .value ) return NaN
107
89
108
- return {
109
- refetch ,
110
- transaction ,
111
- fee ,
112
- senderFormatted ,
113
- recipientFormatted ,
114
- partnerAdmAddress ,
115
- explorerLink ,
116
- confirmations ,
117
- admTx ,
118
- queryStatus ,
119
- transactionStatus ,
120
- inconsistentStatus
121
- }
90
+ if (' blockNumber' in transaction .value && transaction .value .blockNumber ) {
91
+ return blockHeight .value - transaction .value .blockNumber + 1
122
92
}
93
+
94
+ return transaction .value ?.confirmations
123
95
})
96
+
97
+ const fee = computed (() => transaction .value ?.fee )
124
98
</script >
0 commit comments