From 26cabfe3866dfbb36da18f54fb4b8497fe1f609e Mon Sep 17 00:00:00 2001 From: Bartek Date: Thu, 12 Dec 2024 14:51:31 +0100 Subject: [PATCH] add executed withdrawals to cache --- .../src/util/withdrawals/helpers.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/arb-token-bridge-ui/src/util/withdrawals/helpers.ts b/packages/arb-token-bridge-ui/src/util/withdrawals/helpers.ts index 89ab0369be..1cf448edfa 100644 --- a/packages/arb-token-bridge-ui/src/util/withdrawals/helpers.ts +++ b/packages/arb-token-bridge-ui/src/util/withdrawals/helpers.ts @@ -107,13 +107,15 @@ export async function getOutgoingMessageState( l2Provider: Provider, l2ChainID: number ) { + const executedMessagesCacheKey = 'arbitrum:bridge:executed-messages' + const cacheKey = getExecutedMessagesCacheKey({ event, l2ChainId: l2ChainID }) const executedMessagesCache = JSON.parse( - localStorage.getItem('arbitrum:bridge:executed-messages') || '{}' + localStorage.getItem(executedMessagesCacheKey) || '{}' ) if (executedMessagesCache[cacheKey]) { return OutgoingMessageState.EXECUTED @@ -122,7 +124,19 @@ export async function getOutgoingMessageState( const messageReader = new ChildToParentMessageReader(l1Provider, event) try { - return await messageReader.status(l2Provider) + const status = await messageReader.status(l2Provider) + + if (status === OutgoingMessageState.EXECUTED) { + localStorage.setItem( + executedMessagesCacheKey, + JSON.stringify({ + ...executedMessagesCache, + [cacheKey]: true + }) + ) + } + + return status } catch (error) { return OutgoingMessageState.UNCONFIRMED }