walnuthq / op-scan

Lightweight transaction explorer for the OP Stack.
https://opscan.co
12 stars 22 forks source link

Latest blocks page #19

Closed saimeunt closed 5 months ago

saimeunt commented 5 months ago

Latest blocks page

⚠️ Reading contributors guidelines to get assigned is MANDATORY!

Read contributors guidelines

User stories

Validation

It should look like the Etherscan latest blocks list: https://optimistic.etherscan.io/blocks

Image

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

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

adrianvrj commented 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:

MariangelaNM commented 5 months ago

Hi, i would like work in this issue

Detailed Approach to Creating a Block Display Component

  1. 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.

  2. 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.

  3. 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.

PoulavBhowmick03 commented 5 months ago

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

How I would implement the latest blocks page

  1. Create a new route in the app folder and would import the @/components/pages/home/latest-blocks
  2. Would use Shadcn UI to create a similar looking table and use the props from the previously imported latest-blocks component to display the block number, timestamp, txn count, gas used and gas limit

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

Benjtalkshow commented 5 months ago

@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

Proposed Solution for Latest Blocks Page

Component Creation:

Fetching Data:

Table Structure:

Pagination:

Linking to Details:

  1. Each block number in the table will be a link to the block details page (/block/:number).
  2. The transaction count will link to the block transactions page(/block/:number/txs).

UI Components:

Performance Optimization:

Testing and Validation:

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.

armandocodecr commented 5 months ago

Plan to Resolve the Issue: Latest Blocks Page

Hello walnut team,

I would love to work on this issue and here is my proposal for the implementation:

Problem Description

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.

Implementation Plan

1. Project Structure

a. Create the Route for Blocks:

b. Implement the API to Fetch Blocks:

c. Table Component:

d. Pagination:

2. Technical Details

a. Use of React Server Component (RSC):

b. Progress Bar:

c. Detail Links:

3. Verification and Testing

a. Pagination Verification:

b. Data Verification:

c. Link Navigation:

Conclusion

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.

saimeunt commented 5 months ago

@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.

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.

Benjtalkshow commented 5 months ago

@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.

saimeunt commented 5 months ago

@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.

Benjtalkshow commented 5 months ago

@saimeunt Good day sir, i am currently working it. i will provide feedback soon.

Benjtalkshow commented 5 months ago

@saimeunt ,

Made a pr for the latest blocks page some (hours ago) #32