diff --git a/packages/extension-polkagate/src/fullscreen/stake/pool/partials/PoolsTable.tsx b/packages/extension-polkagate/src/fullscreen/stake/pool/partials/PoolsTable.tsx index a4db37d8f..c3f788e01 100644 --- a/packages/extension-polkagate/src/fullscreen/stake/pool/partials/PoolsTable.tsx +++ b/packages/extension-polkagate/src/fullscreen/stake/pool/partials/PoolsTable.tsx @@ -4,21 +4,22 @@ /* eslint-disable react/jsx-max-props-per-line */ +import type { ApiPromise } from '@polkadot/api'; +import type { BN } from '@polkadot/util'; +import type { PoolFilter, PoolInfo } from '../../../../util/types'; + import { faExclamationTriangle } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { FilterAltOutlined as FilterIcon, MoreVert as MoreVertIcon, SearchOff as SearchOffIcon, SearchOutlined as SearchOutlinedIcon } from '@mui/icons-material'; import { Divider, FormControlLabel, Grid, LinearProgress, Radio, type SxProps, type Theme, Typography, useTheme } from '@mui/material'; import React, { useCallback, useRef, useState } from 'react'; -import { ApiPromise } from '@polkadot/api'; import Filters from '@polkadot/extension-polkagate/src/popup/staking/pool/stake/joinPool/partials/Filters'; -import { BN } from '@polkadot/util'; import { InputFilter, Progress, ShowBalance } from '../../../../components'; import { useInfo, useStakingConsts, useTranslation } from '../../../../hooks'; import PoolMoreInfo from '../../../../popup/staking/partial/PoolMoreInfo'; import { DEFAULT_POOL_FILTERS } from '../../../../util/constants'; -import type { PoolFilter, PoolInfo } from '../../../../util/types'; interface Props { api?: ApiPromise; @@ -37,7 +38,7 @@ interface Props { setSearchedPools: React.Dispatch>; } -export default function PoolsTable({ address, setSearchedPools, api, numberOfFetchedPools, totalNumberOfPools, pools, poolsToShow, filteredPools, setFilteredPools, selected, setSelected, minHeight, maxHeight = window.innerHeight / 2.4, style }: Props): React.ReactElement { +export default function PoolsTable ({ address, api, filteredPools, maxHeight = window.innerHeight / 2.4, minHeight, numberOfFetchedPools, pools, poolsToShow, selected, setFilteredPools, setSearchedPools, setSelected, style, totalNumberOfPools }: Props): React.ReactElement { const { t } = useTranslation(); const ref = useRef(null); const { chain, decimal, token } = useInfo(address); diff --git a/packages/extension-polkagate/src/hooks/useMinToReceiveRewardsInSolo.ts b/packages/extension-polkagate/src/hooks/useMinToReceiveRewardsInSolo.ts index 38b671458..18d327ace 100644 --- a/packages/extension-polkagate/src/hooks/useMinToReceiveRewardsInSolo.ts +++ b/packages/extension-polkagate/src/hooks/useMinToReceiveRewardsInSolo.ts @@ -8,10 +8,10 @@ import { BN } from '@polkadot/util'; import { useApi, useToken } from '.'; -export default function useMinToReceiveRewardsInSolo(address: string): BN | undefined { +export default function useMinToReceiveRewardsInSolo (address: string): BN | undefined { const api = useApi(address); const token = useToken(address); - const tokenFromApi = api && api.registry.chainTokens[0]; + const tokenFromApi = api?.registry.chainTokens[0]; const [min, setMin] = useState(); @@ -20,7 +20,7 @@ export default function useMinToReceiveRewardsInSolo(address: string): BN | unde return setMin(undefined); } - api.query.staking.minimumActiveStake().then((min) => { + api.query['staking']['minimumActiveStake']().then((min) => { setMin(new BN(min.toString())); }).catch(console.error); }, [api, token, tokenFromApi]); diff --git a/packages/extension-polkagate/src/hooks/usePool.ts b/packages/extension-polkagate/src/hooks/usePool.ts index 6dfae4db1..6cc34cf0f 100644 --- a/packages/extension-polkagate/src/hooks/usePool.ts +++ b/packages/extension-polkagate/src/hooks/usePool.ts @@ -9,9 +9,9 @@ import type { MyPoolInfo } from '../util/types'; import { useCallback, useContext, useEffect, useState } from 'react'; import { FetchingContext } from '../components'; +import { AUTO_MODE } from '../util/constants'; import { isHexToBn } from '../util/utils'; import { useInfo } from '.'; -import { AUTO_MODE } from '../util/constants'; export default function usePool (address?: AccountId | string, id?: number, refresh?: boolean, pool?: MyPoolInfo): MyPoolInfo | null | undefined { const { decimal: currentDecimal, endpoint, formatted, token: currentToken } = useInfo(address); diff --git a/packages/extension-polkagate/src/hooks/usePools.ts b/packages/extension-polkagate/src/hooks/usePools.ts index 62d65b4c1..e4231efc8 100644 --- a/packages/extension-polkagate/src/hooks/usePools.ts +++ b/packages/extension-polkagate/src/hooks/usePools.ts @@ -2,14 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 // @ts-nocheck +import type { ApiPromise } from '@polkadot/api'; import type { DeriveStakingAccount } from '@polkadot/api-derive/types'; import type { Codec } from '@polkadot/types/types'; import type { PoolInfo } from '../util/types'; import { useCallback, useEffect, useState } from 'react'; -import { ApiPromise } from '@polkadot/api'; - import getPoolAccounts from '../util/getPoolAccounts'; import { useApi } from '.'; @@ -34,13 +33,13 @@ const handleInfo = (info: [Codec, Codec, Codec, DeriveStakingAccount][], lastBat } })?.filter((f) => f !== undefined); -type UsePools = { +interface UsePools { incrementalPools: PoolInfo[] | null | undefined; numberOfFetchedPools: number; totalNumberOfPools: number | undefined; } -export default function usePools(address: string): UsePools { +export default function usePools (address: string): UsePools { const api = useApi(address); const [totalNumberOfPools, setTotalNumberOfPools] = useState(); @@ -83,9 +82,9 @@ export default function usePools(address: string): UsePools { const { stashId } = getPoolAccounts(api, poolId); queries.push(Promise.all([ - api.query.nominationPools.metadata(poolId), + api.query['nominationPools']['metadata'](poolId), api.query['nominationPools']['bondedPools'](poolId), - api.query.nominationPools.rewardPools(poolId), + api.query['nominationPools']['rewardPools'](poolId), api.derive.staking.account(stashId) ])); } @@ -102,7 +101,7 @@ export default function usePools(address: string): UsePools { }, []); useEffect(() => { - api && getPools(api); + api && getPools(api).catch(console.error); }, [api, getPools]); return { diff --git a/packages/extension-polkagate/src/util/workers/getStakingConsts.js b/packages/extension-polkagate/src/util/workers/getStakingConsts.js index 0a5fba75e..2981a782b 100644 --- a/packages/extension-polkagate/src/util/workers/getStakingConsts.js +++ b/packages/extension-polkagate/src/util/workers/getStakingConsts.js @@ -32,7 +32,7 @@ async function getStakingConsts (endpoint) { return { bondingDuration, - eraIndex: Number(currentEraIndex?.toString(), '0'), + eraIndex: Number(currentEraIndex?.toString() || '0'), existentialDeposit, maxNominations, maxNominatorRewardedPerValidator,