Balance.tsx 900 B

123456789101112131415161718192021222324252627282930
  1. // Copyright 2017-2020 @polkadot/react-query 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 React from 'react';
  5. import { DeriveBalancesAll } from '@polkadot/api-derive/types';
  6. import { InputBalance } from '@polkadot/react-components';
  7. import { useApi, useCall } from '@polkadot/react-hooks';
  8. interface Props {
  9. className?: string;
  10. label?: React.ReactNode;
  11. params?: any;
  12. }
  13. function BalanceDisplay ({ className = '', label, params }: Props): React.ReactElement<Props> {
  14. const { api } = useApi();
  15. const allBalances = useCall<DeriveBalancesAll>(api.derive.balances.all, [params]);
  16. return (
  17. <InputBalance
  18. className={className}
  19. defaultValue={allBalances?.freeBalance}
  20. isDisabled
  21. label={label}
  22. />
  23. );
  24. }
  25. export default React.memo(BalanceDisplay);