Added validator link to block id route

This commit is contained in:
sam-keen 2022-03-03 14:16:10 +00:00 committed by Dexter Edwards
parent 3f47eed917
commit d3b81babb9
2 changed files with 19 additions and 11 deletions

View File

@ -30,20 +30,18 @@ export const BlocksTable = ({ data, showTransactions }: BlocksProps) => {
? '1 transaction' ? '1 transaction'
: `${block.num_txs} transactions`} : `${block.num_txs} transactions`}
</td> </td>
{block.header?.proposer_address && (
<td> <td>
<Link to={`/validators/${block.header.proposer_address}`}> <Link to={`/validators/${block.header?.proposer_address}`}>
{block.header.proposer_address} {block.header.proposer_address}
</Link> </Link>
</td> </td>
)}
<td> <td>
<SecondsAgo date={block.header?.time} /> <SecondsAgo date={block.header?.time} />
</td> </td>
</tr> </tr>
{showTransactions && ( {showTransactions && (
<tr> <tr>
<TxsPerBlock blockHeight={block.header.height} /> <TxsPerBlock blockHeight={block.header?.height} />
</tr> </tr>
)} )}
</> </>

View File

@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import { useParams } from 'react-router-dom'; import { Link, useParams } from 'react-router-dom';
import { DATA_SOURCES } from '../../../config'; import { DATA_SOURCES } from '../../../config';
import useFetch from '../../../hooks/use-fetch'; import useFetch from '../../../hooks/use-fetch';
import { TendermintBlocksResponse } from '../tendermint-blocks-response'; import { TendermintBlocksResponse } from '../tendermint-blocks-response';
@ -15,18 +15,28 @@ const Block = () => {
`${DATA_SOURCES.tendermintUrl}/block?height=${block}` `${DATA_SOURCES.tendermintUrl}/block?height=${block}`
); );
const header = blockData?.result.block.header;
if (!header) {
return <>Could not get block data</>;
}
return ( return (
<section> <section>
<h1>BLOCK {block}</h1> <h1>BLOCK {block}</h1>
<Table> <Table>
<tr> <tr>
<td>Mined by</td> <td>Mined by</td>
<td>{blockData?.result.block.header?.proposer_address}</td> <td>
<Link to={`/validators/${header.proposer_address}`}>
{header.proposer_address}
</Link>
</td>
</tr> </tr>
<tr> <tr>
<td>Time</td> <td>Time</td>
<td> <td>
<SecondsAgo date={blockData?.result.block.header?.time} /> <SecondsAgo date={header.time} />
</td> </td>
</tr> </tr>
</Table> </Table>