Skip to content

[Explorer]: Shinzohub Transactions and Transaction details#231

Open
NiranjanaBinoy wants to merge 14 commits into
mainfrom
feat/shinzohub-txns
Open

[Explorer]: Shinzohub Transactions and Transaction details#231
NiranjanaBinoy wants to merge 14 commits into
mainfrom
feat/shinzohub-txns

Conversation

@NiranjanaBinoy

@NiranjanaBinoy NiranjanaBinoy commented May 27, 2026

Copy link
Copy Markdown
Contributor

Pull Request

Description

The PR uses the existing transactions and transaction-details components for Shinzohub.

Changes

  • I reorganized the component paths for more clarity in this PR, the components under @page/shinzohub/home are moved to @page/shinzohub-home avoiding an extra step in the folder structure. These files does not have any new changes, they only reflect the path changes.
  • The files in the transactions and transaction-details folders are organized to /hook and /ui folders respectively.
  • Inside the /hook folder, all the existing ethereum based hooks are moved to ethereum folder and shinzohub related hooks are in the shinzohub folder.
  • In the /ui folder, we have reused most of the components, in transactions I have updated the page.tsx to call the chain based page clients and introduced EthereumTransactionsPageClient and ShinzohubTransactionsPageClient for chain specific data rendering.
  • Similarly in transaction-details I have EthereumTransactionCard and ShinzohubTransactionCard which uses teh respective hooks to fetch the related data to be displayed.

Related Issue

fixes #161

Steps to Test

Worker urls => https://feat-shinzohub-txns-shinzo-explorer.shinzo-492.workers.dev/shinzohub/txs
https://feat-shinzohub-txns-shinzo-explorer.shinzo-492.workers.dev/shinzohub/tx/--hash value --

  1. Pull branch locally and NEXT_PUBLIC_SHINZOHUB_RPC_URL=http://rpc.develop.devnet.shinzo.network:8545 to the .env file
  2. Run the app or service
  3. Load http://localhost:3000/shinzohub/txs to get transactiosn list.
  4. Load http://localhost:3000/shinzohub/tx/-txhash- to get the transactions details.

Checklist

  • Code compiles / runs
  • Tests added / updated
  • Documentation updated if needed
  • PR is self-contained and focused
  • Code does not break any existing features
  • Code passes personal internal testing

Notes

@NiranjanaBinoy NiranjanaBinoy self-assigned this May 27, 2026
@NiranjanaBinoy NiranjanaBinoy added the enhancement New feature or request label May 27, 2026
@NiranjanaBinoy NiranjanaBinoy linked an issue May 27, 2026 that may be closed by this pull request
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 27, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
shinzo-explorer 547cf18 Commit Preview URL

Branch Preview URL
Jun 09 2026, 06:05 PM

unwatch()
}
}, [count])
}, [count, publicClient])

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Lint warning fix


import { useMemo } from 'react';
import { useShinzohubTransactionIndex } from '../../hook/use-shinzohub-transaction-index';
import { useShinzohubTransactionsSync } from '@/pages/transactions/hooks/shinzohub/use-shinzohub-transactions-sync';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Existing hook is renamed for clarity

queryKey: ['transaction-logs', hash],
enabled: !!hash && enabled,
queryKey: ['ethereum', 'transaction-logs', hash],
enabled: chain === 'ethereum' && !!hash && !!tx,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

to make sure the api fetch call happens only for ethereum not shinzohub.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why could it possibly be called on shinzohub-related pages? Do you have this hook usages running globally? I imagine that ethereum-related hooks shouldn't even be called on shinzohub pages

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

suggestion: refactor it in a way that the hook doesn't depend on useChainPathSegment hook. It should only be called in the pages where it is actually needed

@@ -0,0 +1,209 @@
'use client';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is a new component added for Shinzohub transaction details; It fetches data from Shinzohub specific hooks and use DataList to display i, same as in EthereumTransactionCard.

case 'ethereum':
return <TransactionLogs txHash={hash} />;
default:
return null;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Making sure the transcationlogs get rendered for only ethereum network.

case 'shinzohub':
return <ShinzohubTransactionCard txHash={hash} />;
default:
return null;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Switch based on chain to render the appropriate transaction card.

import { getPublicClient } from '@/shared/viem/client';
import type { Transaction } from 'viem';

const TX_INDEX_QUERY_KEY = ['shinzohub', 'transaction-index'] as const;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Most of the changes in this hook is renaming the variables for clarity

case 'shinzohub':
return <ShinzohubTransactionsPageClient pageParams={pageParams} />
default:
return <div>Invalid chain</div>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Chain based rendering of the TransactionPageClient

@@ -0,0 +1,47 @@
"use client"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

New component to render the transactions list for the Shinzohub. this one uses the Shinzohub specific use-shinzohub-transcations hook for the data fetching.

Comment thread apps/explorer/lib/pages/transactions/ui/transactions-list.tsx
@NiranjanaBinoy NiranjanaBinoy marked this pull request as ready for review June 2, 2026 05:31
Comment thread apps/explorer/lib/pages/shinzohub-home/ui/transactions-home.tsx Outdated
queryKey: ['transaction-logs', hash],
enabled: !!hash && enabled,
queryKey: ['ethereum', 'transaction-logs', hash],
enabled: chain === 'ethereum' && !!hash && !!tx,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

suggestion: refactor it in a way that the hook doesn't depend on useChainPathSegment hook. It should only be called in the pages where it is actually needed

Comment thread apps/explorer/lib/pages/transactions/ui/page.tsx Outdated
import { formatUnits } from "viem";

export const formatGasPrice = (gasPrice: string) => {
return Number(formatUnits(BigInt(gasPrice), 9)).toFixed(2);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

question: is gas always measured with 9 decimals?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

As we are formating the gasPrice to GWEI, which is Giga-WEI, it should be 9 from what I could find.

cc @dvncan or @soniasingla can you confirm this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

viem have a formatGwei for the same conversion, I am replacing this function with that in #235

# Optional overrides per path: /ethereum/* vs /shinzohub/* (Shinzo chain id 91273002)
NEXT_PUBLIC_ETHEREUM_RPC_URL=
NEXT_PUBLIC_SHINZOHUB_RPC_URL=
NEXT_PUBLIC_SHINZOHUB_RPC_URL=http://rpc.develop.devnet.shinzo.network:8545

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

suggestion: add a proxy endpoint and make the viem client configurable to use the proxy when calling ShinzoHub. It would make the deployed Explorer load data correctly. Limit this proxy endpoint to same-site requests, so it won't be available for anyone else to use.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have added the url in this file just for testing guid lines, I have added the staging proxy url to the deployed app.

@VanishMax VanishMax left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

issue: requests keep loading infinitely. In the screenshot, I got >300 requests in 6.8 seconds.

Image

@NiranjanaBinoy

Copy link
Copy Markdown
Contributor Author

issue: requests keep loading infinitely. In the screenshot, I got >300 requests in 6.8 seconds.

Image

Inorder to fetch the list of transactions using viem, we need to read through each block and get the trasaction from each block. We currently have a hook useShinzohubTranscationSync, which reads through all the blocks starting from 0 during the initial load and travel upto the latest block at that point. At each 20 blocks the transactions detected until that point are written to localstorage. We are also saving the latestblock till fetch the fetch is done, so for every refetch we will start from that point to fill the transaction list. This is the reason we are seeing so many request at the backend, for me all of them are resolving. Since we do not have much activity, just filling transaction list as the blocks comes up leaves the transactions list bare.

I am thinking of storing the transactions list to the cloudflare DB1 instead of in localstorage, in which case the user does not have to wait till the transactions started loading, it wont be alarming when the initial transactions starts loading.

@VanishMax

Copy link
Copy Markdown
Collaborator

At each 20 blocks the transactions detected until that point are written to localstorage

Unexpected. This definitely shouldn't be a work of the frontend. With this logic, all we'll do is start a DoS attack on a ShinzoHub node, and we surely don't want that.

I agree on using a DB from Cloudflare. Ideally, it should start the data-filling process as soon as the explorer is deployed, and keep the backend stateful - always watching for new blocks and processing them when needed.

If you think this is too much for the current PR, then we can leave it minimal and simply render transactions only for the last block, or show 0 if it doesn't have it. It would require removing the localStorage tx saving logic and infinite requests logic.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 4, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
shinzo-webapp-staging 8e0b215 Jun 04 2026, 08:59 PM

@NiranjanaBinoy NiranjanaBinoy changed the title [Explorer]: Shinzohub Transactions [Explorer]: Shinzohub Transactions and Transaction details Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Explorer: ShinzoHub transactions

2 participants