From 2b71f07eb5a8b2fbad51b6f563f559a48e08b6de Mon Sep 17 00:00:00 2001 From: ChiTimesChi <88190723+ChiTimesChi@users.noreply.github.com> Date: Wed, 26 Feb 2025 21:14:47 +0000 Subject: [PATCH] fix: gas.zip refund tracking --- .../components/_Transaction/_Transaction.tsx | 7 ++++-- .../_Transaction/helpers/useTxRefundStatus.ts | 23 +++++++++++-------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/packages/synapse-interface/components/_Transaction/_Transaction.tsx b/packages/synapse-interface/components/_Transaction/_Transaction.tsx index 965567b934..ef964ef6ea 100644 --- a/packages/synapse-interface/components/_Transaction/_Transaction.tsx +++ b/packages/synapse-interface/components/_Transaction/_Transaction.tsx @@ -76,8 +76,8 @@ export const _Transaction = ({ destinationChain?.id, destinationAddress ?? connectedAddress ) - - const { + // TODO: this could be cleaned up + let { remainingTime, delayedTime, delayedTimeInMin, @@ -86,6 +86,9 @@ export const _Transaction = ({ isCheckTxForRevert, isCheckTxForRefund, } = calculateEstimatedTimeStatus(currentTime, timestamp, estimatedTime) + if (bridgeModuleName === 'Gas.zip') { + isCheckTxForRefund = isEstimatedTimeReached + } const [isTxCompleted, _kappa] = useBridgeTxStatus({ originChainId: originChain?.id, diff --git a/packages/synapse-interface/components/_Transaction/helpers/useTxRefundStatus.ts b/packages/synapse-interface/components/_Transaction/helpers/useTxRefundStatus.ts index 0e86f2bc92..18255aed19 100644 --- a/packages/synapse-interface/components/_Transaction/helpers/useTxRefundStatus.ts +++ b/packages/synapse-interface/components/_Transaction/helpers/useTxRefundStatus.ts @@ -21,6 +21,7 @@ enum GasZipStatus { CONFIRMED = 'CONFIRMED', // user received funds on dst chain CANCELLED = 'CANCELLED', // tx will not be processed, user hasn't received their origin funds back yet REFUNDED = 'REFUNDED', // user received funds back on origin chain after tx was cancelled + OTHER = 'OTHER', // other status } const GAS_ZIP_API_URL = 'https://backend.gas.zip/v2/deposit' @@ -129,16 +130,20 @@ const checkGasZipTxStatus = async ( if (!data.txs || !data.txs.length) { return undefined } - switch (data.txs[0].status) { - case GasZipStatus.CONFIRMED: - return GasZipStatus.CONFIRMED - case GasZipStatus.CANCELLED: { - // Check if there is a CONFIRMED tx in the list - this would be the refund tx - return data.txs.find((tx) => tx.status === GasZipStatus.CONFIRMED) - ? GasZipStatus.REFUNDED - : GasZipStatus.CANCELLED - } + console.log({ txId, data }) + if (data.txs[0].status === GasZipStatus.CONFIRMED) { + return GasZipStatus.CONFIRMED + } + if ( + data.txs[0].status === GasZipStatus.CANCELLED || + data.txs[0].cancelled + ) { + // Check if there is a refun tx in the list + return data.txs.find((tx) => tx.refund) + ? GasZipStatus.REFUNDED + : GasZipStatus.CANCELLED } + return GasZipStatus.OTHER } catch (error) { throw new Error(error) }