Skip to content

fix(explorer): tolerate per-token metadata failures on block page#1105

Open
web3jacker wants to merge 1 commit into
tempoxyz:mainfrom
web3jacker:fix/block-known-events-resilience
Open

fix(explorer): tolerate per-token metadata failures on block page#1105
web3jacker wants to merge 1 commit into
tempoxyz:mainfrom
web3jacker:fix/block-known-events-resilience

Conversation

@web3jacker

Copy link
Copy Markdown

🩹 One bad token shouldn't blank out a whole block's events

Hey! Small but annoying one here.

On the block page we collect every TIP-20 address that shows up in the
receipts, then fetch metadata for all of them at once:

const metadataResults = await Promise.all(
  tip20Array.map((token) => client.token.getMetadata({ token })),
)

Problem: Promise.all is all-or-nothing. If one token doesn't conform to the
TIP-20 metadata interface, or the RPC just hiccups on a single call, the whole
thing rejects — and blockKnownEventsQueryOptions fails with it. So a single
weird token means none of the transactions on that block get their
known-events rendered. 😬

The funny thing is the receipts fetch right above it already does the right
thing with .catch(() => null), and the loop that consumes the metadata
already null-checks each entry. So this was just an inconsistency.

The fix is to make the metadata fetch match:

tip20Array.map((token) => client.token.getMetadata({ token }).catch(() => null))

Now a flaky/non-conforming token just doesn't get decorated metadata, and
everything else on the block renders fine. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant