diff --git a/package.json b/package.json index ecb3780255f2..8d7d7e2627b4 100644 --- a/package.json +++ b/package.json @@ -10,10 +10,10 @@ "packages/*" ], "resolutions": { - "@polkadot/api": "^0.99.0-beta.3", - "@polkadot/api-contract": "^0.99.0-beta.3", + "@polkadot/api": "^0.99.0-beta.4", + "@polkadot/api-contract": "^0.99.0-beta.4", "@polkadot/keyring": "^1.7.1", - "@polkadot/types": "^0.99.0-beta.3", + "@polkadot/types": "^0.99.0-beta.4", "@polkadot/util": "^1.7.1", "@polkadot/util-crypto": "^1.7.1", "babel-core": "^7.0.0-bridge.0", @@ -34,10 +34,11 @@ "start": "cd packages/apps && webpack --config webpack.config.js" }, "devDependencies": { - "@babel/core": "^7.7.4", - "@babel/runtime": "^7.7.4", - "@polkadot/dev-react": "^0.32.0-beta.16", - "@polkadot/ts": "^0.1.87", + "@babel/core": "^7.7.5", + "@babel/register": "^7.7.4", + "@babel/runtime": "^7.7.5", + "@polkadot/dev-react": "^0.32.0-beta.17", + "@polkadot/ts": "^0.1.88", "autoprefixer": "^9.7.1", "empty": "^0.10.1", "html-loader": "^0.5.5", diff --git a/packages/app-123code/package.json b/packages/app-123code/package.json index 58c41c7d0276..679a8102d514 100644 --- a/packages/app-123code/package.json +++ b/packages/app-123code/package.json @@ -10,7 +10,7 @@ ], "license": "Apache-2.0", "dependencies": { - "@babel/runtime": "^7.7.4", + "@babel/runtime": "^7.7.5", "@polkadot/react-components": "^0.38.0-beta.43" } } diff --git a/packages/app-accounts/package.json b/packages/app-accounts/package.json index 4241526b047f..c7170544e675 100644 --- a/packages/app-accounts/package.json +++ b/packages/app-accounts/package.json @@ -10,9 +10,9 @@ "contributors": [], "license": "Apache-2.0", "dependencies": { - "@babel/runtime": "^7.7.4", + "@babel/runtime": "^7.7.5", "@polkadot/react-components": "^0.38.0-beta.43", - "@polkadot/react-qr": "^0.48.0-beta.0", + "@polkadot/react-qr": "^0.48.0-beta.1", "@types/file-saver": "^2.0.0", "@types/yargs": "^13.0.2", "babel-plugin-module-resolver": "^3.1.1", diff --git a/packages/app-address-book/package.json b/packages/app-address-book/package.json index 9dc0beec531a..2c4aaf1d49f3 100644 --- a/packages/app-address-book/package.json +++ b/packages/app-address-book/package.json @@ -10,7 +10,7 @@ "contributors": [], "license": "Apache-2.0", "dependencies": { - "@babel/runtime": "^7.7.4", + "@babel/runtime": "^7.7.5", "@polkadot/react-components": "^0.38.0-beta.43" } } diff --git a/packages/app-claims/package.json b/packages/app-claims/package.json index dd7237a74278..1900a81f00b0 100644 --- a/packages/app-claims/package.json +++ b/packages/app-claims/package.json @@ -11,7 +11,7 @@ ], "license": "Apache-2.0", "dependencies": { - "@babel/runtime": "^7.7.4", + "@babel/runtime": "^7.7.5", "@polkadot/react-components": "^0.38.0-beta.43" } } diff --git a/packages/app-contracts/package.json b/packages/app-contracts/package.json index 61d0e589c195..f86bf4b0870a 100644 --- a/packages/app-contracts/package.json +++ b/packages/app-contracts/package.json @@ -10,8 +10,8 @@ ], "license": "Apache-2.0", "dependencies": { - "@babel/runtime": "^7.7.4", - "@polkadot/api-contract": "^0.99.0-beta.3", + "@babel/runtime": "^7.7.5", + "@polkadot/api-contract": "^0.99.0-beta.4", "@polkadot/react-components": "^0.38.0-beta.43" } } diff --git a/packages/app-council/package.json b/packages/app-council/package.json index 3404f501f15f..c412539f4537 100644 --- a/packages/app-council/package.json +++ b/packages/app-council/package.json @@ -10,7 +10,7 @@ ], "license": "Apache-2.0", "dependencies": { - "@babel/runtime": "^7.7.4", + "@babel/runtime": "^7.7.5", "@polkadot/react-components": "^0.38.0-beta.43", "@polkadot/react-query": "^0.38.0-beta.43" } diff --git a/packages/app-dashboard/package.json b/packages/app-dashboard/package.json index 4769dd0a1303..56ac101abad8 100644 --- a/packages/app-dashboard/package.json +++ b/packages/app-dashboard/package.json @@ -10,7 +10,7 @@ ], "license": "Apache-2.0", "dependencies": { - "@babel/runtime": "^7.7.4", + "@babel/runtime": "^7.7.5", "@polkadot/apps-routing": "^0.38.0-beta.43", "@polkadot/react-components": "^0.38.0-beta.43" } diff --git a/packages/app-democracy/package.json b/packages/app-democracy/package.json index 1d0561af03f0..36914d70fae4 100644 --- a/packages/app-democracy/package.json +++ b/packages/app-democracy/package.json @@ -10,7 +10,7 @@ ], "license": "Apache-2.0", "dependencies": { - "@babel/runtime": "^7.7.4", + "@babel/runtime": "^7.7.5", "@polkadot/react-components": "^0.38.0-beta.43", "@polkadot/react-query": "^0.38.0-beta.43" } diff --git a/packages/app-explorer/package.json b/packages/app-explorer/package.json index 2feee6101f3d..ab46bc261130 100644 --- a/packages/app-explorer/package.json +++ b/packages/app-explorer/package.json @@ -10,7 +10,7 @@ "contributors": [], "license": "Apache-2.0", "dependencies": { - "@babel/runtime": "^7.7.4", + "@babel/runtime": "^7.7.5", "@polkadot/react-components": "^0.38.0-beta.43" } } diff --git a/packages/app-extrinsics/package.json b/packages/app-extrinsics/package.json index a96f6b92602e..f482174dde73 100644 --- a/packages/app-extrinsics/package.json +++ b/packages/app-extrinsics/package.json @@ -10,7 +10,7 @@ "contributors": [], "license": "Apache-2.0", "dependencies": { - "@babel/runtime": "^7.7.4", + "@babel/runtime": "^7.7.5", "@polkadot/react-components": "^0.38.0-beta.43", "@polkadot/react-params": "^0.38.0-beta.43", "@polkadot/react-signer": "^0.38.0-beta.43" diff --git a/packages/app-generic-asset/package.json b/packages/app-generic-asset/package.json index 0c2894598647..6933cb732aa5 100644 --- a/packages/app-generic-asset/package.json +++ b/packages/app-generic-asset/package.json @@ -10,7 +10,7 @@ ], "license": "Apache-2.0", "dependencies": { - "@babel/runtime": "^7.7.4", + "@babel/runtime": "^7.7.5", "@polkadot/react-components": "^0.38.0-beta.43" } } diff --git a/packages/app-js/package.json b/packages/app-js/package.json index 03303151eef7..4cdb52f732fb 100644 --- a/packages/app-js/package.json +++ b/packages/app-js/package.json @@ -10,7 +10,7 @@ ], "license": "Apache-2.0", "dependencies": { - "@babel/runtime": "^7.7.4", + "@babel/runtime": "^7.7.5", "@polkadot/react-components": "^0.38.0-beta.43", "snappyjs": "^0.6.0" } diff --git a/packages/app-parachains/package.json b/packages/app-parachains/package.json index b5aaa42364d8..b6c89a9101df 100644 --- a/packages/app-parachains/package.json +++ b/packages/app-parachains/package.json @@ -10,7 +10,7 @@ ], "license": "Apache-2.0", "dependencies": { - "@babel/runtime": "^7.7.4", + "@babel/runtime": "^7.7.5", "@polkadot/react-components": "^0.38.0-beta.43", "@polkadot/react-query": "^0.38.0-beta.43" } diff --git a/packages/app-settings/package.json b/packages/app-settings/package.json index eeb0107749b8..cc22cfd8af58 100644 --- a/packages/app-settings/package.json +++ b/packages/app-settings/package.json @@ -10,7 +10,7 @@ ], "license": "Apache-2.0", "dependencies": { - "@babel/runtime": "^7.7.4", + "@babel/runtime": "^7.7.5", "@polkadot/react-components": "^0.38.0-beta.43", "@polkadot/react-query": "^0.38.0-beta.43", "query-string": "^6.8.3" diff --git a/packages/app-staking/package.json b/packages/app-staking/package.json index d555117b8128..8416c29db916 100644 --- a/packages/app-staking/package.json +++ b/packages/app-staking/package.json @@ -10,7 +10,7 @@ ], "license": "Apache-2.0", "dependencies": { - "@babel/runtime": "^7.7.4", + "@babel/runtime": "^7.7.5", "@polkadot/app-explorer": "^0.38.0-beta.43", "@polkadot/react-components": "^0.38.0-beta.43", "@polkadot/react-query": "^0.38.0-beta.43" diff --git a/packages/app-staking/src/Actions/Account/index.tsx b/packages/app-staking/src/Actions/Account/index.tsx index a3667276fbac..6f0aef4f616d 100644 --- a/packages/app-staking/src/Actions/Account/index.tsx +++ b/packages/app-staking/src/Actions/Account/index.tsx @@ -228,7 +228,7 @@ class Account extends React.PureComponent { {nominees && !!nominees.length && (
- {t('Nominating {{count}}', { replace: { count: nominees.length } })} + {t('Nominating ({{count}})', { replace: { count: nominees.length } })} {nominees.map((nomineeId, index): React.ReactNode => ( [], queryLedger?: Option[]): [string, boolean][] | null { @@ -44,17 +47,28 @@ function getStashes (allAccounts: string[], queryBonded?: Option[], q return result; } -function Actions ({ allAccounts, allStashes, className, recentlyOnline, t }: Props): React.ReactElement { +function Actions ({ allStashes, className, isVisible, recentlyOnline, t }: Props): React.ReactElement { const { api } = useApi(); + const { allAccounts } = useAccounts(); const queryBonded = useStream[]>(api.query.staking.bonded.multi as any, [allAccounts]); const queryLedger = useStream[]>(api.query.staking.ledger.multi as any, [allAccounts]); const [isNewStakeOpen, setIsNewStateOpen] = useState(false); - const foundStashes = getStashes(allAccounts, queryBonded, queryLedger); - const stashOptions = allStashes.map((stashId): KeyringSectionOption => - createOption(stashId, () as any) - ); - const isEmpty = !isNewStakeOpen && (!foundStashes || foundStashes.length === 0); + const [foundStashes, setFoundStashes] = useState<[string, boolean][] | null>(null); + const [stashOptions, setStashOptions] = useState([]); + + useEffect((): void => { + setStashOptions( + allStashes.map((stashId): KeyringSectionOption => + createOption(stashId, () as any) + ) + ); + }, [allStashes]); + useEffect((): void => { + setFoundStashes(getStashes(allAccounts, queryBonded, queryLedger)); + }, [allAccounts, queryBonded, queryLedger]); + + const isEmpty = !isNewStakeOpen && (!foundStashes || foundStashes.length === 0); const _toggleNewStake = (): void => setIsNewStateOpen(!isNewStakeOpen); return ( @@ -68,7 +82,7 @@ function Actions ({ allAccounts, allStashes, className, recentlyOnline, t }: Pro onClick={_toggleNewStake} /> } - className={className} + className={`${className} ${!isVisible && 'staking--hidden'}`} emptyText={t('No funds staked yet.')} isEmpty={isEmpty} > diff --git a/packages/app-staking/src/Overview/CurrentList.tsx b/packages/app-staking/src/Overview/CurrentList.tsx index 4c33468cb397..977f048b625f 100644 --- a/packages/app-staking/src/Overview/CurrentList.tsx +++ b/packages/app-staking/src/Overview/CurrentList.tsx @@ -9,8 +9,7 @@ import { ValidatorFilter } from '../types'; import React, { useEffect, useState } from 'react'; import { Dropdown, FilterOverlay, Table } from '@polkadot/react-components'; -import { useApi, useFavorites } from '@polkadot/react-hooks'; -import keyring from '@polkadot/ui-keyring'; +import { useAccounts, useApi, useFavorites } from '@polkadot/react-hooks'; import { STORE_FAVS_BASE } from '../constants'; import translate from '../translate'; @@ -20,6 +19,7 @@ interface Props extends I18nProps { authorsMap: Record; hasQueries: boolean; isIntentions: boolean; + isVisible: boolean; lastAuthors?: string[]; next: string[]; recentlyOnline?: DerivedHeartbeats; @@ -57,15 +57,15 @@ function accountsToString (accounts: AccountId[]): string[] { return accounts.map((accountId): string => accountId.toString()); } -function CurrentList ({ authorsMap, hasQueries, isIntentions, lastAuthors, next, recentlyOnline, stakingOverview, t }: Props): React.ReactElement { +function CurrentList ({ authorsMap, hasQueries, isIntentions, isVisible, lastAuthors, next, recentlyOnline, stakingOverview, t }: Props): React.ReactElement | null { const { isSubstrateV2 } = useApi(); + const { allAccounts } = useAccounts(); const [favorites, toggleFavorite] = useFavorites(STORE_FAVS_BASE); const [filter, setFilter] = useState('all'); - const [myAccounts] = useState(keyring.getAccounts().map(({ address }): string => address)); const [{ elected, validators, waiting }, setFiltered] = useState<{ elected: AccountExtend[]; validators: AccountExtend[]; waiting: AccountExtend[] }>({ elected: [], validators: [], waiting: [] }); useEffect((): void => { - if (stakingOverview) { + if (isVisible && stakingOverview) { const _elected = accountsToString(stakingOverview.currentElected); const _validators = accountsToString(stakingOverview.validators); const validators = filterAccounts(_validators, _elected, favorites, [], stakingOverview.eraPoints); @@ -77,7 +77,7 @@ function CurrentList ({ authorsMap, hasQueries, isIntentions, lastAuthors, next, waiting: filterAccounts(next, [], favorites, _elected) }); } - }, [favorites, next, stakingOverview]); + }, [favorites, isVisible, next, stakingOverview]); const _renderRows = (addresses: AccountExtend[], defaultName: string, withOnline: boolean): React.ReactNode => addresses.map(([address, isElected, isFavorite, points]): React.ReactNode => ( @@ -91,7 +91,7 @@ function CurrentList ({ authorsMap, hasQueries, isIntentions, lastAuthors, next, isFavorite={isFavorite} lastAuthors={lastAuthors} key={address} - myAccounts={myAccounts} + myAccounts={allAccounts} points={points} recentlyOnline={ withOnline @@ -103,7 +103,7 @@ function CurrentList ({ authorsMap, hasQueries, isIntentions, lastAuthors, next, )); return ( -
+
{ +function Summary ({ className, isVisible, next, stakingOverview, style, t }: Props): React.ReactElement { + const { lastBlockAuthors, lastBlockNumber } = useContext(BlockAuthorsContext); + return (
@@ -44,7 +45,7 @@ function Summary ({ className, lastAuthors, lastBlock, next, stakingOverview, st className='validator--Summary-authors' label={t('last block')} > - {lastAuthors && lastAuthors.map((author): React.ReactNode => ( + {lastBlockAuthors?.map((author): React.ReactNode => ( ))} - {lastBlock} + {lastBlockNumber}
diff --git a/packages/app-staking/src/Overview/index.tsx b/packages/app-staking/src/Overview/index.tsx index c2367bf55c7b..7d61734239bd 100644 --- a/packages/app-staking/src/Overview/index.tsx +++ b/packages/app-staking/src/Overview/index.tsx @@ -2,52 +2,35 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. +import { DerivedHeartbeats, DerivedStakingOverview } from '@polkadot/api-derive/types'; import { BareProps } from '@polkadot/react-components/types'; -import { ComponentProps } from '../types'; -import React, { useContext, useEffect, useState } from 'react'; +import React, { useContext } from 'react'; import { useLocation } from 'react-router-dom'; -import { useApi } from '@polkadot/react-hooks'; import { BlockAuthorsContext } from '@polkadot/react-query'; import CurrentList from './CurrentList'; -import Summary from './Summary'; -interface Props extends BareProps, ComponentProps {} +interface Props extends BareProps { + hasQueries: boolean; + isVisible: boolean; + recentlyOnline?: DerivedHeartbeats; + next: string[]; + stakingOverview?: DerivedStakingOverview; +} -export default function Overview ({ allControllers, hasQueries, allStashes, className, recentlyOnline, stakingOverview }: Props): React.ReactElement { - const { isSubstrateV2 } = useApi(); +export default function Overview ({ hasQueries, isVisible, className, recentlyOnline, next, stakingOverview }: Props): React.ReactElement { const { pathname } = useLocation(); - const { byAuthor, lastBlockAuthors, lastBlockNumber } = useContext(BlockAuthorsContext); - const [next, setNext] = useState([]); - const validators = stakingOverview && stakingOverview.validators; + const { byAuthor, lastBlockAuthors } = useContext(BlockAuthorsContext); const isIntentions = pathname !== '/staking'; - useEffect((): void => { - validators && setNext( - isSubstrateV2 - // this is a V2 node currentValidators is a list of stashes - ? allStashes.filter((address): boolean => !validators.includes(address as any)) - // this is a V1 node currentValidators is a list of controllers - : allControllers.filter((address): boolean => !validators.includes(address as any)) - ); - }, [allControllers, allStashes, validators]); - return ( -
- {!isIntentions && ( - - )} +
{ -// if (isValid && value.length !== 0) { -// window.location.hash = `/explorer/query/${value}`; -// } -// }; - -// return ( -// -// -//