diff --git a/src/components/transactions/hooks/useTransactionStatus.ts b/src/components/transactions/hooks/useTransactionStatus.ts index ca9be0e74..c3207a02c 100644 --- a/src/components/transactions/hooks/useTransactionStatus.ts +++ b/src/components/transactions/hooks/useTransactionStatus.ts @@ -12,7 +12,7 @@ export function useTransactionStatus( if (isFetching.value) return TransactionStatus.PENDING if (queryStatus.value === 'error') return TransactionStatus.REJECTED if (queryStatus.value === 'success') { - if (inconsistentStatus?.value) return TransactionStatus.UNKNOWN + if (inconsistentStatus?.value) return TransactionStatus.INVALID return TransactionStatus.CONFIRMED } diff --git a/src/hooks/queries/transaction/useTransactionStatusQuery.ts b/src/hooks/queries/transaction/useTransactionStatusQuery.ts index 06bcf53b5..9be944cce 100644 --- a/src/hooks/queries/transaction/useTransactionStatusQuery.ts +++ b/src/hooks/queries/transaction/useTransactionStatusQuery.ts @@ -1,6 +1,7 @@ -import { computed, MaybeRef, unref } from 'vue' +import { MaybeRef, unref } from 'vue' import { useInconsistentStatus } from '@/components/transactions/hooks/useInconsistentStatus' -import { CryptoSymbol, TransactionStatus, TransactionStatusType } from '@/lib/constants' +import { useTransactionStatus } from '@/components/transactions/hooks/useTransactionStatus' +import { CryptoSymbol } from '@/lib/constants' import { useTransactionQuery } from './useTransactionQuery' export function useTransactionStatusQuery( @@ -8,27 +9,16 @@ export function useTransactionStatusQuery( crypto: MaybeRef ) { const { - status: fetchStatus, + status: queryStatus, isFetching, data: transaction, refetch } = useTransactionQuery(transactionId, unref(crypto)) const inconsistentStatus = useInconsistentStatus(transaction, unref(crypto)) - - const status = computed(() => { - if (isFetching.value) return TransactionStatus.PENDING - if (fetchStatus.value === 'error') return TransactionStatus.REJECTED - if (fetchStatus.value === 'success') { - if (inconsistentStatus.value) return TransactionStatus.UNKNOWN - - return TransactionStatus.CONFIRMED - } - - return TransactionStatus.UNKNOWN - }) + const status = useTransactionStatus(isFetching, queryStatus, inconsistentStatus) return { - fetchStatus, + queryStatus, inconsistentStatus, status, refetch diff --git a/src/providers/TransactionProvider.vue b/src/providers/TransactionProvider.vue index 93b72accf..55292ff61 100644 --- a/src/providers/TransactionProvider.vue +++ b/src/providers/TransactionProvider.vue @@ -1,7 +1,7 @@