-
Notifications
You must be signed in to change notification settings - Fork 22
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
Fetch block details from database #53
Comments
Hi @saimeunt can I work on this? |
Hi @Iwueseiter! |
I am applying to this issue via OnlyDust platform. My background and how it can be leveragedSoftware engineering background mainly in backend development with contributions in previous odhacks. Looking to make first contribution on this project How I plan on tackling this issueI understand I'm to create a function following the implementation of the referenced function and other required functions as hinted including the indexer. I'll make use of all provided resources and be sure to deliver as required |
I am applying to this issue via OnlyDust platform. My background and how it can be leveragedhello @saimeunt I would love to work on this issue I'm a frontend developer and I have made contribution to other repositories, and this would be my first contribution on this repository I would love to contribute to this project!! |
I am applying to this issue via OnlyDust platform. My background and how it can be leveragedPlease I will like to be assigned this issue. I am a front-end Developer, and my experience includes html, css, react, JavaScript and a little of TypeScript. |
I'm applying this issue via Onlydust Platform hi @saimeunt I'll love to be assigned I'm a frontend developer and I'll love to be a contributor to this repo Steps
this issue is easy to tackle hopefully I get assigned |
Hi @martinvibes! |
I am applying to this issue via https://app.onlydust.com/p/opscan-by-walnut @saimeunt can I be assigned to this issue ? My background in software development, JavaScript, and data fetching can be leveraged to efficiently complete this task. To approach this problem, I would:
|
Hi @ShantelPeters! |
I am applying to this issue via OnlyDust platform. My background and how it can be leveragedMy name is Collins Ikechukwu. I am a fullstack developer with 4 years of experience. I'm thrilled about the chance to contribute to the Op Scan Project. With 4 years of solid experience in Next.js, TypeScript, Shadcn, and React, Nodejs and PHP I'm confident in my ability to deliver an efficient and user-friendly Contract page for transactions. How I plan on tackling this issueI will create a new file components/pages/block/fetch-block-details.ts. Update or create lib/fetch-database.ts to include a function for querying block details from the database using Prisma. I will make sure the implementation handles the block ID and adheres to existing design patterns. i will update lib/fetch-data.ts |
I am applying to this issue via OnlyDust platform. My background and how it can be leveragedI'm Poulav Bhowmick, with a robust background in TypeScript, fullstack development and blockchain technology. My experience includes building robust applications, optimizing functionalities and blockchain integration. I have actively participated in events and open source contributions, enhancing my capability to tackle real-world tech challenges. My projects can be viewed on my GitHub Profile and OnlyDust Profile. Plus I´m active member of Starknet community🇷. This is my first contribution to Walnut’s Repositories. How I plan on tackling this issueTo implement fetching block details from either JSON-RPC or a database, I propose the following steps:
Here's a skeleton of the import { l2PublicClient } from "@/lib/chains";
import { prisma } from "@/lib/prisma";
import { fromViemBlock, Block } from "@/lib/types";
const fetchBlockDetailsFromJsonRpc = async (number: bigint): Promise<Block | null> => {
const block = await l2PublicClient.getBlock({ blockNumber: number });
return block ? fromViemBlock(block) : null;
};
const fetchBlockDetailsFromDatabase = async (number: bigint): Promise<Block | null> => {
const block = await prisma.block.findUnique({
where: { number: number.toString() },
include: { transactions: true },
});
if (!block) return null;
// Transform the Prisma block to match the Block type
// This may require additional logic depending on your database schema
return {
number: BigInt(block.number),
hash: block.hash,
parentHash: block.parentHash,
timestamp: BigInt(block.timestamp),
nonce: block.nonce,
difficulty: BigInt(block.difficulty),
gasLimit: BigInt(block.gasLimit),
gasUsed: BigInt(block.gasUsed),
miner: block.miner,
extraData: block.extraData,
baseFeePerGas: block.baseFeePerGas ? BigInt(block.baseFeePerGas) : null,
transactions: block.transactions.map(tx => tx.hash),
};
};
const fetchBlockDetails = process.env.USE_DATABASE === 'true'
? fetchBlockDetailsFromDatabase
: fetchBlockDetailsFromJsonRpc;
export default fetchBlockDetails; |
@saimeunt Please can you assign this to me. |
The maintainer saimeunt has assigned PoulavBhowmick03 to this issue via OnlyDust Platform. |
@PoulavBhowmick03 this one goes to you as you provided a clear description of what's needed to implement the fetchBlockDetails function. There's no need to introduce another environment variable, stick to the pattern used here: https://github.com/walnuthq/op-scan/blob/main/src/components/pages/tx/fetch-transaction-details.ts#L77-L79 |
Fetch block details from database
Read contributors guidelines
User stories
As a rollup developer using op-scan, I want to fetch the block details data either from JSON-RPC (current behavior) or from a database fed from op-indexer.
The data source should be abstracted away in a dedicated function and is configured using an environment variable.
Validation
It should fetch the exact same data whether calling the RPC directly or querying the database.
It MUST adhere to the existing design pattern already implemented in the tx details page.
Implementation
Create a new helper function under
components/pages/block/fetch-block-details.ts
, use the same logic found incomponents/pages/tx/fetch-transaction-details.ts
, a top level exported function which is data source agnostic and 2 separate functions fetching data from either JSON-RPC (this is already implemented here: https://github.com/walnuthq/op-scan/blob/main/src/components/pages/block/index.tsx#L9) or from the database (this is what has to be implemented).Move the block details data fetching logic from the block page to this helper function and just call this function in the block details page top-level server component.
Run op-indexer as a background task in another terminal along the explorer to keep an up-to-date database mirroring what you'd fetch from the JSON-RPC endpoint.
Resources
The text was updated successfully, but these errors were encountered: