Skip to content

Commit

Permalink
add executed withdrawals to cache
Browse files Browse the repository at this point in the history
  • Loading branch information
brtkx committed Dec 12, 2024
1 parent 90f3aa4 commit 26cabfe
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions packages/arb-token-bridge-ui/src/util/withdrawals/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand Down

0 comments on commit 26cabfe

Please sign in to comment.