diff --git a/package.json b/package.json index bfb700c67c..dbf45b8edb 100644 --- a/package.json +++ b/package.json @@ -10,10 +10,10 @@ "packages/*" ], "resolutions": { - "@polkadot/api": "^0.96.0-beta.17", - "@polkadot/api-contract": "^0.96.0-beta.17", + "@polkadot/api": "^0.96.0-beta.18", + "@polkadot/api-contract": "^0.96.0-beta.18", "@polkadot/keyring": "^1.6.1", - "@polkadot/types": "^0.96.0-beta.17", + "@polkadot/types": "^0.96.0-beta.18", "@polkadot/util": "^1.6.1", "@polkadot/util-crypto": "^1.6.1", "babel-core": "^7.0.0-bridge.0", diff --git a/packages/app-contracts/package.json b/packages/app-contracts/package.json index 88508a5747..9d604257e5 100644 --- a/packages/app-contracts/package.json +++ b/packages/app-contracts/package.json @@ -11,7 +11,7 @@ "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.6.3", - "@polkadot/api-contract": "^0.96.0-beta.17", + "@polkadot/api-contract": "^0.96.0-beta.18", "@polkadot/react-components": "^0.37.0-beta.28" } } diff --git a/packages/app-staking/src/Actions/Account/index.tsx b/packages/app-staking/src/Actions/Account/index.tsx index b61db4d061..461b6ac37f 100644 --- a/packages/app-staking/src/Actions/Account/index.tsx +++ b/packages/app-staking/src/Actions/Account/index.tsx @@ -26,8 +26,6 @@ import Unbond from './Unbond'; import Validate from './Validate'; import { u8aToHex, u8aConcat } from '@polkadot/util'; -import { updateOnlineStatus } from '../../util'; - interface Props extends ApiProps, I18nProps { accountId: string; allStashes?: string[]; @@ -105,12 +103,12 @@ class Account extends React.PureComponent { stashId: null }; - public static getDerivedStateFromProps ({ allStashes, recentlyOnline, staking_info }: Props): Pick | null { + public static getDerivedStateFromProps ({ allStashes, staking_info }: Props): Pick | null { if (!staking_info) { return null; } - const { controllerId, nextSessionIds, nominators, online, offline, rewardDestination, sessionIds, stakers, stakingLedger, stashId, validatorPrefs } = staking_info; + const { controllerId, nextSessionIds, nominators, rewardDestination, sessionIds, stakers, stakingLedger, stashId, validatorPrefs } = staking_info; const isStashNominating = nominators && !!nominators.length; const _stashId = toIdString(stashId); const isStashValidating = !!allStashes && !!_stashId && allStashes.includes(_stashId); @@ -126,7 +124,6 @@ class Account extends React.PureComponent { isStashNominating, isStashValidating, nominees: nominators && nominators.map(toIdString), - onlineStatus: updateOnlineStatus(recentlyOnline)(sessionIds || null, { online, offline }), sessionIds: ( nextSessionIds.length ? nextSessionIds diff --git a/packages/app-staking/src/Overview/Address.tsx b/packages/app-staking/src/Overview/Address.tsx index 159df3632e..3e16fae835 100644 --- a/packages/app-staking/src/Overview/Address.tsx +++ b/packages/app-staking/src/Overview/Address.tsx @@ -3,7 +3,7 @@ // of the Apache-2.0 license. See the LICENSE file for details. import { AccountId, Balance, Points } from '@polkadot/types/interfaces'; -import { DerivedStaking, DerivedStakingOnlineStatus, DerivedHeartbeats } from '@polkadot/api-derive/types'; +import { DerivedStaking, DerivedHeartbeats } from '@polkadot/api-derive/types'; import { I18nProps } from '@polkadot/react-components/types'; import { ValidatorFilter } from '../types'; @@ -11,11 +11,10 @@ import BN from 'bn.js'; import React, { useContext, useEffect, useState } from 'react'; import styled from 'styled-components'; import { ApiContext, withCalls, withMulti } from '@polkadot/react-api'; -import { AddressCard, AddressMini, Badge, Icon, OnlineStatus } from '@polkadot/react-components'; +import { AddressCard, AddressMini, Badge, Icon } from '@polkadot/react-components'; import { classes } from '@polkadot/react-components/util'; import keyring from '@polkadot/ui-keyring'; import { formatNumber } from '@polkadot/util'; -import { updateOnlineStatus } from '../util'; import translate from '../translate'; @@ -40,26 +39,15 @@ interface StakingState { isNominatorMe: boolean; isSelected: boolean; nominators: [AccountId, Balance][]; - // stashActive: string | null; - // stashTotal: string | null; sessionId?: string; stashId?: string; } -interface OnlineState { - hasOfflineWarnings: boolean; - onlineStatus: DerivedStakingOnlineStatus; -} - const WITH_VALIDATOR_PREFS = { validatorPayment: true }; function Address ({ address, authorsMap, className, currentElected, defaultName, filter, lastAuthors, points, recentlyOnline, stakingInfo, t, withNominations = true }: Props): React.ReactElement | null { const { isSubstrateV2 } = useContext(ApiContext); const [extraInfo, setExtraInfo] = useState<[React.ReactNode, React.ReactNode][] | undefined>(); - const [{ hasOfflineWarnings, onlineStatus }, setOnlineStatus] = useState({ - hasOfflineWarnings: false, - onlineStatus: {} - }); const [isNominationsOpen, setIsNominationsOpen] = useState(false); const [{ balanceOpts, controllerId, hasNominators, isNominatorMe, isSelected, nominators, sessionId, stashId }, setStakingState] = useState({ balanceOpts: { bonded: true }, @@ -67,8 +55,6 @@ function Address ({ address, authorsMap, className, currentElected, defaultName, isNominatorMe: false, isSelected: false, nominators: [] - // stashActive: null, - // stashTotal: null }); useEffect((): void => { @@ -102,33 +88,19 @@ function Address ({ address, authorsMap, className, currentElected, defaultName, isSelected: !!(_stashId && currentElected && currentElected.includes(_stashId)), nominators, sessionId: nextSessionId && nextSessionId.toString(), - // stashActive: stakingLedger - // ? formatBalance(stakingLedger.active) - // : null, - // stashTotal: stakingLedger - // ? formatBalance(stakingLedger.total) - // : null, stashId: _stashId }); } }, [currentElected, stakingInfo]); - useEffect((): void => { - if (stakingInfo) { - const { online, offline, sessionIds, stashId } = stakingInfo; - const onlineStatus = updateOnlineStatus(recentlyOnline)(sessionIds, { offline, online }); - - setOnlineStatus({ - hasOfflineWarnings: !!(stashId && onlineStatus.offline && onlineStatus.offline.length), - onlineStatus - }); - } - }, [recentlyOnline, stakingInfo]); + const hasActivity = recentlyOnline + ? (recentlyOnline[stashId || ''] && recentlyOnline[stashId || ''].isOnline) || false + : true; if ((filter === 'hasNominators' && !hasNominators) || (filter === 'noNominators' && hasNominators) || - (filter === 'hasWarnings' && !hasOfflineWarnings) || - (filter === 'noWarnings' && hasOfflineWarnings) || + (filter === 'hasWarnings' && !hasActivity) || + (filter === 'noWarnings' && hasActivity) || (filter === 'iNominated' && !isNominatorMe) || (filter === 'nextSet' && !isSelected)) { return null; @@ -182,22 +154,30 @@ function Address ({ address, authorsMap, className, currentElected, defaultName, extraInfo={extraInfo} iconInfo={ <> - {controllerId && onlineStatus && ( - - )} {isSelected && ( } + info={} isTooltip type='next' /> )} + {recentlyOnline && hasActivity && ( + } + isTooltip + type='online' + /> + )} } + isDisabled={!hasActivity} stakingInfo={stakingInfo} value={stashId} withBalance={balanceOpts} diff --git a/packages/app-staking/src/Overview/CurrentList.tsx b/packages/app-staking/src/Overview/CurrentList.tsx index 73619d318d..533ad42373 100644 --- a/packages/app-staking/src/Overview/CurrentList.tsx +++ b/packages/app-staking/src/Overview/CurrentList.tsx @@ -24,7 +24,7 @@ interface Props extends I18nProps { recentlyOnline?: DerivedHeartbeats; } -function renderColumn (addresses: string[], defaultName: string, withPoints: boolean, filter: string, { authorsMap, currentElected, eraPoints, lastAuthors, recentlyOnline }: Props): React.ReactNode { +function renderColumn (addresses: string[], defaultName: string, withOnline: boolean, withPoints: boolean, filter: string, { authorsMap, currentElected, eraPoints, lastAuthors, recentlyOnline }: Props): React.ReactNode { return addresses.map((address, index): React.ReactNode => (
)); } @@ -86,7 +90,7 @@ function CurrentList (props: Props): React.ReactElement { emptyText={t('No addresses found')} headerText={t('validators')} > - {renderColumn(currentValidators, t('validator'), true, filter, props)} + {renderColumn(currentValidators, t('validator'), true, true, filter, props)} { > {(electedFiltered.length !== 0 || nextFiltered.length !== 0) && ( <> - {renderColumn(electedFiltered, t('intention'), false, filter, props)} - {renderColumn(nextFiltered, t('intention'), false, filter, props)} + {renderColumn(electedFiltered, t('intention'), false, false, filter, props)} + {renderColumn(nextFiltered, t('intention'), false, false, filter, props)} )} diff --git a/packages/app-staking/src/util.ts b/packages/app-staking/src/util.ts deleted file mode 100644 index d3b792b794..0000000000 --- a/packages/app-staking/src/util.ts +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2017-2019 @polkadot/app-staking 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 { AccountId } from '@polkadot/types/interfaces'; -import { DerivedStakingOnlineStatus, DerivedHeartbeats } from '@polkadot/api-derive/types'; - -export function updateOnlineStatus (recentlyOnline: DerivedHeartbeats = {}): (sessionIds: AccountId[] | null, onlineStatus: DerivedStakingOnlineStatus) => DerivedStakingOnlineStatus { - return (sessionIds: AccountId[] | null, onlineStatus: DerivedStakingOnlineStatus): DerivedStakingOnlineStatus => { - if (!recentlyOnline || !sessionIds) { - return onlineStatus; - } - - const available = Object.keys(recentlyOnline); - const sessionId = sessionIds.find((sessionId): boolean => available.includes(sessionId.toString())); - - return { - ...onlineStatus, - ...( - sessionId - ? { - online: { - isOnline: recentlyOnline[sessionId.toString()] - } - } - : {} - ) - }; - }; -} diff --git a/packages/react-api/package.json b/packages/react-api/package.json index 39e2ddf73f..56ef617e98 100644 --- a/packages/react-api/package.json +++ b/packages/react-api/package.json @@ -31,7 +31,7 @@ "homepage": "https://github.com/polkadot-js/ui/tree/master/packages/ui-reactive#readme", "dependencies": { "@babel/runtime": "^7.6.3", - "@polkadot/api": "^0.96.0-beta.17", + "@polkadot/api": "^0.96.0-beta.18", "@polkadot/extension-dapp": "^0.14.0-beta.1", "edgeware-node-types": "^1.0.10", "rxjs-compat": "^6.5.3" diff --git a/yarn.lock b/yarn.lock index 0b6b649730..b9183f7722 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2016,45 +2016,45 @@ once "^1.4.0" universal-user-agent "^4.0.0" -"@polkadot/api-contract@^0.96.0-beta.17": - version "0.96.0-beta.17" - resolved "https://registry.yarnpkg.com/@polkadot/api-contract/-/api-contract-0.96.0-beta.17.tgz#1f3465ff8fe4741833bb4489dd9ba68e63e81fa2" - integrity sha512-Y17MlyjmTP1OF42v96kj7ZUS+E9E2Op0z80u8M108Nss8YR28V7AHMh3X2X3PPEW91vk9vjRFxVquRRuVlNt7g== +"@polkadot/api-contract@^0.96.0-beta.18": + version "0.96.0-beta.18" + resolved "https://registry.yarnpkg.com/@polkadot/api-contract/-/api-contract-0.96.0-beta.18.tgz#a4b698e74e23e31d89c3b34098b5a3e0d8bc67ba" + integrity sha512-DS9731ALmw6qN9tMfYYqQxX0q/Ec8g0i2/e7wa1/KOPqbcs1/OC44viwHvOWQ4J2mbikmZGyYnxVbmHtyTggiA== dependencies: "@babel/runtime" "^7.6.3" - "@polkadot/types" "^0.96.0-beta.17" + "@polkadot/types" "^0.96.0-beta.18" -"@polkadot/api-derive@^0.96.0-beta.17": - version "0.96.0-beta.17" - resolved "https://registry.yarnpkg.com/@polkadot/api-derive/-/api-derive-0.96.0-beta.17.tgz#1ffcf15534c91adcadca88cb68f3e8ce6ac94535" - integrity sha512-QzO+26/Z4cSYwBYHsd7/Xq9b//XXR083sa7S9fOmBVeMOYj4rtXmmzzcl4k28byqFvUIT0Izt73m9aw8fSADKQ== +"@polkadot/api-derive@^0.96.0-beta.18": + version "0.96.0-beta.18" + resolved "https://registry.yarnpkg.com/@polkadot/api-derive/-/api-derive-0.96.0-beta.18.tgz#7cb760cf4fad8b9ef790016dc7734b334cbbe80e" + integrity sha512-GYRFV3b23CVmaYKYVyZjU06wMMrBIt1W75nsrWxCERjGvT8V/yJXiYwey4j//uG+yieZeEeT//YSZH7Y0Q8yMQ== dependencies: "@babel/runtime" "^7.6.3" - "@polkadot/api" "^0.96.0-beta.17" - "@polkadot/types" "^0.96.0-beta.17" + "@polkadot/api" "^0.96.0-beta.18" + "@polkadot/types" "^0.96.0-beta.18" -"@polkadot/api-metadata@^0.96.0-beta.17": - version "0.96.0-beta.17" - resolved "https://registry.yarnpkg.com/@polkadot/api-metadata/-/api-metadata-0.96.0-beta.17.tgz#4039943c18dbf7b143e48c2ee95365396e137b05" - integrity sha512-j9JKQuH114RcCSsE2X6NWfjPZgyLRn2plFnc6ZKB6c3rFbfDYwVtazAqaRi/IpOLnFRj+h1Rfapbu1ihz6q8nw== +"@polkadot/api-metadata@^0.96.0-beta.18": + version "0.96.0-beta.18" + resolved "https://registry.yarnpkg.com/@polkadot/api-metadata/-/api-metadata-0.96.0-beta.18.tgz#33bd5fa6955a80b5048a39d2c216885966c6fbc1" + integrity sha512-MTSpIbYdRkoJZSwcajkvPEElSY80FaQD/KitUqkxOD7Shq8WmELUJu7wSVv3wV7kTXWKYDKSjVHTacwWI+owsg== dependencies: "@babel/runtime" "^7.6.3" - "@polkadot/types" "^0.96.0-beta.17" + "@polkadot/types" "^0.96.0-beta.18" "@polkadot/util" "^1.6.1" "@polkadot/util-crypto" "^1.6.1" -"@polkadot/api@^0.96.0-beta.17": - version "0.96.0-beta.17" - resolved "https://registry.yarnpkg.com/@polkadot/api/-/api-0.96.0-beta.17.tgz#ecff2ccd549d16f297683c69ab23fe0f84d1b318" - integrity sha512-E+0wSfUMuQrEotxfqeveqJaWoX+zXBMhHN/HesCdMFTEHcm5wlD7N+tfAY3yg3nzWQkDKlao728Y6fqsnFyKDQ== +"@polkadot/api@^0.96.0-beta.18": + version "0.96.0-beta.18" + resolved "https://registry.yarnpkg.com/@polkadot/api/-/api-0.96.0-beta.18.tgz#d5c56aa825d909d4bfa21acbab33a0b1375527b8" + integrity sha512-1RWNT7srP/IT7bPsTIIvTB5QqFxFixANzTFwZkml7CBMpebBE6CNbXOKWZ68ijZ87Gwo8gr2hmbCIRp2/qeT/g== dependencies: "@babel/runtime" "^7.6.3" - "@polkadot/api-derive" "^0.96.0-beta.17" - "@polkadot/api-metadata" "^0.96.0-beta.17" + "@polkadot/api-derive" "^0.96.0-beta.18" + "@polkadot/api-metadata" "^0.96.0-beta.18" "@polkadot/keyring" "^1.6.1" - "@polkadot/rpc-core" "^0.96.0-beta.17" - "@polkadot/rpc-provider" "^0.96.0-beta.17" - "@polkadot/types" "^0.96.0-beta.17" + "@polkadot/rpc-core" "^0.96.0-beta.18" + "@polkadot/rpc-provider" "^0.96.0-beta.18" + "@polkadot/types" "^0.96.0-beta.18" "@polkadot/util-crypto" "^1.6.1" "@polkadot/dev-react@^0.32.0-beta.12": @@ -2156,10 +2156,10 @@ dependencies: "@babel/runtime" "^7.6.3" -"@polkadot/jsonrpc@^0.96.0-beta.17": - version "0.96.0-beta.17" - resolved "https://registry.yarnpkg.com/@polkadot/jsonrpc/-/jsonrpc-0.96.0-beta.17.tgz#888249f017db65ddda294ef1a7277c67875771a0" - integrity sha512-cPqSjZrMEGYAwoxSyqth/P9EX7l8frWO1psH2AcK8zQs2/7PzGVJHoqMXDfBz541d5mm6egGkJJ1AvHc37Wxvg== +"@polkadot/jsonrpc@^0.96.0-beta.18": + version "0.96.0-beta.18" + resolved "https://registry.yarnpkg.com/@polkadot/jsonrpc/-/jsonrpc-0.96.0-beta.18.tgz#747908b9782377dbe9d2d2b734bee509eaea4075" + integrity sha512-05U2LxTMm+D7kvJ+cQZ9x30ltB9/KoAGZC3VblfDTBaAQTZrJETQFTbPHsV7pPJsTERjboGH4rdO932QEk65/A== dependencies: "@babel/runtime" "^7.6.3" @@ -2197,25 +2197,25 @@ qrcode-generator "^1.4.4" react-qr-reader "^2.2.1" -"@polkadot/rpc-core@^0.96.0-beta.17": - version "0.96.0-beta.17" - resolved "https://registry.yarnpkg.com/@polkadot/rpc-core/-/rpc-core-0.96.0-beta.17.tgz#474718a9f77661f0fecd46042666cefa6251f8cd" - integrity sha512-d50fmHsz62TB87k6pTUQKyNUFHp+k5Mts7VsmI0AxCWTyfwfeWVJM7TBqSIeHNcs6nW9BB1wwWvgoHUXLOOT6Q== +"@polkadot/rpc-core@^0.96.0-beta.18": + version "0.96.0-beta.18" + resolved "https://registry.yarnpkg.com/@polkadot/rpc-core/-/rpc-core-0.96.0-beta.18.tgz#660ddeb2e4bb29fd80a6134feb4ee3010ab95bd1" + integrity sha512-395NeQ0cLv3DHKRrP5QHgHmGN5Bt+yduvWqvnDr3zy4oM6I7pJV7pVJVF1n3Nv7VMWgDJCbNucZyh8Qf5in09w== dependencies: "@babel/runtime" "^7.6.3" - "@polkadot/jsonrpc" "^0.96.0-beta.17" - "@polkadot/rpc-provider" "^0.96.0-beta.17" - "@polkadot/types" "^0.96.0-beta.17" + "@polkadot/jsonrpc" "^0.96.0-beta.18" + "@polkadot/rpc-provider" "^0.96.0-beta.18" + "@polkadot/types" "^0.96.0-beta.18" "@polkadot/util" "^1.6.1" rxjs "^6.5.3" -"@polkadot/rpc-provider@^0.96.0-beta.17": - version "0.96.0-beta.17" - resolved "https://registry.yarnpkg.com/@polkadot/rpc-provider/-/rpc-provider-0.96.0-beta.17.tgz#3c3bf2b94f22993971e26b8c361c30b4deaf010e" - integrity sha512-zrIk4bJUbec9WCFu4Ry/qXoR9wUe2ggEcYSMDuvbCZZaKSpNzk2/qBBcAzPriLMUy0Kykb23xjnxoQehj+Wvag== +"@polkadot/rpc-provider@^0.96.0-beta.18": + version "0.96.0-beta.18" + resolved "https://registry.yarnpkg.com/@polkadot/rpc-provider/-/rpc-provider-0.96.0-beta.18.tgz#8cb27ce6bbbeebb61d98855ce83a87f89af775c3" + integrity sha512-/EbVpD8F+3SuZHMeH5Fd2fEJoRCUmLeyb7bXuN4knsxE6ujAIIrTSWsryDENTSyJUm/fxNLyjLDuhX8xm68DCA== dependencies: "@babel/runtime" "^7.6.3" - "@polkadot/api-metadata" "^0.96.0-beta.17" + "@polkadot/api-metadata" "^0.96.0-beta.18" "@polkadot/util" "^1.6.1" "@polkadot/util-crypto" "^1.6.1" "@types/nock" "^11.1.0" @@ -2230,10 +2230,10 @@ dependencies: "@types/chrome" "^0.0.91" -"@polkadot/types@^0.96.0-beta.17": - version "0.96.0-beta.17" - resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-0.96.0-beta.17.tgz#5b5804d803d48f0774e89a9b14bb30226c045aca" - integrity sha512-9iV8H1bJbFbIyxDZLLbZ4buVG1weHksuvM8AzEWu9BxPgNGigUrxoRLaUC02qjmPKPfhwCQ4Q2XS8NfaoPiCcA== +"@polkadot/types@^0.96.0-beta.18": + version "0.96.0-beta.18" + resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-0.96.0-beta.18.tgz#245c5f0bae4ca5c20fc50cef92994e39197652f1" + integrity sha512-8Aq2ZWyoQBXvtJcnkJY1cMfOfZUYJN+GpYvN1V1K/E6D/s+crz+ZP4sdqSe3716BO9oj8trpkgkMUFIm2fhW/A== dependencies: "@babel/runtime" "^7.6.3" "@polkadot/util" "^1.6.1"