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: Add NavArrows component #479

Merged
merged 12 commits into from
Sep 4, 2024
Merged

feat: Add NavArrows component #479

merged 12 commits into from
Sep 4, 2024

Conversation

luis-herasme
Copy link
Member

Checklist

  • My change requires a documentation update, and I have done it.
  • I have added tests to cover my changes.
  • I have filled out the description and linked the related issues.

Description

Add NavArrows component

Related Issue (Optional)

#471
Closes #472

Screenshots (if appropriate):

image
image

@luis-herasme luis-herasme requested a review from PJColombo August 3, 2024 04:46
Copy link

changeset-bot bot commented Aug 3, 2024

🦋 Changeset detected

Latest commit: af00b62

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

This PR includes changesets to release 1 package
Name Type
@blobscan/web Minor

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 Aug 3, 2024

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

Name Status Preview Comments Updated (UTC)
blobscan-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 4, 2024 4:50pm
blobscan-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 4, 2024 4:50pm
4 Skipped Deployments
Name Status Preview Comments Updated (UTC)
blobscan-gnosis ⬜️ Ignored (Inspect) Visit Preview Sep 4, 2024 4:50pm
blobscan-holesky ⬜️ Ignored (Inspect) Visit Preview Sep 4, 2024 4:50pm
blobscan-mainnet ⬜️ Ignored (Inspect) Visit Preview Sep 4, 2024 4:50pm
blobscan-sepolia ⬜️ Ignored (Inspect) Visit Preview Sep 4, 2024 4:50pm

Copy link
Contributor

github-actions bot commented Aug 3, 2024

📦 Next.js Bundle Analysis for @blobscan/web

This analysis was generated by the Next.js Bundle Analysis action. 🤖

⚠️ Global Bundle Size Increased

Page Size (compressed)
global 275.44 KB (🟡 +29.82 KB)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

New Page Added

The following page was added to the bundle from the code in this PR:

Page Size (compressed) First Load % of Budget (350 KB)
/block_neighbor 251 B 275.69 KB 78.77%

Eleven Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load % of Budget (350 KB)
/ 352.48 KB 627.92 KB 179.41% (🟢 -4.82%)
/address/[address] 27.28 KB 302.72 KB 86.49% (🟢 -4.70%)
/blob/[hash] 26.32 KB 301.76 KB 86.22% (🟢 -4.60%)
/blobs 75.51 KB 350.95 KB 100.27% (🟡 +12.19%)
/block/[id] 13 KB 288.44 KB 82.41% (🟢 -4.53%)
/blocks 73.23 KB 348.67 KB 99.62% (🟡 +12.19%)
/stats/blob 336.49 KB 611.93 KB 174.84% (🟢 -4.80%)
/stats/block 337.64 KB 613.08 KB 175.16% (🟢 -4.76%)
/stats/tx 336.75 KB 612.19 KB 174.91% (🟢 -4.76%)
/tx/[hash] 14.07 KB 289.51 KB 82.72% (🟡 +0.23%)
/txs 72.7 KB 348.14 KB 99.47% (🟡 +10.17%)
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

The "Budget %" column shows what percentage of your performance budget the First Load total takes up. For example, if your budget was 100kb, and a given page's first load size was 10kb, it would be 10% of your budget. You can also see how much this has increased or decreased compared to the base branch of your PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this. If you see "+/- <0.01%" it means that there was a change in bundle size, but it is a trivial enough amount that it can be ignored.

Copy link

codecov bot commented Aug 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.90%. Comparing base (c9a6ada) to head (af00b62).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #479   +/-   ##
=======================================
  Coverage   89.90%   89.90%           
=======================================
  Files         148      148           
  Lines        9699     9699           
  Branches     1028     1028           
=======================================
  Hits         8720     8720           
  Misses        979      979           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@PJColombo PJColombo left a comment

Choose a reason for hiding this comment

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

Nice job!

It still needs a few changes.

.changeset/sweet-melons-beg.md Outdated Show resolved Hide resolved
const router = useRouter();

return (
<button
Copy link
Member

Choose a reason for hiding this comment

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

Can we use the button component we already have?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll make that change after the button refactorization PR is merged, since the style of this button is a bit different

apps/web/src/pages/block/[id].tsx Outdated Show resolved Hide resolved
apps/web/src/pages/block/[id].tsx Show resolved Hide resolved
@PabloCastellano PabloCastellano changed the base branch from next to main August 6, 2024 16:03
Copy link
Member

@PJColombo PJColombo left a comment

Choose a reason for hiding this comment

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

Great work.

However, I believe there might be a more efficient approach to retrieving neighboring blocks. Currently, we’re fetching the neighboring block numbers initially, only to fetch the entire block data again when clicking on the arrow buttons to navigate. This double-fetching could be optimized.

Additionally, rendering the arrow buttons after fetching the block by triggering the getBlockNeighbours procedure affects the UI experience, making it feel slightly disjointed.

I think we can optimise the overall logic by leveraging the tRPC React Query's cache , and fetching neighbour blocks on demand only.

We could update the getBlockNeighbors procedure by having it return the same block data structure as the getBlockById procedure. Additionally, we could introduce a new parameter to specify which neighboring block to retrieve (either previous or next) instead of retrieving both.

The flow I envision for navigating to neighbouring blocks is as follows:

  1. The user clicks on either the “next” or “previous” arrow button.
  2. The user is redirected to a new page at /block/[block-number]/neighbour?direction=[next|previous] where the following server-side operations are performed:
    1. Call getBlockNeighbor to retrieve the appropriate neighboring block (next or previous) by using the tRPC server side helpers.
    2. Update the React Query cache entries for the procedure calls getBlockNeighbor and getBlockById with the neighbouring block as input. This way, when requested later, React Query will use the cached value instead of performing the procedure call again. We can do this by using serverSideHelpers.setQueryData. We can get the query key by using getQueryKey
    3. Redirect to /block/[neighbor-block-number], where neighbor-block-number is the block number returned by the previous getBlockNeighbor call. When the page is rendered, tRPC will use the data from the cache we populated previously.

We can reintroduce the server-side helpers for making tRPC calls on the server, which were removed in the search bar fix PR. Instead of instantiating these helpers in every getServerSideProps call, we can create and manage a single instance in a separate file.

.changeset/sweet-melons-beg.md Outdated Show resolved Hide resolved
@@ -25,6 +25,21 @@ function resolveApiUrl(): string {
return `https://api.${env.NEXT_PUBLIC_NETWORK_NAME}.blobscan.com`;
}

type Network = typeof env.NEXT_PUBLIC_NETWORK_NAME;

const NETWORKS_FIRST_BLOB_NUMBER: Record<Network, number> = {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we can have something like getNetworkDencunForkSlot but for blocks?

export function getNetworkDencunForkSlot(
networkName: Environment["NETWORK_NAME"]
): number {
switch (networkName) {
case "mainnet":
return 8626176;
case "holesky":
return 950272;
case "sepolia":
return 4243456;
case "gnosis":
return 14237696;
case "chiado":
return 8265728;
case "devnet":
return 0;
}
}

Copy link
Member

@PabloCastellano PabloCastellano left a comment

Choose a reason for hiding this comment

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

I miss some kind of effect in the buttons so that they change either on hover or clicked. Overall the new implementation using cache looks good!

Reuse the component we have already.

@PabloCastellano PabloCastellano mentioned this pull request Sep 4, 2024
2 tasks
@luis-herasme luis-herasme merged commit 2ded4f9 into main Sep 4, 2024
14 checks passed
@github-actions github-actions bot mentioned this pull request Sep 10, 2024
@PJColombo PJColombo deleted the nav-arrows branch October 29, 2024 11:35
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.

Create "Next" and "Previous" buttons for the block details page
4 participants