Closed saimeunt closed 5 months ago
Hi! Can I hop on this? I have already worked on a similar issue and think I can handle this!
Plus I am already working on the block transactions issue, I think I can work on this as a continuation of that issue.
How I would approach this:
Hi, i would like work in this issue
Detailed Approach to Creating a Block Display Component
Configure Route Access Ensure that the /blocks route is correctly set up in your application's routing system. This involves configuring the appropriate routing so that when users access this route, they are presented with the block display component.
Testing and Validation Once the component is integrated and the route is configured, conduct testing to verify that everything functions as expected. Test various scenarios, such as viewing different pages of blocks if pagination is implemented, and ensure that data is displayed correctly in the user interface.
Optimization and Enhancements If necessary, optimize the component and data integration to improve performance and usability. Consider any improvements to design or functionality that could enhance the user experience.
Hey! I would love to work on this issue! I am Poulav Bhowmick, a fullstack blockchain developer, already raised a PR and have a pretty good understanding of the codebase
I already have decent experience in building pagination, be it with or without Shadcn UI, so I feel I would be a great fit for this task I would love to get assigned and complete this task as soon as possible
@saimeunt
I'm interested in implementing the Latest Block page for the Op Scan Project. This is my first time contributing to a Walnut project. With my 3 years of solid background in Next.js, TypeScript, Shadcn, and React, I’m very sure that i will deliver an efficient and user-friendly blocks page. You can check out my GitHub profile here: My Github Profile
src/pages/blocks.tsx
.getServerSideProps
or getStaticProps
to fetch the initial list of blocks, ensuring efficient data loading and SEO benefits.block number
, timestamp
, transaction count
, gas used
, and gas limit
./blocks
will show blocks 100 to 76, /blocks?p=2
will show blocks 75 to 51, and so on.useSearchParams
function from Next.js to manage query parameters and navigate between pages.(/block/:number)
.(/block/:number/txs)
.<Progress value={(gasUsed / gasLimit) * 100} />
getServerSideProps
to fetch the initial data on the server-side. This ensures that the page loads with the necessary data already available, improving both load time and SEO.I am confident that my approach will deliver a high-quality and user-friendly Latest Blocks page. I will do my best to deliver on this issue promptly and ensure it meets the project's standards.
Hello walnut team,
I would love to work on this issue and here is my proposal for the implementation:
The objective is to develop a page that displays a paginated list of the latest blocks created on the blockchain. This list should include:
The visualization should resemble the latest blocks list on Etherscan, without additional metrics such as network utilization or block size.
/blocks
: Create a dedicated page to display the list of blocks. This page will use a React Server Component to handle the fetching and initial rendering of block data, adhering to Next.js best practices for handling search parameters (searchParams
)./api/blocks
: Implement an API to fetch blocks from a simulated source or a blockchain API. This API will handle receiving the page number and returning the corresponding blocks, based on the last known block number.searchParams
). The logic will maintain the last block number as a reference to calculate subsequent pages, ensuring that navigation always shows 25 blocks per page, starting from the last known block./blocks
page is rendered with up-to-date data from the server without requiring additional client-side requests./block/:number
for block details and /block/:number/txs
for the block's transaction list. This will improve navigation and access to detailed information about each block.My plan outlines a complete and careful implementation that follows Next.js best practices and uses Shadcn components for a clean and efficient user interface. This solution not only meets the specific requirements of the issue but also ensures an intuitive user experience and a technically sound implementation.
I hope to have the opportunity to work on this issue and contribute significantly to the project. Thank you for considering my proposal.
Best regards, Armando.
@Benjtalkshow this one is for you!
I appreciate your proposal, while reading it a couple things came to my mind:
Please make sure you are following along the latest NextJS way of approaching Server Side Rendering which is the app router and React Server Components, getServerSideProps
/ getStaticProps
and the pages router is outdated. You can refer to other pages and components already implemented and the NextJS docs if needed: https://nextjs.org/docs/app/building-your-application/data-fetching/patterns#parallel-data-fetching
Regarding pagination, it should be done almost entirely server-side using the searchParams
parameter: https://nextjs.org/docs/app/api-reference/file-conventions/page#searchparams-optional you should not use useSearchParams
which is a client side API.
Something else came into my mind, you will need to fetch the latest block number on first page load and then pass it to all subsequent page navigation since data fetching only happens on the server.
blocks
display blocks 100 => 76 and since there's no latest
query parameter, fetch it using viem getBlockNumber
and use it in pagination links.blocks?p=2&latest=100
display blocks 75 => 51, read latest block number from searchParams
.Finally, everything related to caching is an after thought and out of scope for this issue, as well as cross browser support and responsive design, we assume shadcn/ui sane defaults will be more than enough.
@saimeunt,
Thank you for assigning this task to me. I also appreciate the clarification on using the latest NextJS practices for Server Side Rendering with the app router and React Server Components. I will ensure to follow these guidelines and refer to the NextJS documentation and existing components as needed.
@Benjtalkshow how is it going with the issue? Are you still working on this? Please note that if you're not providing at least a draft PR by the end of Wednesday we'll have to assign someone else.
@saimeunt Good day sir, i am currently working it. i will provide feedback soon.
@saimeunt ,
Made a pr for the latest blocks page some (hours ago) #32
Latest blocks page
⚠️ Reading contributors guidelines to get assigned is MANDATORY!
Read contributors guidelines
User stories
/blocks
Validation
It should look like the Etherscan latest blocks list: https://optimistic.etherscan.io/blocks
For the gas used column, you should add the percentage against gas limit and you can show a progress bar using https://ui.shadcn.com/docs/components/progress Don't forget to add links to block details page
/block/:number
and block txs/block/:number/txs
page.Do NOT include block metrics such as Network utilization, block size, etc. Do NOT add a "Download Page Data" button. Do NOT add a "Show rows" dropdown, this is out of scope for this issue.
Implementation
Use a simple table from shadcn/ui, always display 25 blocks and use a query parameter to handle pagination: If current block head is 100 then
/blocks
=> blocks 100 => 76/blocks?p=2
=> blocks 75 => 51/blocks?p=3
=> blocks 50 => 26 Use client state to keep track of the latest block number upon first visiting the page, and use this as a reference for navigation: when we click on page 2, we want to see the next 25 blocks from the initial block head (100), not the next 25 blocks from the new current block head.You must use NextJS best practices about handling query parameters, in particular, read
searchParams
from the top-level Page component and use a React Server Component to fetch the blocks needed. Do NOT fetch the blocks client-side.Resources