index.tsx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Copyright 2017-2018 @polkadot/app-explorer authors & contributors
  2. // This software may be modified and distributed under the terms
  3. // of the ISC license. See the LICENSE file for details.
  4. import { Header } from '@polkadot/primitives/header';
  5. import { I18nProps } from '@polkadot/ui-app/types';
  6. import './BlockHeader.css';
  7. import React from 'react';
  8. import headerHash from '@polkadot/primitives-codec/header/hash';
  9. import classes from '@polkadot/ui-app/util/classes';
  10. import numberFormat from '@polkadot/ui-react-rx/util/numberFormat';
  11. import u8aToHex from '@polkadot/util/u8a/toHex';
  12. import translate from '../translate';
  13. type Props = I18nProps & {
  14. value?: Header
  15. };
  16. function BlockHeader ({ className, value, style }: Props) {
  17. if (!value) {
  18. return null;
  19. }
  20. const hash = headerHash(value);
  21. const { extrinsicsRoot, number, parentHash, stateRoot } = value;
  22. return (
  23. <div
  24. className={classes('explorer--BlockHeader', className)}
  25. style={style}
  26. >
  27. <div className='number'>
  28. <div>{numberFormat(number)}</div>
  29. </div>
  30. <div className='details'>
  31. <div className='hash'>
  32. {u8aToHex(hash)}
  33. </div>
  34. <table className='contains'>
  35. <tbody>
  36. <tr>
  37. <td className='type'>parentHash</td>
  38. <td className='hash'>
  39. {u8aToHex(parentHash)}
  40. </td>
  41. </tr>
  42. <tr>
  43. <td className='type'>extrinsicsRoot</td>
  44. <td className='hash'>
  45. {u8aToHex(extrinsicsRoot)}
  46. </td>
  47. </tr>
  48. <tr>
  49. <td className='type'>stateRoot</td>
  50. <td className='hash'>
  51. {u8aToHex(stateRoot)}
  52. </td>
  53. </tr>
  54. </tbody>
  55. </table>
  56. </div>
  57. </div>
  58. );
  59. }
  60. export default translate(BlockHeader);