Skip to content

Commit

Permalink
(fix) Fix chain info for zq2 and currency symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
rrw-zilliqa committed Dec 9, 2024
1 parent bc5d6a0 commit 6745eeb
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 43 deletions.
100 changes: 59 additions & 41 deletions src/execution/ChainInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,31 @@ import ChainInfoItem from "../components/ChainInfoItem";
import ContentFrame from "../components/ContentFrame";
import { PendingChainInfoResults } from "../search/PendingResults";
import { useBCInfoStateInfo, useLatestBlockChainInfo } from "../useLatestBlock";
import { useQuirks } from "../useQuirks";
import { RuntimeContext } from "../useRuntime";

const ChainInfo: FC = () => {
const { zilliqa } = useContext(RuntimeContext);
const { zilliqa, provider } = useContext(RuntimeContext);
const quirks = useQuirks(provider);

const latestBlockChainInfo = useLatestBlockChainInfo(zilliqa);

const BCInfo = useBCInfoStateInfo(latestBlockChainInfo);

let gridValues = "grid-rows-2 grid-cols-4";
if (quirks?.isZilliqa1) {
gridValues = "grid-rows-3 grid-cols-4";
}
gridValues =
"grid items-baseline gap-x-1 border-t border-b border-gray-200 bg-gray-100 text-sm " +
gridValues;
// Return a table with rows containing the basic information of the most recent RECENT_SIZE blocks
return (
<ContentFrame isLoading={latestBlockChainInfo === undefined}>
<div className="pb-3">
<ChainInfoHeader isLoading={latestBlockChainInfo === undefined} />
{latestBlockChainInfo ? (
<div
className="grid grid-rows-3 grid-cols-4 items-baseline gap-x-1 border-t
border-b border-gray-200 bg-gray-100 text-sm"
>
<div className={gridValues}>
<span>
<ChainInfoItem
title="Current Tx Epoch:"
Expand All @@ -37,30 +43,38 @@ const ChainInfo: FC = () => {
data={latestBlockChainInfo.NumTransactions}
/>
</span>
<span>
<ChainInfoItem
title="Peers:"
data={latestBlockChainInfo.NumPeers}
/>
</span>
<span>
<ChainInfoItem
title="Sharding Structure:"
data={`[${latestBlockChainInfo.ShardingStructure.NumPeers.toString()}]`}
/>
</span>
<span>
<ChainInfoItem
title="Current DS Epoch:"
data={latestBlockChainInfo.CurrentDSEpoch}
/>
</span>
<span>
<ChainInfoItem
title="DS Block Rate:"
data={latestBlockChainInfo.DSBlockRate.toFixed(5)}
/>
</span>
{quirks?.isZilliqa1 && (
<span>
<ChainInfoItem
title="Peers:"
data={latestBlockChainInfo.NumPeers}
/>
</span>
)}
{quirks?.isZilliqa1 && (
<span>
<ChainInfoItem
title="Sharding Structure:"
data={`[${latestBlockChainInfo.ShardingStructure.NumPeers.toString()}]`}
/>
</span>
)}
{quirks?.isZilliqa1 && (
<span>
<ChainInfoItem
title="Current DS Epoch:"
data={latestBlockChainInfo.CurrentDSEpoch}
/>
</span>
)}
{quirks?.isZilliqa1 && (
<span>
<ChainInfoItem
title="DS Block Rate:"
data={latestBlockChainInfo.DSBlockRate.toFixed(5)}
/>
</span>
)}
<span>
<ChainInfoItem
title="Tx Block Rate:"
Expand All @@ -73,18 +87,22 @@ const ChainInfo: FC = () => {
data={latestBlockChainInfo.TransactionRate.toFixed(5)}
/>
</span>
<span>
<ChainInfoItem
title="Number of Txns in DS Epoch:"
data={latestBlockChainInfo.NumTxnsDSEpoch}
/>
</span>
<span>
<ChainInfoItem
title="Number of Txns in Txn Epoch:"
data={latestBlockChainInfo.NumTxnsTxEpoch}
/>
</span>
{quirks?.isZilliqa1 && (
<span>
<ChainInfoItem
title="Number of Txns in DS Epoch:"
data={latestBlockChainInfo.NumTxnsDSEpoch}
/>
</span>
)}
{quirks?.isZilliqa1 && (
<span>
<ChainInfoItem
title="Number of Txns in Txn Epoch:"
data={latestBlockChainInfo.NumTxnsTxEpoch}
/>
</span>
)}
<span>
<ChainInfoItem
title={
Expand Down
4 changes: 2 additions & 2 deletions src/useConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ export const defaultChainInfo: ChainInfo = {
name: "",
faucets: [],
nativeCurrency: {
name: "Ether",
symbol: "ETH",
name: "Zilliqa",
symbol: "ZIL",
decimals: 18,
},
};
Expand Down

0 comments on commit 6745eeb

Please sign in to comment.