Skip to content

Commit

Permalink
Improve formatting slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
FrederikBolding committed Jul 26, 2024
1 parent 0916e67 commit 5d22525
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/components/RpcTable.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useContext, useEffect, useState } from "react";
import {
Button,
Skeleton,
Table,
TableContainer,
Tbody,
Expand All @@ -19,8 +20,8 @@ async function checkRpc(chainId: number, rpc: string) {
const provider = new JsonRpcProvider(rpc, chainId, { staticNetwork: true });
const blockNumber = await provider.getBlockNumber();
return { blockNumber, latency: Date.now() - now };
} catch {
return null;
} catch (error) {
return { error };
}
}

Expand Down Expand Up @@ -63,12 +64,24 @@ export const RpcTable = ({
</Tr>
</Thead>
<Tbody>
{mergedRpcs.map(({ rpcUrl, blockNumber, latency }) => {
{mergedRpcs.map(({ rpcUrl, blockNumber, latency, error }) => {
return (
<Tr key={rpcUrl}>
<Td pl="0">{rpcUrl}</Td>
<Td>{blockNumber ?? "?"}</Td>
<Td>{latency ?? "?"} ms</Td>
<Td>
{blockNumber || error ? (
blockNumber ?? "Unavailable"
) : (
<Skeleton height="24px" />
)}
</Td>
<Td>
{latency || error ? (
<>{latency ?? "?"} ms</>
) : (
<Skeleton height="24px" />
)}
</Td>
<Td pr="0" textAlign="end">
{!isConnected ? (
<Button onClick={handleConnect}>Connect</Button>
Expand Down

0 comments on commit 5d22525

Please sign in to comment.