diff --git a/packages/app-explorer/src/Summary.tsx b/packages/app-explorer/src/Summary.tsx index 01e888b648..9d326baa2b 100644 --- a/packages/app-explorer/src/Summary.tsx +++ b/packages/app-explorer/src/Summary.tsx @@ -6,7 +6,7 @@ import { I18nProps } from '@polkadot/ui-app/types'; import React from 'react'; import { SummaryBox, CardSummary } from '@polkadot/ui-app'; -import { BestFinalized, BestNumber, TimeNow, TimePeriod } from '@polkadot/ui-reactive'; +import { BestFinalized, BestNumber, TimeNow, TimePeriod, TotalIssuance } from '@polkadot/ui-reactive'; import SummarySession from './SummarySession'; import translate from './translate'; @@ -20,14 +20,20 @@ class Summary extends React.PureComponent { return (
+ + + - - + +
diff --git a/packages/ui-reactive/src/TotalIssuance.tsx b/packages/ui-reactive/src/TotalIssuance.tsx new file mode 100644 index 0000000000..41cd4a11d3 --- /dev/null +++ b/packages/ui-reactive/src/TotalIssuance.tsx @@ -0,0 +1,40 @@ +// Copyright 2017-2019 @polkadot/ui-reactive 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, CallProps } from '@polkadot/ui-api/types'; + +import React from 'react'; +import { Balance } from '@polkadot/types'; +import { withCalls } from '@polkadot/ui-api'; +import { formatBalance } from '@polkadot/util'; + +type Props = BareProps & CallProps & { + children?: React.ReactNode, + label?: string, + balances_totalIssuance?: Balance +}; + +export class TotalIssuance extends React.PureComponent { + render () { + const { children, className, label = '', style, balances_totalIssuance } = this.props; + const value = balances_totalIssuance + ? balances_totalIssuance.toString() + : null; + + return ( +
+ {label}{ + value + ? `${formatBalance(value, false)}${formatBalance.calcSi(value).value}` + : '-' + }{children} +
+ ); + } +} + +export default withCalls('query.balances.totalIssuance')(TotalIssuance); diff --git a/packages/ui-reactive/src/index.ts b/packages/ui-reactive/src/index.ts index 3121d451e5..c1f43ed72d 100644 --- a/packages/ui-reactive/src/index.ts +++ b/packages/ui-reactive/src/index.ts @@ -15,4 +15,5 @@ export { default as NodeVersion } from './NodeVersion'; export { default as Nonce } from './Nonce'; export { default as TimeNow } from './TimeNow'; export { default as TimePeriod } from './TimePeriod'; +export { default as TotalIssuance } from './TotalIssuance'; export { default as Unlocking } from './Unlocking';