// Copyright 2017-2019 @polkadot/app-explorer authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. import { BareProps } from '@polkadot/ui-app/types'; import './BlockHeader.css'; import React from 'react'; import { Link } from 'react-router-dom'; import { HeaderExtended } from '@polkadot/api-derive'; import { AddressMini, LinkPolkascan } from '@polkadot/ui-app'; import { formatNumber } from '@polkadot/util'; type Props = BareProps & { isSummary?: boolean, value?: HeaderExtended, withExplorer?: boolean, withLink?: boolean }; export default class BlockHeader extends React.PureComponent { render () { const { isSummary, value, withExplorer, withLink } = this.props; if (!value) { return null; } const { author, blockNumber, hash } = value; const hashHex = hash.toHex(); const textNumber = formatNumber(blockNumber); return (
{ withLink ? {textNumber} : textNumber } 
{hashHex}
{ author ? : undefined }
{ isSummary ? undefined : this.renderDetails(value) } { withExplorer ? : undefined }
); } private renderDetails ({ blockNumber, extrinsicsRoot, parentHash, stateRoot }: HeaderExtended) { const parentHex = parentHash.toHex(); return (
{ blockNumber.gtn(1) ? {parentHex} : parentHex }
{extrinsicsRoot.toHex()}
{stateRoot.toHex()}
); } }