From 6d0655aab2d43b34bb603771c7d066160ee10c75 Mon Sep 17 00:00:00 2001 From: Caio Costa Date: Sun, 2 Feb 2025 19:16:36 -0300 Subject: [PATCH] fix: Don't show swaps as 'refundable' when there was no lockup tx --- src/pages/Refund.tsx | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/pages/Refund.tsx b/src/pages/Refund.tsx index e2008f88..dd48070d 100644 --- a/src/pages/Refund.tsx +++ b/src/pages/Refund.tsx @@ -27,17 +27,17 @@ const Refund = () => { setRefundableSwaps(refundableSwaps().concat(swap)); }; - const swapsToRefund = (await getSwaps()) + const allSwaps = await getSwaps(); + + const swapsToRefund = allSwaps .filter(refundSwapsSanityFilter) - .filter((swap) => - [ - swapStatusFailed.InvoiceFailedToPay, - swapStatusFailed.TransactionLockupFailed, - ].includes(swap.status), + .filter( + (swap) => + swapStatusFailed.TransactionLockupFailed === swap.status, ); setRefundableSwaps(swapsToRefund); - void (await getSwaps()) + void allSwaps .filter(refundSwapsSanityFilter) .filter( (swap) => @@ -53,12 +53,7 @@ const Refund = () => { !(await updateSwapStatus(swap.id, res.status)) && Object.values(swapStatusFailed).includes(res.status) ) { - if (res.status !== swapStatusFailed.SwapExpired) { - addToRefundableSwaps(swap); - return; - } - - // Make sure coins were locked for the swap with the status "swap.expired" + // Make sure coins were locked for the swaps with status "swap.expired" or "swap.failedToPay" await getLockupTransaction(swap.id, swap.type); addToRefundableSwaps(swap); }