Skip to content

Commit

Permalink
fix: Hide Expired status in tx history
Browse files Browse the repository at this point in the history
  • Loading branch information
usame-algan authored and compojoom committed May 6, 2024
1 parent 4ed007f commit 3d90599
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/components/transactions/TxDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const TxDetailsBlock = ({ txSummary, txDetails }: TxDetailsProps): ReactElement
</Box>
)}

{expiredSwap && (
{isQueue && expiredSwap && (
<Typography color="text.secondary" mt={2}>
This order has expired. Reject this transaction and try again.
</Typography>
Expand Down
2 changes: 1 addition & 1 deletion src/components/transactions/TxSummary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const TxSummary = ({ item, isGrouped }: TxSummaryProps): ReactElement => {
</Box>
)}

{expiredSwap && (
{isQueue && expiredSwap && (
<Box gridArea="status" justifyContent="flex-end" display="flex" className={css.status}>
<StatusLabel status="expired" />
</Box>
Expand Down
4 changes: 2 additions & 2 deletions src/features/swap/hooks/useIsExpiredSwap.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState } from 'react'
import type { TransactionInfo } from '@safe-global/safe-gateway-typescript-sdk'
import useInterval from '@/hooks/useInterval'
import { isExpiredSwap as isSwapInfoExpired, isSwapTxInfo } from '@/utils/transaction-guards'
import { isSwapTxInfo } from '@/utils/transaction-guards'

const INTERVAL_IN_MS = 10_000

Expand All @@ -16,7 +16,7 @@ const useIsExpiredSwap = (txInfo: TransactionInfo) => {
const isExpiredSwap = () => {
if (!isSwapTxInfo(txInfo)) return

setIsExpired(Date.now() > txInfo.validUntil * 1000 && isSwapInfoExpired(txInfo))
setIsExpired(Date.now() > txInfo.validUntil * 1000)
}

useInterval(isExpiredSwap, INTERVAL_IN_MS)
Expand Down
4 changes: 0 additions & 4 deletions src/utils/transaction-guards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,6 @@ export const isSwapConfirmationViewOrder = (
return false
}

export const isExpiredSwap = (value: TransactionInfo) => {
return isSwapTxInfo(value) && value.status === 'expired'
}

export const isCancelledSwap = (value: TransactionInfo) => {
return isSwapTxInfo(value) && value.status === 'cancelled'
}
Expand Down

0 comments on commit 3d90599

Please sign in to comment.