Skip to content

Commit 923f663

Browse files
committed
fix(cross-chain): delay Across status failures
Increase 10 mins Timeout 2 hours
1 parent 05acb74 commit 923f663

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

apps/kyberswap-interface/src/pages/CrossChainSwap/adapters/AcrossAdapter/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ export class AcrossAdapter extends BaseSwapAdapter {
265265

266266
return {
267267
txHash: getAcrossFillTxHash(res),
268-
status: mapAcrossDepositStatus(res),
268+
status: mapAcrossDepositStatus(res, { txTimestamp: params.timestamp }),
269269
}
270270
} catch (error) {
271271
console.error('Error fetching transaction status:', error)

apps/kyberswap-interface/src/pages/CrossChainSwap/adapters/AcrossAdapter/utils.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,29 @@
11
import { AcrossDepositStatusResponse } from 'pages/CrossChainSwap/adapters/AcrossAdapter/types'
22
import { SwapStatus } from 'pages/CrossChainSwap/adapters/BaseSwapAdapter'
33

4+
const ACROSS_STATUS_ERROR_GRACE_PERIOD = 2 * 60 * 60 * 1_000
5+
6+
interface AcrossDepositStatusOptions {
7+
txTimestamp?: number
8+
now?: number
9+
}
10+
411
export const getAcrossFillTxHash = (statusResponse: AcrossDepositStatusResponse): string => {
512
return statusResponse.fillTxnRef || statusResponse.fillTx || ''
613
}
714

8-
export const mapAcrossDepositStatus = (statusResponse: AcrossDepositStatusResponse): SwapStatus['status'] => {
15+
export const mapAcrossDepositStatus = (
16+
statusResponse: AcrossDepositStatusResponse,
17+
options: AcrossDepositStatusOptions = {},
18+
): SwapStatus['status'] => {
919
if (statusResponse.error) {
20+
const { txTimestamp, now = Date.now() } = options
21+
const isWithinIndexingGracePeriod = txTimestamp ? now - txTimestamp < ACROSS_STATUS_ERROR_GRACE_PERIOD : false
22+
23+
if (isWithinIndexingGracePeriod) {
24+
return 'Processing'
25+
}
26+
1027
return 'Failed'
1128
}
1229

apps/kyberswap-interface/src/pages/CrossChainSwap/adapters/KyberAcrossAdapter/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ export class KyberAcrossAdapter extends BaseSwapAdapter {
217217

218218
return {
219219
txHash: getAcrossFillTxHash(res),
220-
status: mapAcrossDepositStatus(res),
220+
status: mapAcrossDepositStatus(res, { txTimestamp: params.timestamp }),
221221
}
222222
} catch (error) {
223223
console.error('Error fetching transaction status:', error)

0 commit comments

Comments
 (0)