Bonded.tsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright 2017-2020 @polkadot/react-components authors & contributors
  2. // This software may be modified and distributed under the terms
  3. // of the Apache-2.0 license. See the LICENSE file for details.
  4. import { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
  5. import BN from 'bn.js';
  6. import React from 'react';
  7. import { Bonded } from '@polkadot/react-query';
  8. import { renderProvided } from './Balance';
  9. import { classes } from './util';
  10. export interface Props {
  11. bonded?: BN | BN[];
  12. className?: string;
  13. label?: React.ReactNode;
  14. params?: AccountId | AccountIndex | Address | string | Uint8Array | null;
  15. withLabel?: boolean;
  16. }
  17. function BondedDisplay (props: Props): React.ReactElement<Props> | null {
  18. const { bonded, className = '', label, params } = props;
  19. if (!params) {
  20. return null;
  21. }
  22. return bonded
  23. ? <>{renderProvided({ className, label, value: bonded })}</>
  24. : (
  25. <Bonded
  26. className={classes('ui--Bonded', className)}
  27. label={label}
  28. params={params}
  29. />
  30. );
  31. }
  32. export default React.memo(BondedDisplay);