-
Notifications
You must be signed in to change notification settings - Fork 39
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
Conversation
🦋 Changeset detectedLatest commit: af00b62 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
4 Skipped Deployments
|
📦 Next.js Bundle Analysis for @blobscan/webThis analysis was generated by the Next.js Bundle Analysis action. 🤖
|
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.
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
There was a problem hiding this 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.
apps/web/src/components/NavArrow.tsx
Outdated
const router = useRouter(); | ||
|
||
return ( | ||
<button |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this 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:
- The user clicks on either the “next” or “previous” arrow button.
- The user is redirected to a new page at
/block/[block-number]/neighbour?direction=[next|previous]
where the following server-side operations are performed:- Call
getBlockNeighbor
to retrieve the appropriate neighboring block (next or previous) by using the tRPC server side helpers. - Update the React Query cache entries for the procedure calls
getBlockNeighbor
andgetBlockById
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 usingserverSideHelpers.setQueryData
. We can get the query key by usinggetQueryKey
- Redirect to
/block/[neighbor-block-number]
, whereneighbor-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.
- Call
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.
Co-authored-by: elessar.eth <paulo.colombo@pm.me>
@@ -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> = { |
There was a problem hiding this comment.
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?
blobscan/apps/rest-api-server/src/utils.ts
Lines 3 to 20 in 03fb6b0
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; | |
} | |
} |
There was a problem hiding this 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.
Checklist
Description
Add NavArrows component
Related Issue (Optional)
#471
Closes #472
Screenshots (if appropriate):