// Copyright 2017-2019 @polkadot/ui-app 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 { DerivedBalances, DerivedStaking } from '@polkadot/api-derive/types'; import { BareProps, I18nProps } from './types'; import BN from 'bn.js'; import React from 'react'; import styled from 'styled-components'; import { formatBalance, formatNumber } from '@polkadot/util'; import { Icon, Tooltip, TxButton } from '@polkadot/ui-app'; import { withCalls, withMulti } from '@polkadot/ui-api'; import CryptoType from './CryptoType'; import Label from './Label'; import translate from './translate'; // true to display, or (for bonded) provided values [own, ...all extras] export type BalanceActiveType = { available?: boolean, bonded?: boolean | BN[], free?: boolean, redeemable?: boolean, unlocking?: boolean }; export type CryptoActiveType = { crypto?: boolean, nonce?: boolean }; export type ValidatorPrefsType = { unstakeThreshold?: boolean, validatorPayment?: boolean }; type Props = BareProps & I18nProps & { address: string, balances_all?: DerivedBalances, children?: React.ReactNode, staking_info?: DerivedStaking, withBalance?: boolean | BalanceActiveType, withRewardDestination?: boolean, withExtended?: boolean | CryptoActiveType, withValidatorPrefs?: boolean | ValidatorPrefsType }; class AddressInfo extends React.PureComponent { public render (): React.ReactNode { const { children, className } = this.props; return (
{this.renderBalances()} {this.renderValidatorPrefs()} {this.renderRewardDestination()}
{this.renderExtended()} {children && (
{children}
)}
); } private renderBalances () { const { balances_all, staking_info, t, withBalance = true } = this.props; const balanceDisplay = withBalance === true ? { available: true, bonded: true, free: true, redeemable: true, unlocking: true } : withBalance ? withBalance : undefined; if (!balanceDisplay || !balances_all) { return null; } return ( <> {balanceDisplay.free && ( <>