Skip to content

Commit

Permalink
zetachain metrics added
Browse files Browse the repository at this point in the history
  • Loading branch information
vasylcode authored Sep 6, 2023
1 parent 8f78854 commit f4408d2
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/zetachain/index.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Zetachain

import MainpageMetrics from '@site/src/components/MainpageMetrics';

<MainpageMetrics rpc="https://zetachain-rpc.f5nodes.com/net_info" binary="zetacored" />

[Zetachain](https://www.zetachain.com/) is an EVM-compatible L1 blockchain that connects everything: Build interoperable dApps that span any chain, including Bitcoin; access all chains from one place.

[Website](https://www.zetachain.com/) | [Blog](https://www.zetachain.com/blog) | [GitHub](https://github.com/zeta-chain) | [Twitter](https://twitter.com/zetablockchain) | [Discord](https://discord.gg/zetachain) | [Docs](https://docs.zetachain.com/)
Expand Down
File renamed without changes.
File renamed without changes.
44 changes: 44 additions & 0 deletions src/components/MainpageMetrics/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React, { useEffect, useState } from "react";

interface MainpageMetricsProps {
rpc: string;
binary: string;
}

const MainpageMetrics: React.FC<MainpageMetricsProps> = ({ rpc, binary }) => {
const [network, setNetwork] = useState<string>("");
const [isLoading, setIsLoading] = useState<boolean>(true);

useEffect(() => {
const fetchNetworkInfo = async () => {
try {
const response = await fetch(`${rpc}/status`);
const data = await response.json();

const networkInfo = data.result.node_info.network;
setNetwork(networkInfo);
setIsLoading(false);
} catch (error) {
console.error(`Failed to fetch network info for RPC ${rpc}:`, error);
setIsLoading(false);
}
};

fetchNetworkInfo();
}, [rpc]);

return (
<>
{isLoading ? (
<p>Loading metrics info...</p>
) : (
<>
<h4>Network: {network}</h4>
<p>Binary Value: {binary}</p>
</>
)}
</>
);
};

export default MainpageMetrics;

0 comments on commit f4408d2

Please sign in to comment.