Skip to content

Commit

Permalink
fix: gas.zip refund tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiTimesChi committed Feb 26, 2025
1 parent 061ee1f commit 2b71f07
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ export const _Transaction = ({
destinationChain?.id,
destinationAddress ?? connectedAddress
)

const {
// TODO: this could be cleaned up
let {
remainingTime,
delayedTime,
delayedTimeInMin,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 2b71f07

Please sign in to comment.