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'
: `${block.num_txs} transactions`}
</td>
{block.header?.proposer_address && (
<td>
<Link to={`/validators/${block.header.proposer_address}`}>
{block.header.proposer_address}
</Link>
</td>
)}
<td>
<Link to={`/validators/${block.header?.proposer_address}`}>
{block.header.proposer_address}
</Link>
</td>
<td>
<SecondsAgo date={block.header?.time} />
</td>
</tr>
{showTransactions && (
<tr>
<TxsPerBlock blockHeight={block.header.height} />
<TxsPerBlock blockHeight={block.header?.height} />
</tr>
)}
</>

View File

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