Skip to content

Commit

Permalink
Check receipt existance before getting status
Browse files Browse the repository at this point in the history
  • Loading branch information
gndelia committed Jan 21, 2025
1 parent 25bc36f commit ece997a
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion webapp/workers/watchEvmWithdrawals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,23 @@ const watchWithdrawal = (withdrawal: ToEvmWithdrawOperation) =>

const crossChainMessenger = await getCrossChainMessenger(l1Chain, l2Chain)
debug('Checking withdrawal %s', withdrawal.transactionHash)

const updates: Partial<ToEvmWithdrawOperation> = {}

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,
Expand All @@ -146,7 +163,7 @@ const watchWithdrawal = (withdrawal: ToEvmWithdrawOperation) =>
getBlockTimestamp(withdrawal),
),
])
const updates: Partial<ToEvmWithdrawOperation> = {}

if (withdrawal.status !== status) {
debug(
'Withdrawal %s status changed from %s to %s',
Expand Down

0 comments on commit ece997a

Please sign in to comment.