Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(explorer): show transactions #3062

Merged
merged 57 commits into from
Oct 3, 2024
Merged

feat(explorer): show transactions #3062

merged 57 commits into from
Oct 3, 2024

Conversation

karooolis
Copy link
Contributor

@karooolis karooolis commented Aug 26, 2024

CleanShot 2024-10-03 at 16 05 09

Copy link

changeset-bot bot commented Aug 26, 2024

🦋 Changeset detected

Latest commit: 0e929d2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 26 packages
Name Type
@latticexyz/explorer Patch
@latticexyz/abi-ts Patch
@latticexyz/block-logs-stream Patch
@latticexyz/cli Patch
@latticexyz/common Patch
@latticexyz/config Patch
create-mud Patch
@latticexyz/dev-tools Patch
@latticexyz/faucet Patch
@latticexyz/gas-report Patch
@latticexyz/protocol-parser Patch
@latticexyz/react Patch
@latticexyz/recs Patch
@latticexyz/schema-type Patch
solhint-config-mud Patch
solhint-plugin-mud Patch
@latticexyz/stash Patch
@latticexyz/store-indexer Patch
@latticexyz/store-sync Patch
@latticexyz/store Patch
@latticexyz/utils Patch
@latticexyz/world-module-metadata Patch
@latticexyz/world-modules Patch
@latticexyz/world Patch
mock-game-contracts Patch
ts-benchmarks Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Sep 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
explorer ❌ Failed (Inspect) Sep 30, 2024 4:51pm

return Array.from(mergedMap.values()).reverse();
}, [transactions, observerWrites]);

async function handleTransaction(hash: Hex, timestamp: bigint) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, feels weird that we're not writing to the transaction list until after all the things below resolve (getting tx, getting receipt, simulating result

wouldn't we want to render it right away, then enrich it with data as it comes in?

could we do this all inline with individual components rather than in a big handler like this? or does that impact the resulting order?

Copy link
Contributor Author

@karooolis karooolis Oct 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, did it like that initially for simplicity reasons but definitely better to update state as soon as it's available, will change.

As for individual components, I explored that approach but it didn't quite work due to how tanstack table works. It expects all the data to be passed to the useReactTable beforehand, and then provides utilities for rendering rows and cells. We could do without the tanstack table ofc but wanted to use it in case we need table functionalities like filter, sorting, and such. Of course, all of that can be achieved custom. Also, as you noted, there would be other considerations when it comes to sorting that would be need handling, mainly seems like handling incoming txs from observer would need more thought where tx hash is not immediately available.

Anyhow, to improve the situation regarding the size of handleTransaction separated TransactionTable into TransactionTableContainer to handle all the logic, and TransactionTableView for display.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OOC do we need two components? seems like we could do one component and one hook? since most of the logic in TransactionTableContainer is now hook-like and we only wrap it in a component to render TransactionTableView

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah good suggestion. I couldn't figure out at first why using the hook way caused infinite re-renders but now figured out the culprit was const observerWrites = useStore(store, (state) => Object.values(state.writes)) which then messed with useMemo due to being a new object every time. Switching to const observerWrites = useStore(store, (state) => state.writes did the trick.

karooolis and others added 4 commits October 2, 2024 13:42
…Address]/observe/BlockExplorerLink.tsx

Co-authored-by: Kevin Ingersoll <[email protected]>
…Address]/observe/TimeAgoCell.tsx

Co-authored-by: Kevin Ingersoll <[email protected]>
…Address]/observe/BlockExplorerLink.tsx

Co-authored-by: Kevin Ingersoll <[email protected]>
holic
holic previously approved these changes Oct 3, 2024
Copy link
Member

@holic holic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no action needed on the spacing comment, just a note as we continue to build out and refine pages

prob worth moving the TransactionTableContainer logic into a hook then use it in TransactionsTableView (which could prob get back to being TransactionsTable)

otherwise lgtm!

if (attempt < maxRetries - 1) {
await new Promise((resolve) => setTimeout(resolve, retryInterval));
}
}
Copy link
Member

@holic holic Oct 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is basically what viem's waitForTransactionReceipt does, but with caching/batching - can we use that here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh so nice!!! great suggestion, changed

@karooolis karooolis merged commit bbd5e31 into main Oct 3, 2024
12 of 13 checks passed
@karooolis karooolis deleted the kumpis/show-transactions branch October 3, 2024 12:27
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.

2 participants