From c9d9b5022d235c1346a1c851e5cc9224e76a3185 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Sat, 28 Nov 2020 14:29:12 +0100 Subject: [PATCH] Bump API (#4088) --- package.json | 6 +- .../apps/public/locales/ar/translation.json | 4 +- .../apps/public/locales/en/app-staking.json | 4 +- .../apps/public/locales/fr/translation.json | 4 +- .../apps/public/locales/id/translation.json | 4 +- .../apps/public/locales/it/translation.json | 4 +- .../apps/public/locales/ko/translation.json | 4 +- .../apps/public/locales/zh/translation.json | 4 +- packages/apps/src/Menu/ChainInfo.tsx | 4 +- packages/page-contracts/package.json | 2 +- packages/page-staking/src/Filtering.tsx | 2 - packages/page-staking/src/Ledgend.tsx | 2 +- .../page-staking/src/Overview/CurrentList.tsx | 3 + .../page-staking/src/Targets/Validator.tsx | 10 +- packages/page-staking/src/Targets/index.tsx | 41 ++++-- packages/react-api/package.json | 4 +- packages/react-components/src/Table/index.tsx | 4 +- yarn.lock | 126 +++++++++--------- 18 files changed, 132 insertions(+), 100 deletions(-) diff --git a/package.json b/package.json index 6650bddd22..6ee6cdb436 100644 --- a/package.json +++ b/package.json @@ -12,11 +12,11 @@ "packages/*" ], "resolutions": { - "@polkadot/api": "^2.8.2-3", - "@polkadot/api-contract": "^2.8.2-3", + "@polkadot/api": "^2.8.3-2", + "@polkadot/api-contract": "^2.8.3-2", "@polkadot/keyring": "^4.2.1", "@polkadot/networks": "^4.2.1", - "@polkadot/types": "^2.8.2-3", + "@polkadot/types": "^2.8.3-2", "@polkadot/util": "^4.2.1", "@polkadot/util-crypto": "^4.2.1", "@polkadot/wasm-crypto": "^2.0.1", diff --git a/packages/apps/public/locales/ar/translation.json b/packages/apps/public/locales/ar/translation.json index 339da7764e..b5eff5489d 100644 --- a/packages/apps/public/locales/ar/translation.json +++ b/packages/apps/public/locales/ar/translation.json @@ -1004,7 +1004,7 @@ "launch period": "فترة الإطلاق", "legal name": "الإسم القانوني", "lifetime": "مدى الحياة", - "limit to elected": "الاقتصار على المنتخبين", + "only elected": "الاقتصار على المنتخبين", "lng.detect": "(لغة المتصفح الافتراضية (الكشف التلقائي", "lock expired": "انتهت صلاحية القفل", "locked": "مقفل", @@ -1300,4 +1300,4 @@ "{{threshold}}, not passing": "سقف}}، لا يتم تمريره}}", "{{threshold}}, passing": "سقف}}، يتم تمريره}}", "{{value}}x voting balance, locked for {{lock}}x enactment ({{period}} days)": "({{قفل}} (تاريخ إصدار {{أيام}}x رصيد التصويت، مقفل لـ x {{قيمة }}" -} \ No newline at end of file +} diff --git a/packages/apps/public/locales/en/app-staking.json b/packages/apps/public/locales/en/app-staking.json index 2971243e6d..91284e0a80 100644 --- a/packages/apps/public/locales/en/app-staking.json +++ b/packages/apps/public/locales/en/app-staking.json @@ -170,7 +170,7 @@ "last block": "last block", "last reward": "last reward", "limit single operator exposure": "limit single operator exposure", - "limit to elected": "limit to elected", + "only elected": "only elected", "lowest / avg staked": "lowest / avg staked", "next": "next", "nominated accounts": "nominated accounts", @@ -221,4 +221,4 @@ "{{currency}} slashed": "{{currency}} slashed", "{{currency}} total": "{{currency}} total", "{{days}} days": "{{days}} days" -} \ No newline at end of file +} diff --git a/packages/apps/public/locales/fr/translation.json b/packages/apps/public/locales/fr/translation.json index f94cb6dbf7..80ae37d3dc 100644 --- a/packages/apps/public/locales/fr/translation.json +++ b/packages/apps/public/locales/fr/translation.json @@ -1138,7 +1138,7 @@ "launch period": "période de lancement", "legal name": "nom légal", "lifetime": "durée de vie", - "limit to elected": "Limiter aux élus", + "only elected": "Limiter aux élus", "lng.detect": "Language du navigateur (détection automatique)", "lock expired": "verrouillage expiré", "locked": "verrouillé", @@ -1519,4 +1519,4 @@ "{{threshold}}, not passing": "{{seuil} }, ne dépassant pas", "{{threshold}}, passing": "{{seuil}}, passant", "{{value}}x voting balance, locked for {{lock}}x enactment ({{period}} days)": "{{value}} x solde de vote, verrouillé pendant {{lock}} x décret ({{period}} jours)" -} \ No newline at end of file +} diff --git a/packages/apps/public/locales/id/translation.json b/packages/apps/public/locales/id/translation.json index 84f4d099ba..1dba03f668 100644 --- a/packages/apps/public/locales/id/translation.json +++ b/packages/apps/public/locales/id/translation.json @@ -1107,7 +1107,7 @@ "launch period": "periode peluncuran", "legal name": "nama resmi", "lifetime": "seumur hidup", - "limit to elected": "batas untuk dipilih", + "only elected": "batas untuk dipilih", "lng.detect": "Default bahasa browser (otomatis-deteksi)", "lock expired": "kunci kadaluarsa", "locked": "terkunci", @@ -1452,4 +1452,4 @@ "{{threshold}}, not passing": "{{threshold}}, tidak melewati", "{{threshold}}, passing": "{{threshold}}, melewati", "{{value}}x voting balance, locked for {{lock}}x enactment ({{period}} days)": "{{value}}x memilih saldo, terkunci untuk {{lock}}x berlaku ({{period}} hari)" -} \ No newline at end of file +} diff --git a/packages/apps/public/locales/it/translation.json b/packages/apps/public/locales/it/translation.json index bf791005ba..a7d5bfa053 100644 --- a/packages/apps/public/locales/it/translation.json +++ b/packages/apps/public/locales/it/translation.json @@ -1090,7 +1090,7 @@ "launch period": "finestra di voto", "legal name": "nome legale", "lifetime": "perpetuo", - "limit to elected": "mostra validator eletti (attivi)", + "only elected": "mostra validator eletti (attivi)", "lng.detect": "Lingua del browser predefinita (rilevamento automatico)", "lock expired": "vincolo terminato", "locked": "bloccati/riservati", @@ -1431,4 +1431,4 @@ "{{threshold}}, not passing": "{{threshold}}, respinta", "{{threshold}}, passing": "{{threshold}}, approvato", "{{value}}x voting balance, locked for {{lock}}x enactment ({{period}} days)": "{{value}} x moltiplicatore di voto, fondi bloccati per {{lock}}x = {{period}} giorni" -} \ No newline at end of file +} diff --git a/packages/apps/public/locales/ko/translation.json b/packages/apps/public/locales/ko/translation.json index 0406d72533..0bcac506b4 100644 --- a/packages/apps/public/locales/ko/translation.json +++ b/packages/apps/public/locales/ko/translation.json @@ -1104,7 +1104,7 @@ "launch period": "시작 기간", "legal name": "법정 이름", "lifetime": "일생", - "limit to elected": "선출된 자로 제한하다", + "only elected": "선출된 자로 제한하다", "lng.detect": "디폴트 브라우저 언어(자동 검색)", "lock expired": "록이 만료됐습니다", "locked": "잠겼습니다", @@ -1479,4 +1479,4 @@ "{{threshold}}, not passing": "{{threshold}}, 통과되지 않았습니다", "{{threshold}}, passing": "{{threshold}}, 통과되었습니다", "{{value}}x voting balance, locked for {{lock}}x enactment ({{period}} days)": "{{value}}x 투표 발란스, 잠금 {{lock}}x제정 ({{period}} days)" -} \ No newline at end of file +} diff --git a/packages/apps/public/locales/zh/translation.json b/packages/apps/public/locales/zh/translation.json index 3b4953e444..6cda4fbe67 100644 --- a/packages/apps/public/locales/zh/translation.json +++ b/packages/apps/public/locales/zh/translation.json @@ -1076,7 +1076,7 @@ "launch period": "启动期", "legal name": "法定名称", "lifetime": "生命周期", - "limit to elected": "仅限于当选的", + "only elected": "仅限于当选的", "lng.detect": "默认浏览器语言 (自动检测)", "lock expired": "锁定已过期", "locked": "锁定", @@ -1379,4 +1379,4 @@ "{{threshold}}, not passing": "{{threshold}},没有通过", "{{threshold}}, passing": "{{threshold}}, 通过", "{{value}}x voting balance, locked for {{lock}}x enactment ({{period}} days)": "{{value}}x投票余额,锁定 {{lock}}x 执行 ({{period}} days)" -} \ No newline at end of file +} diff --git a/packages/apps/src/Menu/ChainInfo.tsx b/packages/apps/src/Menu/ChainInfo.tsx index 4e75f2a66b..a7cac4dba0 100644 --- a/packages/apps/src/Menu/ChainInfo.tsx +++ b/packages/apps/src/Menu/ChainInfo.tsx @@ -18,8 +18,8 @@ interface Props { function ChainInfo ({ className }: Props): React.ReactElement { const { t } = useTranslation(); - const { api } = useApi(); - const runtimeVersion = useCall(api.rpc.state.subscribeRuntimeVersion); + const { api, isApiReady } = useApi(); + const runtimeVersion = useCall(isApiReady && api.rpc.state.subscribeRuntimeVersion); const { ipnsChain } = useIpfs(); const [isEndpointsVisible, toggleEndpoints] = useToggle(); const canToggle = !ipnsChain; diff --git a/packages/page-contracts/package.json b/packages/page-contracts/package.json index 2f0f187eb8..9578d992aa 100644 --- a/packages/page-contracts/package.json +++ b/packages/page-contracts/package.json @@ -10,6 +10,6 @@ "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.12.5", - "@polkadot/api-contract": "^2.8.2-3" + "@polkadot/api-contract": "^2.8.3-2" } } diff --git a/packages/page-staking/src/Filtering.tsx b/packages/page-staking/src/Filtering.tsx index eacad814a0..8858037c6d 100644 --- a/packages/page-staking/src/Filtering.tsx +++ b/packages/page-staking/src/Filtering.tsx @@ -8,7 +8,6 @@ import { useApi } from '@polkadot/react-hooks'; import { isString } from '@polkadot/util'; import { useTranslation } from './translate'; -import Ledgend from './Ledgend'; interface Props { children?: React.ReactNode; @@ -52,7 +51,6 @@ function Filtering ({ children, className, nameFilter, setNameFilter, setWithIde value={withIdentity} /> )} - ); diff --git a/packages/page-staking/src/Ledgend.tsx b/packages/page-staking/src/Ledgend.tsx index 99f05f21df..306109baa9 100644 --- a/packages/page-staking/src/Ledgend.tsx +++ b/packages/page-staking/src/Ledgend.tsx @@ -64,7 +64,7 @@ function Ledgend ({ className }: Props): React.ReactElement { export default React.memo(styled(Ledgend)` font-size: 0.85rem; - padding: 1rem 0.5rem 0.5rem; + padding: 1rem 0.5rem; text-align: center; .ui--Badge { diff --git a/packages/page-staking/src/Overview/CurrentList.tsx b/packages/page-staking/src/Overview/CurrentList.tsx index 69f14aefd9..dca624da1d 100644 --- a/packages/page-staking/src/Overview/CurrentList.tsx +++ b/packages/page-staking/src/Overview/CurrentList.tsx @@ -13,6 +13,7 @@ import { useApi, useCall, useLoadingDelay } from '@polkadot/react-hooks'; import { BlockAuthorsContext } from '@polkadot/react-query'; import Filtering from '../Filtering'; +import Ledgend from '../Ledgend'; import { useTranslation } from '../translate'; import Address from './Address'; @@ -179,6 +180,7 @@ function CurrentList ({ favorites, hasQueries, isIntentions, next, stakingOvervi /> } header={headerWaitingRef.current} + ledgend={} > {isLoading ? undefined : _renderRows(elected, false).concat(_renderRows(waiting, false))} @@ -195,6 +197,7 @@ function CurrentList ({ favorites, hasQueries, isIntentions, next, stakingOvervi /> } header={headerActiveRef.current} + ledgend={} > {isLoading ? undefined : _renderRows(validators, true)} diff --git a/packages/page-staking/src/Targets/Validator.tsx b/packages/page-staking/src/Targets/Validator.tsx index 8af613e15f..362faacce7 100644 --- a/packages/page-staking/src/Targets/Validator.tsx +++ b/packages/page-staking/src/Targets/Validator.tsx @@ -30,6 +30,8 @@ interface Props { toggleSelected: (accountId: string) => void; withElected: boolean; withIdentity: boolean; + withoutComm: boolean; + withoutOver: boolean; } function checkIdentity (api: ApiPromise, accountInfo: DeriveAccountInfo): [boolean, string | null] { @@ -61,7 +63,7 @@ function checkIdentity (api: ApiPromise, accountInfo: DeriveAccountInfo): [boole return [hasIdentity, parentId]; } -function Validator ({ allSlashes, canSelect, filterName, info, isNominated, isSelected, toggleFavorite, toggleSelected, withElected, withIdentity }: Props): React.ReactElement | null { +function Validator ({ allSlashes, canSelect, filterName, info, isNominated, isSelected, toggleFavorite, toggleSelected, withElected, withIdentity, withoutComm, withoutOver }: Props): React.ReactElement | null { const { t } = useTranslation(); const { api } = useApi(); const accountInfo = useCall(api.derive.accounts.info, [info.accountId]); @@ -99,7 +101,11 @@ function Validator ({ allSlashes, canSelect, filterName, info, isNominated, isSe [info.key, toggleSelected] ); - if (!isVisible || (withElected && !info.isElected)) { + const nonToggled = (withElected && !info.isElected) || + (withoutComm && info.commissionPer >= 20) || + (withoutOver && api.consts.staking?.maxNominatorRewardedPerValidator?.lten(info.numNominators)); + + if (!isVisible || (!info.isFavorite && nonToggled)) { return null; } diff --git a/packages/page-staking/src/Targets/index.tsx b/packages/page-staking/src/Targets/index.tsx index 819f60218d..bf711c8c8d 100644 --- a/packages/page-staking/src/Targets/index.tsx +++ b/packages/page-staking/src/Targets/index.tsx @@ -13,6 +13,7 @@ import { useApi, useAvailableSlashes } from '@polkadot/react-hooks'; import ElectionBanner from '../ElectionBanner'; import Filtering from '../Filtering'; +import Ledgend from '../Ledgend'; import { MAX_NOMINATIONS } from '../constants'; import { useTranslation } from '../translate'; import Nominate from './Nominate'; @@ -30,8 +31,10 @@ interface Props { } interface Flags { - withIdentity: boolean; withGroup: boolean; + withIdentity: boolean; + withoutComm: boolean; + withoutOver: boolean; } interface SortState { @@ -70,19 +73,22 @@ function extractNominees (ownNominators: StakerState[] = []): string[] { return myNominees; } -function selectProfitable (maxPaid: BN |undefined, list: ValidatorInfo[], { withGroup, withIdentity }: Flags): string[] { +function selectProfitable (maxPaid: BN |undefined, list: ValidatorInfo[], { withGroup, withIdentity, withoutComm, withoutOver }: Flags): string[] { const parentIds: (string | null)[] = []; const result: string[] = []; for (let i = 0; i < list.length && result.length < MAX_NOMINATIONS; i++) { - const { hasIdentity, isElected, isFavorite, key, numNominators, parentId, rewardPayout } = list[i]; + const { commissionPer, hasIdentity, isElected, isFavorite, key, numNominators, parentId, rewardPayout } = list[i]; if ( (!withIdentity || hasIdentity) && (isElected || isFavorite) && !rewardPayout.isZero() && - (!maxPaid || maxPaid.gtn(numNominators)) && - (!withGroup || (isFavorite || !parentIds.includes(parentId))) + (isFavorite || ( + (!withGroup || !parentIds.includes(parentId)) && + (!withoutComm || commissionPer < 20) && + (!withoutOver || !maxPaid || maxPaid.gtn(numNominators)) + )) ) { result.push(key); parentId && parentIds.push(parentId); @@ -102,6 +108,8 @@ function Targets ({ className = '', isInElection, ownStashes, targets: { avgStak const [withElected, setWithElected] = useState(false); const [withGroup, setWithGroup] = useState(true); const [withIdentity, setWithIdentity] = useState(false); + const [withoutComm, setWithoutComm] = useState(true); + const [withoutOver, setWithoutOver] = useState(true); const [{ sortBy, sortFromMax }, setSortBy] = useState({ sortBy: 'rankOverall', sortFromMax: true }); const [sorted, setSorted] = useState(); @@ -140,9 +148,9 @@ function Targets ({ className = '', isInElection, ownStashes, targets: { avgStak () => setSelected(selectProfitable( api.consts.staking?.maxNominatorRewardedPerValidator, validators || [], - { withGroup, withIdentity } + { withGroup, withIdentity, withoutComm, withoutOver } )), - [api, validators, withGroup, withIdentity] + [api, validators, withGroup, withIdentity, withoutComm, withoutOver] ); const labelsRef = useRef({ @@ -193,14 +201,26 @@ function Targets ({ className = '', isInElection, ownStashes, targets: { avgStak /> ('limit to elected')} + label={t('no 20%+ comm')} + onChange={setWithoutComm} + value={withoutComm} + /> + ('no oversubscribed')} + onChange={setWithoutOver} + value={withoutOver} + /> + ('only elected')} onChange={setWithElected} value={withElected} /> ) - ), [calcWith, setCalcWith, nameFilter, sorted, t, withElected, withGroup, withIdentity]); + ), [calcWith, setCalcWith, nameFilter, sorted, t, withElected, withGroup, withIdentity, withoutComm, withoutOver]); return (
@@ -230,6 +250,7 @@ function Targets ({ className = '', isInElection, ownStashes, targets: { avgStak empty={sorted && t('No active validators to check')} filter={filter} header={header} + ledgend={} > {validators && sorted && (validators.length === sorted.length) && sorted.map((index): React.ReactNode => )} diff --git a/packages/react-api/package.json b/packages/react-api/package.json index 05bf94e9a4..6e536cf608 100644 --- a/packages/react-api/package.json +++ b/packages/react-api/package.json @@ -20,8 +20,8 @@ "homepage": "https://github.com/polkadot-js/apps/tree/master/packages/react-api#readme", "dependencies": { "@babel/runtime": "^7.12.5", - "@polkadot/api": "^2.8.2-3", - "@polkadot/extension-dapp": "^0.35.0-beta.54", + "@polkadot/api": "^2.8.3-2", + "@polkadot/extension-dapp": "^0.35.0-beta.56", "rxjs-compat": "^6.6.3" } } diff --git a/packages/react-components/src/Table/index.tsx b/packages/react-components/src/Table/index.tsx index 9e40848f5a..cda47b9ba8 100644 --- a/packages/react-components/src/Table/index.tsx +++ b/packages/react-components/src/Table/index.tsx @@ -17,6 +17,7 @@ interface TableProps { footer?: React.ReactNode; header?: [React.ReactNode?, string?, number?, (() => void)?][]; isFixed?: boolean; + ledgend?: React.ReactNode; } function extractKids (children: React.ReactNode): [boolean, React.ReactNode] { @@ -30,11 +31,12 @@ function extractKids (children: React.ReactNode): [boolean, React.ReactNode] { return [isEmpty, isEmpty ? null : kids]; } -function Table ({ children, className = '', empty, emptySpinner, filter, footer, header, isFixed }: TableProps): React.ReactElement { +function Table ({ children, className = '', empty, emptySpinner, filter, footer, header, isFixed, ledgend }: TableProps): React.ReactElement { const [isEmpty, kids] = extractKids(children); return (
+ {ledgend}