Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alter display info of Staking summary overview #7179

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
2fc7495
add minExposedThreshold into useSortedTarget
wirednkod Mar 16, 2022
f9eb19c
Fix the minExposedThreshold scripts/hook
wirednkod Mar 16, 2022
42359e8
fix missing api error
wirednkod Mar 17, 2022
4be121a
add implementation based on issue #6918
wirednkod Mar 17, 2022
cddbd7e
add translation strings
wirednkod Mar 17, 2022
deaa75e
remove stray logs
wirednkod Mar 17, 2022
e60c7b3
revert formatBalance
wirednkod Mar 21, 2022
4019138
fix code to show correctly the min active nominator stake
wirednkod Mar 21, 2022
0fa8264
Add tooltip; Fix breaking lint
wirednkod Mar 21, 2022
ba6b934
merge
wirednkod Apr 14, 2022
6111da4
Merge branch 'master' of github.com:wirednkod/apps into nik-fix-staki…
wirednkod Apr 14, 2022
6ee2b5b
Fix performance issue
wirednkod Apr 14, 2022
b635be3
readdress performance
wirednkod Apr 14, 2022
306d909
resolve merge conflicts
wirednkod Apr 19, 2022
c801839
Seperate pages Overview/Validator
wirednkod Apr 19, 2022
e6d2158
Remove not-necessery components; Revert changes of SummaryBox
wirednkod Apr 19, 2022
8099177
Finalize Overview page by concentrating Summaries
wirednkod Apr 21, 2022
5489dac
merge with master and resolve conflicts
wirednkod Apr 21, 2022
5e4ba99
Fix merge issue
wirednkod Apr 21, 2022
0af248e
Add condition rendering for bags Card in Overview
wirednkod Apr 22, 2022
de0e9ea
Merge branch 'master' into nik-fix-staking-numbers
wirednkod May 6, 2022
ac124fd
Merge branch 'polkadot-js:master' into nik-fix-staking-numbers
wirednkod May 17, 2022
4e53f1b
Update translation string
wirednkod May 17, 2022
e234c9e
Merge branch 'nik-fix-staking-numbers' of github.com:wirednkod/apps i…
wirednkod May 17, 2022
e7038c8
Address more PR comments
wirednkod May 17, 2022
fc5ba15
Correct the max electing nominators
wirednkod May 17, 2022
7347707
Add notice for nominators
wirednkod May 17, 2022
fe3fc30
Merge branch 'polkadot-js:master' into nik-fix-staking-numbers
wirednkod May 24, 2022
157b58b
move notification inside nominator's panel
wirednkod May 24, 2022
113eb7d
satisfy linter
wirednkod May 24, 2022
b046c48
satisfy linter
wirednkod May 24, 2022
9aa37fe
resolve conflicts
wirednkod Jun 9, 2022
cada3da
Correct staking page for older staking networks
wirednkod Jun 15, 2022
72be4b5
merge with master
wirednkod Jun 15, 2022
db83a8a
merge with master
wirednkod Jun 15, 2022
d31a7ec
Merge branch 'master' of github.com:wirednkod/apps into nik-fix-staki…
wirednkod Jun 20, 2022
c3122b2
Address issues on Docker PoS Mainnet
wirednkod Jun 22, 2022
cdf1106
Merge branch 'polkadot-js:master' into nik-fix-staking-numbers
wirednkod Jul 12, 2022
b200658
Address issue of Automata
wirednkod Jul 12, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/apps/public/locales/en/app-staking.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
"Join nomination pool": "Join nomination pool",
"Keys from rotateKeys": "Keys from rotateKeys",
"Max, {{eras}} eras": "Max, {{eras}} eras",
"Minimum stake among the active nominators": "Minimum stake among the active nominators",
"Minimum (total) stake among the active validators.": "Minimum (total) stake among the active validators.",
"Members ({{count}})": "Members ({{count}})",
"Most profitable": "Most profitable",
"Move up {{jumpCount}}": "Move up {{jumpCount}}",
Expand Down Expand Up @@ -276,6 +278,7 @@
"member account": "member account",
"members": "members",
"min": "min",
"min active stake": "min active stake",
"min nominated": "min nominated",
"min nominated / threshold": "min nominated / threshold",
"my nodes": "my nodes",
Expand Down Expand Up @@ -350,4 +353,4 @@
"{{currency}} slashed": "{{currency}} slashed",
"{{currency}} total": "{{currency}} total",
"{{days}} days": "{{days}} days"
}
}
3 changes: 2 additions & 1 deletion packages/apps/public/locales/it/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1466,6 +1466,7 @@
"https://example.com": "https://example.com",
"id": "id",
"ideal staked": "",
"min active stake": "",
"identity": "identità",
"imminent preimage (proposal already passed)": "proposta imminente (già approvate)",
"immortal": "perpetua",
Expand Down Expand Up @@ -2137,4 +2138,4 @@
"{{threshold}}, passing": "{{threshold}}, approvato",
"{{type}} copied": "{{type}} copiato",
"{{value}}x voting balance, locked for {{lock}}x enactment ({{period}} days)": "{{value}} x moltiplicatore di voto, fondi bloccati per {{lock}}x = {{period}} giorni"
}
}
3 changes: 2 additions & 1 deletion packages/apps/public/locales/ru/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1492,6 +1492,7 @@
"https://example.com": "https://primer.com",
"id": "",
"ideal staked": "",
"min active stake": "",
"identity": "личность",
"imminent preimage (proposal already passed)": "неизбежный прообраз (предложение уже одобрено)",
"immortal": "бессмертный",
Expand Down Expand Up @@ -2214,4 +2215,4 @@
"{{threshold}}, passing": "{{threshold}}, проходит",
"{{type}} copied": "",
"{{value}}x voting balance, locked for {{lock}}x enactment ({{period}} days)": "{{value}}x баланс голосования, заблокировано на {{lock}}x ({{period}} дней)"
}
}
57 changes: 0 additions & 57 deletions packages/page-staking/src/Bags/Summary.tsx

This file was deleted.

9 changes: 2 additions & 7 deletions packages/page-staking/src/Bags/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { Button, MarkWarning, Table, ToggleGroup } from '@polkadot/react-compone

import { useTranslation } from '../translate';
import Bag from './Bag';
import Summary from './Summary';
import useBagsList from './useBagsList';
import useBagsNodes from './useBagsNodes';

Expand Down Expand Up @@ -61,11 +60,7 @@ function Bags ({ className, ownStashes }: Props): React.ReactElement<Props> {
);

return (
<div className={className}>
<Summary
bags={bags}
mapOwn={mapOwn}
/>
<>
<Button.Group>
<ToggleGroup
onChange={setFilterIndex}
Expand Down Expand Up @@ -96,7 +91,7 @@ function Bags ({ className, ownStashes }: Props): React.ReactElement<Props> {
/>
))}
</Table>
</div>
</>
);
}

Expand Down
22 changes: 22 additions & 0 deletions packages/page-staking/src/Overview/SpinnerWrap.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2017-2022 @polkadot/app-staking authors & contributors
// SPDX-License-Identifier: Apache-2.0

import React, { JSXElementConstructor, ReactElement } from 'react';
import styled from 'styled-components';

import { Spinner } from '@polkadot/react-components';

interface Props {
check: boolean
children: ReactElement<Props, string | JSXElementConstructor<any>>
}

function SpinnerWrap ({ check, children }: Props): React.ReactElement<Props> {
return check
? children
: (<Spinner noLabel />);
}

export default React.memo(styled(SpinnerWrap)`
margin-top: 1rem;
`);
59 changes: 59 additions & 0 deletions packages/page-staking/src/Overview/SummaryBags.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright 2017-2022 @polkadot/app-staking authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { BN } from '@polkadot/util';

import React, { useMemo } from 'react';

import { Card, CardSummary, SummaryBox } from '@polkadot/react-components';
import { useApi, useCall } from '@polkadot/react-hooks';
import { StakerState } from '@polkadot/react-hooks/types';
import { formatNumber } from '@polkadot/util';

import useBagsList from '../Bags/useBagsList';
import useBagsNodes from '../Bags/useBagsNodes';
import { useTranslation } from '../translate';
import { Section, Title } from './index';
import SpinnerWrap from './SpinnerWrap';

interface Props {
ownStashes?: StakerState[];
}

function SummaryBags ({ ownStashes }: Props) {
const { t } = useTranslation();
const { api } = useApi();
const stashIds = useMemo(
() => ownStashes
? ownStashes.map(({ stashId }) => stashId)
: [],
[ownStashes]
);
const mapOwn = useBagsNodes(stashIds);
const bags = useBagsList();
const total = useCall<BN>(api.query.bagsList.counterForListNodes);

return (
<Card>
<Title>{t<string>('bags')}</Title>
<SummaryBox>
<Section>
<CardSummary label={t<string>('total bags')}>
<SpinnerWrap check={bags}>
{formatNumber(bags?.length)}
</SpinnerWrap>
</CardSummary>
</Section>
<Section>
<CardSummary label={t<string>('total nodes')}>
<SpinnerWrap check={!!mapOwn}>
{formatNumber(total)}
</SpinnerWrap>
</CardSummary>
</Section>
</SummaryBox>
</Card>
);
}

export default SummaryBags;
100 changes: 100 additions & 0 deletions packages/page-staking/src/Overview/SummaryGeneral.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// Copyright 2017-2022 @polkadot/app-staking authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { BN } from '@polkadot/util';

import React, { useMemo } from 'react';

import SummarySession from '@polkadot/app-explorer/SummarySession';
import { Card, CardSummary, SummaryBox } from '@polkadot/react-components';
import { FormatBalance } from '@polkadot/react-query';

import { useTranslation } from '../translate';
import { SortedTargets } from '../types';
import { Section } from './index';
import SpinnerWrap from './SpinnerWrap';

interface Props {
targets: SortedTargets;
}

interface ProgressInfo {
hideValue: true;
total: BN;
value: BN;
}

function getProgressInfo (value?: BN, total?: BN): ProgressInfo | undefined {
return value && total && !total.isZero()
? {
hideValue: true,
total,
value
}
: undefined;
}

function SummaryGeneral ({ targets: { inflation: { idealStake,
inflation,
stakedReturn },
totalIssuance,
totalStaked } }: Props) {
const { t } = useTranslation();

const progressStake = useMemo(
() => getProgressInfo(totalStaked, totalIssuance),
[totalIssuance, totalStaked]
);

return (
<Card withBottomMargin>
<SummaryBox>
<Section>
<SummarySession />
</Section>
<Section>
<CardSummary
label={t<string>('total staked')}
progress={progressStake}
>
<SpinnerWrap check={progressStake}>
<FormatBalance
value={totalStaked}
withSi
/>
</SpinnerWrap>
</CardSummary>
</Section>
<Section
className='media--900'
>
<CardSummary
label={t<string>('ideal staked')}
>
<SpinnerWrap
check={(idealStake > 0) && Number.isFinite(idealStake)}
>
{(idealStake * 100).toFixed(1)}%
</SpinnerWrap>
</CardSummary>
<CardSummary
label={t<string>('inflation')}
>
<SpinnerWrap
check={(inflation > 0) && Number.isFinite(inflation)}
>{inflation.toFixed(1)}%</SpinnerWrap>
</CardSummary>
<CardSummary label={t<string>('returns')}>
<SpinnerWrap
check={totalIssuance && (stakedReturn > 0) && Number.isFinite(stakedReturn)}
>
{stakedReturn.toFixed(1)}%
</SpinnerWrap>
</CardSummary>
</Section>
</SummaryBox>
</Card>
);
}

export default SummaryGeneral;
Loading