Move pools location (adjusted interface) (#8935)

* Move pools location (adjusted interface)

* Adjust type import
This commit is contained in:
Jaco 2023-02-03 20:47:37 +02:00 committed by GitHub
parent 4610db1c7b
commit 1ad10e61c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 58 additions and 32 deletions

View File

@ -2,8 +2,8 @@
// SPDX-License-Identifier: Apache-2.0
import type { DeriveSessionProgress, DeriveUnlocking } from '@polkadot/api-derive/types';
import type { PoolInfo } from '@polkadot/app-staking2/Pools/types';
import type { PalletNominationPoolsPoolMember, PalletNominationPoolsPoolRoles } from '@polkadot/types/lookup';
import type { PoolInfo } from '../../Pools/types';
import type { SortedTargets } from '../../types';
import React, { useCallback, useMemo } from 'react';

View File

@ -5,12 +5,12 @@ import type { BN } from '@polkadot/util';
import React, { useRef, useState } from 'react';
import useAmountError from '@polkadot/app-staking2/Pools/useAmountError';
import { Dropdown, InputBalance, Modal, TxButton } from '@polkadot/react-components';
import { useApi } from '@polkadot/react-hooks';
import { BalanceFree } from '@polkadot/react-query';
import { BN_ZERO } from '@polkadot/util';
import useAmountError from '../../Pools/useAmountError';
import { useTranslation } from '../../translate';
import PoolInfo from '../partials/PoolInfo';

View File

@ -8,7 +8,8 @@ import type { SortedTargets } from '../../types';
import React from 'react';
import usePoolInfo from '../../Pools/usePoolInfo';
import usePoolInfo from '@polkadot/app-staking2/Pools/usePoolInfo';
import Account from './Account';
interface Props {

View File

@ -2,8 +2,9 @@
// SPDX-License-Identifier: Apache-2.0
import type { DeriveSessionProgress } from '@polkadot/api-derive/types';
import type { OwnPool } from '@polkadot/app-staking2/Pools/types';
import type { PalletStakingUnappliedSlash } from '@polkadot/types/lookup';
import type { OwnPool, SortedTargets } from '../types';
import type { SortedTargets } from '../types';
import React, { useRef } from 'react';

View File

@ -3,8 +3,9 @@
import '@polkadot/api-augment';
import type { OwnPool } from '@polkadot/app-staking2/Pools/types';
import type { StakerState } from '@polkadot/react-hooks/types';
import type { OwnPool, SortedTargets } from '../types';
import type { SortedTargets } from '../types';
import React, { useMemo, useRef, useState } from 'react';

View File

@ -3,8 +3,8 @@
import type { TFunction } from 'i18next';
import type { DeriveStakerReward } from '@polkadot/api-derive/types';
import type { OwnPool } from '@polkadot/app-staking2/Pools/types';
import type { StakerState } from '@polkadot/react-hooks/types';
import type { OwnPool } from '../types';
import type { PayoutStash, PayoutValidator } from './types';
import React, { useMemo, useRef, useState } from 'react';

View File

@ -11,6 +11,8 @@ import { Route, Switch } from 'react-router';
import { useLocation } from 'react-router-dom';
import styled from 'styled-components';
import Pools from '@polkadot/app-staking2/Pools';
import useOwnPools from '@polkadot/app-staking2/Pools/useOwnPools';
import { Tabs } from '@polkadot/react-components';
import { useAccounts, useApi, useAvailableSlashes, useCall, useCallMulti, useFavorites, useOwnStashInfos } from '@polkadot/react-hooks';
import { isFunction } from '@polkadot/util';
@ -19,13 +21,11 @@ import Actions from './Actions';
import Bags from './Bags';
import { STORE_FAVS_BASE } from './constants';
import Payouts from './Payouts';
import Pools from './Pools';
import Query from './Query';
import Slashes from './Slashes';
import Targets from './Targets';
import { useTranslation } from './translate';
import useNominations from './useNominations';
import useOwnPools from './useOwnPools';
import useSortedTargets from './useSortedTargets';
import Validators from './Validators';

View File

@ -2,9 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import type { Inflation } from '@polkadot/react-hooks/types';
import type { u32 } from '@polkadot/types';
import type { AccountId, Balance, BlockNumber, EraIndex, Exposure, Hash, SessionIndex, ValidatorPrefs, ValidatorPrefsTo196 } from '@polkadot/types/interfaces';
import type { PalletNominationPoolsPoolMember } from '@polkadot/types/lookup';
import type { BN } from '@polkadot/util';
export type Nominators = Record<string, string[]>;
@ -97,17 +95,3 @@ export interface SortedTargets {
validatorIds?: string[];
waitingIds?: string[];
}
export interface PoolAccounts {
rewardId: string;
stashId: string;
}
export interface OwnPoolBase {
members: Record<string, PalletNominationPoolsPoolMember>;
poolId: u32;
}
export interface OwnPool extends OwnPoolBase, PoolAccounts {
// nothing additional, only combined
}

View File

@ -2,8 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import type { BN } from '@polkadot/util';
import type { OwnPool } from '../types';
import type { Params } from './types';
import type { OwnPool, Params } from './types';
import React, { useMemo, useRef, useState } from 'react';

View File

@ -1,12 +1,13 @@
// Copyright 2017-2023 @polkadot/app-staking authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { OwnPool } from '../types';
import type { OwnPool } from './types';
import React from 'react';
import Pools from './Pools';
import Summary from './Summary';
import useOwnPools from './useOwnPools';
import useParams from './useParams';
import usePoolIds from './usePoolIds';
@ -15,8 +16,9 @@ interface Props {
ownPools?: OwnPool[];
}
function NominationPools ({ className, ownPools }: Props): React.ReactElement<Props> {
function NominationPools ({ className, ownPools: ownPoolProp }: Props): React.ReactElement<Props> {
const ids = usePoolIds();
const ownPools = useOwnPools();
const params = useParams();
return (
@ -27,7 +29,7 @@ function NominationPools ({ className, ownPools }: Props): React.ReactElement<Pr
/>
<Pools
ids={ids}
ownPools={ownPools}
ownPools={ownPools || ownPoolProp}
params={params}
/>
</div>

View File

@ -1,9 +1,23 @@
// Copyright 2017-2023 @polkadot/app-staking authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { u32 } from '@polkadot/types';
import type { PalletNominationPoolsBondedPoolInner, PalletNominationPoolsPoolMember, PalletNominationPoolsRewardPool } from '@polkadot/types/lookup';
import type { BN } from '@polkadot/util';
import type { PoolAccounts } from '../types';
export interface PoolAccounts {
rewardId: string;
stashId: string;
}
export interface OwnPoolBase {
members: Record<string, PalletNominationPoolsPoolMember>;
poolId: u32;
}
export interface OwnPool extends OwnPoolBase, PoolAccounts {
// nothing additional, only combined
}
export interface Params {
lastPoolId: BN;

View File

@ -11,7 +11,7 @@ import { useMemo } from 'react';
import { createNamedHook, useApi, useCallMulti } from '@polkadot/react-hooks';
import { BN_ZERO, bnMax } from '@polkadot/util';
import usePoolAccounts from '../usePoolAccounts';
import usePoolAccounts from './usePoolAccounts';
const OPT_MULTI = {
defaultValue: null,

View File

@ -8,16 +8,33 @@ import { Route, Switch } from 'react-router';
import { Tabs } from '@polkadot/react-components';
import { useApi, useFavorites } from '@polkadot/react-hooks';
import { isFunction } from '@polkadot/util';
import { STORE_FAVS_BASE } from './constants';
import Pools from './Pools';
import { useTranslation } from './translate';
import { clearCache } from './useCache';
import useSessionInfo from './useSessionInfo';
import Validators from './Validators';
function createPathRef (basePath: string): Record<string, string | string[]> {
return {
bags: `${basePath}/bags`,
payout: `${basePath}/payout`,
pools: `${basePath}/pools`,
query: [
`${basePath}/query/:value`,
`${basePath}/query`
],
slashes: `${basePath}/slashes`,
targets: `${basePath}/targets`
};
}
function StakingApp ({ basePath }: Props): React.ReactElement<Props> {
const { t } = useTranslation();
const { api } = useApi();
const pathRef = useRef(createPathRef(basePath));
// on unmount anything else, ensure that for the next round we
// are starting with a fresh cache (there could be large delays)
@ -41,6 +58,10 @@ function StakingApp ({ basePath }: Props): React.ReactElement<Props> {
isRoot: true,
name: 'sign',
text: t<string>('Validators')
},
isFunction(api.query.nominationPools?.minCreateBond) && {
name: 'pools',
text: t<string>('Pools')
}
]);
@ -51,7 +72,10 @@ function StakingApp ({ basePath }: Props): React.ReactElement<Props> {
items={itemsRef.current}
/>
<Switch>
<Route>
<Route path={pathRef.current.pools}>
<Pools />
</Route>
<Route path={basePath}>
<Validators
favorites={favorites}
isRelay={isRelay}