From ece997a89b58a6662948f908cac1b7d347fe00ca Mon Sep 17 00:00:00 2001 From: Gonzalo D'elia Date: Tue, 21 Jan 2025 11:11:30 -0300 Subject: [PATCH] Check receipt existance before getting status --- webapp/workers/watchEvmWithdrawals.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/webapp/workers/watchEvmWithdrawals.ts b/webapp/workers/watchEvmWithdrawals.ts index 7d3cfb17..6294049e 100644 --- a/webapp/workers/watchEvmWithdrawals.ts +++ b/webapp/workers/watchEvmWithdrawals.ts @@ -135,6 +135,23 @@ const watchWithdrawal = (withdrawal: ToEvmWithdrawOperation) => const crossChainMessenger = await getCrossChainMessenger(l1Chain, l2Chain) debug('Checking withdrawal %s', withdrawal.transactionHash) + + const updates: Partial = {} + + const receipt = await getEvmTransactionReceipt( + withdrawal.transactionHash, + withdrawal.l2ChainId, + ) + + if (!receipt) { + debug('Withdrawal %s is not confirmed yet', withdrawal.transactionHash) + worker.postMessage({ + type: getUpdateWithdrawalKey(withdrawal), + updates, + }) + return + } + const [status, [blockNumber, timestamp]] = await Promise.all([ crossChainMessenger.getMessageStatus( withdrawal.transactionHash, @@ -146,7 +163,7 @@ const watchWithdrawal = (withdrawal: ToEvmWithdrawOperation) => getBlockTimestamp(withdrawal), ), ]) - const updates: Partial = {} + if (withdrawal.status !== status) { debug( 'Withdrawal %s status changed from %s to %s',