Fully split active/inactive nominations (#2169)

This commit is contained in:
Jaco Greeff 2020-01-22 16:05:16 +01:00 committed by GitHub
parent 3b4ed57cc4
commit 77256b24e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 89 additions and 76 deletions

View File

@ -10,10 +10,10 @@
"packages/*"
],
"resolutions": {
"@polkadot/api": "^1.0.0-beta.14",
"@polkadot/api-contract": "^1.0.0-beta.14",
"@polkadot/api": "^1.0.0-beta.16",
"@polkadot/api-contract": "^1.0.0-beta.16",
"@polkadot/keyring": "^2.0.0-beta.4",
"@polkadot/types": "^1.0.0-beta.14",
"@polkadot/types": "^1.0.0-beta.16",
"@polkadot/util": "^2.0.0-beta.4",
"@polkadot/util-crypto": "^2.0.0-beta.4",
"babel-core": "^7.0.0-bridge.0",

View File

@ -11,6 +11,6 @@
"license": "Apache-2.0",
"dependencies": {
"@babel/runtime": "^7.7.7",
"@polkadot/api-contract": "^1.0.0-beta.14"
"@polkadot/api-contract": "^1.0.0-beta.16"
}
}

View File

@ -95,7 +95,8 @@ function Account ({ allStashes, className, isOwnStash, next, onUpdateType, staki
const balancesAll = useCall<DerivedBalances>(api.derive.balances.all as any, [stashId]);
const stakingAccount = useCall<DerivedStakingAccount>(api.derive.staking.account as any, [stashId]);
const [{ controllerId, destination, hexSessionIdQueue, hexSessionIdNext, isLoading, isOwnController, isStashNominating, isStashValidating, nominees, sessionIds, validatorPrefs }, setStakeState] = useState<StakeState>({ controllerId: null, destination: 0, hexSessionIdNext: null, hexSessionIdQueue: null, isLoading: true, isOwnController: false, isStashNominating: false, isStashValidating: false, sessionIds: [] });
const inactives = useInactives(stashId, nominees);
const [activeNoms, setActiveNoms] = useState<string[]>([]);
const inactiveNoms = useInactives(stashId, nominees);
const [isBondExtraOpen, toggleBondExtra] = useToggle();
const [isInjectOpen, toggleInject] = useToggle();
const [isNominateOpen, toggleNominate] = useToggle();
@ -122,6 +123,12 @@ function Account ({ allStashes, className, isOwnStash, next, onUpdateType, staki
}
}, [allStashes, stakingAccount, stashId, validateInfo]);
useEffect((): void => {
if (nominees) {
setActiveNoms(nominees.filter((id): boolean => !inactiveNoms.includes(id)));
}
}, [inactiveNoms, nominees]);
return (
<tr className={className}>
<td className='top'>
@ -216,23 +223,25 @@ function Account ({ allStashes, className, isOwnStash, next, onUpdateType, staki
)
: (
<td>
{isStashNominating && nominees && (
{isStashNominating && (
<>
<details>
<summary>{t('All Nominations ({{count}})', { replace: { count: nominees.length } })}</summary>
{nominees.map((nomineeId, index): React.ReactNode => (
<AddressMini
key={index}
value={nomineeId}
withBalance={false}
withBonded
/>
))}
</details>
{inactives.length !== 0 && (
{activeNoms.length !== 0 && (
<details>
<summary>{t('Inactive nominations ({{count}})', { replace: { count: inactives.length } })}</summary>
{inactives.map((nomineeId, index): React.ReactNode => (
<summary>{t('Active nominations ({{count}})', { replace: { count: activeNoms.length } })}</summary>
{activeNoms.map((nomineeId, index): React.ReactNode => (
<AddressMini
key={index}
value={nomineeId}
withBalance={false}
withBonded
/>
))}
</details>
)}
{inactiveNoms.length !== 0 && (
<details>
<summary>{t('Inactive nominations ({{count}})', { replace: { count: inactiveNoms.length } })}</summary>
{inactiveNoms.map((nomineeId, index): React.ReactNode => (
<AddressMini
key={index}
value={nomineeId}

View File

@ -181,6 +181,7 @@ function Targets ({ className, sessionRewards }: Props): React.ReactElement<Prop
<InputBalance
className='balanceInput'
help={t('The amount that will be used on a per-validator basis to calculate rewards for that validator.')}
isFull
label={t('amount to use for estimation')}
onChange={setAmount}
value={_amount}
@ -210,9 +211,4 @@ function Targets ({ className, sessionRewards }: Props): React.ReactElement<Prop
export default styled(Targets)`
text-align: center;
.balanceInput {
padding-right: 2rem;
margin-bottom: 1.5rem;
}
`;

View File

@ -31,7 +31,7 @@
"homepage": "https://github.com/polkadot-js/ui/tree/master/packages/ui-reactive#readme",
"dependencies": {
"@babel/runtime": "^7.7.6",
"@polkadot/api": "^1.0.0-beta.14",
"@polkadot/api": "^1.0.0-beta.16",
"@polkadot/extension-dapp": "^0.15.0-beta.1",
"edgeware-node-types": "^1.0.10",
"rxjs-compat": "^6.5.3"

View File

@ -15,13 +15,14 @@ interface Props extends BareProps {
children?: React.ReactNode;
defaultValue?: string | null;
help?: React.ReactNode;
isFull?: boolean;
label?: React.ReactNode;
onChange?: (address: string | null) => void;
onEnter?: () => void;
onEscape?: () => void;
}
function InputAddressSimple ({ children, className, defaultValue, help, label, onChange, onEnter, onEscape }: Props): React.ReactElement<Props> {
function InputAddressSimple ({ children, className, defaultValue, help, isFull, label, onChange, onEnter, onEscape }: Props): React.ReactElement<Props> {
const [address, setAddress] = useState<string | null>(defaultValue || null);
const _onChange = (_address: string): void => {
@ -38,6 +39,7 @@ function InputAddressSimple ({ children, className, defaultValue, help, label, o
defaultValue={defaultValue}
help={help}
isError={!address}
isFull={isFull}
label={label}
onChange={_onChange}
onEnter={onEnter}

View File

@ -17,6 +17,7 @@ interface Props extends BareProps {
help?: React.ReactNode;
isDisabled?: boolean;
isError?: boolean;
isFull?: boolean;
isZeroable?: boolean;
label?: React.ReactNode;
labelExtra?: React.ReactNode;
@ -33,7 +34,7 @@ interface Props extends BareProps {
const DEFAULT_BITLENGTH = BitLengthOption.CHAIN_SPEC as BitLength;
function InputBalance ({ autoFocus, className, defaultValue: inDefault, help, isDisabled, isError, isZeroable, label, labelExtra, maxValue, onChange, onEnter, onEscape, placeholder, style, value, withEllipsis, withLabel, withMax }: Props): React.ReactElement<Props> {
function InputBalance ({ autoFocus, className, defaultValue: inDefault, help, isDisabled, isError, isFull, isZeroable, label, labelExtra, maxValue, onChange, onEnter, onEscape, placeholder, style, value, withEllipsis, withLabel, withMax }: Props): React.ReactElement<Props> {
const defaultValue = inDefault
? formatBalance(inDefault, { forceUnit: '-', withSi: false }).replace(',', isDisabled ? ',' : '')
: inDefault;
@ -47,6 +48,7 @@ function InputBalance ({ autoFocus, className, defaultValue: inDefault, help, is
help={help}
isDisabled={isDisabled}
isError={isError}
isFull={isFull}
isZeroable={isZeroable}
isSi
label={label}

View File

@ -28,6 +28,7 @@ interface Props extends BareProps, ApiProps {
help?: React.ReactNode;
isDisabled?: boolean;
isError?: boolean;
isFull?: boolean;
isZeroable?: boolean;
label?: any;
onChange?: (value?: BN) => void;
@ -62,7 +63,7 @@ class InputBalanceBonded extends React.PureComponent<Props, State> {
}
public render (): React.ReactNode {
const { autoFocus, className, defaultValue, help, isDisabled, isError, isZeroable, label, onChange, onEnter, onEscape, placeholder, style, value, withEllipsis, withLabel, withMax } = this.props;
const { autoFocus, className, defaultValue, help, isDisabled, isError, isFull, isZeroable, label, onChange, onEnter, onEscape, placeholder, style, value, withEllipsis, withLabel, withMax } = this.props;
const { maxBalance } = this.state;
return (
@ -74,6 +75,7 @@ class InputBalanceBonded extends React.PureComponent<Props, State> {
help={help}
isDisabled={isDisabled}
isError={isError}
isFull={isFull}
isSi
isZeroable={isZeroable}
label={label}

View File

@ -25,6 +25,7 @@ interface Props extends BareProps {
help?: React.ReactNode;
isDisabled?: boolean;
isError?: boolean;
isFull?: boolean;
isSi?: boolean;
isDecimal?: boolean;
isZeroable?: boolean;
@ -194,7 +195,7 @@ function isNewPropsValue (propsValue: BN | string, value: string, valueBn: BN):
export default function InputNumber (props: Props): React.ReactElement<Props> {
const { t } = useTranslation();
const { bitLength = DEFAULT_BITLENGTH, className, defaultValue = ZERO, help, isDecimal, isSi, isDisabled, isError = false, maxLength, maxValue, onChange, onEnter, onEscape, placeholder, style, value: propsValue } = props;
const { bitLength = DEFAULT_BITLENGTH, className, defaultValue = ZERO, help, isDecimal, isFull, isSi, isDisabled, isError = false, maxLength, maxValue, onChange, onEnter, onEscape, placeholder, style, value: propsValue } = props;
const [si, setSi] = useState<SiDef | null>(isSi ? formatBalance.findSi('-') : null);
const [isPreKeyDown, setIsPreKeyDown] = useState(false);
@ -269,6 +270,7 @@ export default function InputNumber (props: Props): React.ReactElement<Props> {
isAction={isSi}
isDisabled={isDisabled}
isError={!isValid || isError}
isFull={isFull}
maxLength={maxLength || maxValueLength}
onChange={_onChange}
onEnter={onEnter}

View File

@ -2093,35 +2093,35 @@
dependencies:
"@types/node" ">= 8"
"@polkadot/api-contract@^1.0.0-beta.14":
version "1.0.0-beta.14"
resolved "https://registry.yarnpkg.com/@polkadot/api-contract/-/api-contract-1.0.0-beta.14.tgz#542b0ee4c1e97afd939243a5de173cb1701765ee"
integrity sha512-HRcBgmGqT0V4/J65CC+G/JkKU0c5jocSavDank+qktlP0KfRpfDn2FMgsrPbIbGZGiNv81zxkJ86Hu/w24Ip+A==
"@polkadot/api-contract@^1.0.0-beta.16":
version "1.0.0-beta.16"
resolved "https://registry.yarnpkg.com/@polkadot/api-contract/-/api-contract-1.0.0-beta.16.tgz#1d5f29eb6febbb10c9390524fcebb89f7ac600b5"
integrity sha512-386ZdOjMaZkpA/LKutadORlFW2wzi0Zg57xKyAQrHatOVqhlwGt9BriavmfLjDLzKeVNVt6tbkbaahKT0PmhIQ==
dependencies:
"@babel/runtime" "^7.7.7"
"@polkadot/types" "^1.0.0-beta.14"
"@polkadot/types" "^1.0.0-beta.16"
"@polkadot/api-derive@^1.0.0-beta.14":
version "1.0.0-beta.14"
resolved "https://registry.yarnpkg.com/@polkadot/api-derive/-/api-derive-1.0.0-beta.14.tgz#4c33d28cd32302e1580f4c23b4f272cc4f809ef3"
integrity sha512-dwnfNPtw/ponoURP1Xpa883OC4AnOvLlHCAQzpamagvcXqLwOkzWBIvMh4OdwPAgvuZE/jfsJW5MF22iZJS6tw==
"@polkadot/api-derive@^1.0.0-beta.16":
version "1.0.0-beta.16"
resolved "https://registry.yarnpkg.com/@polkadot/api-derive/-/api-derive-1.0.0-beta.16.tgz#dc81de7359b4e241966f2c02fbf176ce594719bf"
integrity sha512-bBksii26AaZMt57MKNk/nMlbMlWvMylZ5JfuImnH1wxujt22NsQcS30bXeuQBHmFneAcMw7/0qUdic2Lp2RAig==
dependencies:
"@babel/runtime" "^7.7.7"
"@polkadot/api" "^1.0.0-beta.14"
"@polkadot/types" "^1.0.0-beta.14"
"@polkadot/api" "^1.0.0-beta.16"
"@polkadot/types" "^1.0.0-beta.16"
"@polkadot/api@^1.0.0-beta.14":
version "1.0.0-beta.14"
resolved "https://registry.yarnpkg.com/@polkadot/api/-/api-1.0.0-beta.14.tgz#7f5ecaa3675a89b89563e29f9d75b4d5c92864ef"
integrity sha512-eYfToVzIVa/mFiB1qIDxgKz5eP4bqHejLbJFJFeWr3fFXeqddqry+0PDIsPi0xewwe5ZpmP7gwC23inz8IJYOg==
"@polkadot/api@^1.0.0-beta.16":
version "1.0.0-beta.16"
resolved "https://registry.yarnpkg.com/@polkadot/api/-/api-1.0.0-beta.16.tgz#ffbec6ffe1da6f07a33c789619156331a07978ed"
integrity sha512-mD2vKWuYlYEmHIsMZDJ8iRloy8qD3aowO+ZiZAkRjzim1nvfvdNuGRlKTEh/w92y2JvziJkTy3IT/GeAdvO+ng==
dependencies:
"@babel/runtime" "^7.7.7"
"@polkadot/api-derive" "^1.0.0-beta.14"
"@polkadot/api-derive" "^1.0.0-beta.16"
"@polkadot/keyring" "^2.0.0-beta.4"
"@polkadot/metadata" "^1.0.0-beta.14"
"@polkadot/rpc-core" "^1.0.0-beta.14"
"@polkadot/rpc-provider" "^1.0.0-beta.14"
"@polkadot/types" "^1.0.0-beta.14"
"@polkadot/metadata" "^1.0.0-beta.16"
"@polkadot/rpc-core" "^1.0.0-beta.16"
"@polkadot/rpc-provider" "^1.0.0-beta.16"
"@polkadot/types" "^1.0.0-beta.16"
"@polkadot/util-crypto" "^2.0.0-beta.4"
"@polkadot/dev-react@^0.32.14":
@ -2226,10 +2226,10 @@
dependencies:
"@babel/runtime" "^7.7.7"
"@polkadot/jsonrpc@^1.0.0-beta.14":
version "1.0.0-beta.14"
resolved "https://registry.yarnpkg.com/@polkadot/jsonrpc/-/jsonrpc-1.0.0-beta.14.tgz#884bd6d273f30b7e286100e552ad293f9189fc7f"
integrity sha512-0Qo8vWE0EBojIqmClHLPejp61xg7jPqsJQ7rZJDoEO8qVUK7SdvlO4iBH5CmCg2xSw4T/vNy31edk9hyjcx25g==
"@polkadot/jsonrpc@^1.0.0-beta.16":
version "1.0.0-beta.16"
resolved "https://registry.yarnpkg.com/@polkadot/jsonrpc/-/jsonrpc-1.0.0-beta.16.tgz#fe54012ace8415ef0ea8ba2f5d1a668dcb8a676f"
integrity sha512-QOQWAKkpoiVFcafi9ClOCLNueOgH+5xKqdsm2R4KNRPgbqvPTNSmdK6tX0OTT+OS66IyG6sZqt2PeyzitjQghg==
dependencies:
"@babel/runtime" "^7.7.7"
@ -2242,13 +2242,13 @@
"@polkadot/util" "^2.0.0-beta.4"
"@polkadot/util-crypto" "^2.0.0-beta.4"
"@polkadot/metadata@^1.0.0-beta.14":
version "1.0.0-beta.14"
resolved "https://registry.yarnpkg.com/@polkadot/metadata/-/metadata-1.0.0-beta.14.tgz#33487ade0cffcc4599bf6b2776027a84ed589061"
integrity sha512-C/rN+dLVvzognD24glD6R69NnAN1cciVGLf6sHrKb6eXiewmRRvRiKb/le8aqnWBYXHApqjlWHobEEtR0LpPYg==
"@polkadot/metadata@^1.0.0-beta.16":
version "1.0.0-beta.16"
resolved "https://registry.yarnpkg.com/@polkadot/metadata/-/metadata-1.0.0-beta.16.tgz#bde603f2b4f16af5a769817bf068e07e5ed8620a"
integrity sha512-2bs1GV7xMmNEhEhtplyigObs4x14VX0snrQvdBEd7dMW3B1wtMXMxcqFgYsl+PR1y//PwDv1DzKCZGS8VEAXww==
dependencies:
"@babel/runtime" "^7.7.7"
"@polkadot/types" "^1.0.0-beta.14"
"@polkadot/types" "^1.0.0-beta.16"
"@polkadot/util" "^2.0.0-beta.4"
"@polkadot/util-crypto" "^2.0.0-beta.4"
@ -2276,25 +2276,25 @@
qrcode-generator "^1.4.4"
react-qr-reader "^2.2.1"
"@polkadot/rpc-core@^1.0.0-beta.14":
version "1.0.0-beta.14"
resolved "https://registry.yarnpkg.com/@polkadot/rpc-core/-/rpc-core-1.0.0-beta.14.tgz#162a06b2fde4e7940a93809e04c045d40ee0c7c3"
integrity sha512-jn9YamIjuBNsNj7Dn4iOxRBqUw3ftJKiF3egVMni2bNERasv1pFvFqshLj66fwNx/CwnJEVThJmaB9yaYhaQJQ==
"@polkadot/rpc-core@^1.0.0-beta.16":
version "1.0.0-beta.16"
resolved "https://registry.yarnpkg.com/@polkadot/rpc-core/-/rpc-core-1.0.0-beta.16.tgz#15a748b9f39c3fb411f9b93d9e42ffaddfe9dfbb"
integrity sha512-h88cMfbYR24NKLSnhCLIrxBbI6ZMUtQSQf7aqCrIkLfz0g7kgMYW3ncwtrAO4UpbnrUhvyfe+YPE3OuelpwuIA==
dependencies:
"@babel/runtime" "^7.7.7"
"@polkadot/jsonrpc" "^1.0.0-beta.14"
"@polkadot/rpc-provider" "^1.0.0-beta.14"
"@polkadot/types" "^1.0.0-beta.14"
"@polkadot/jsonrpc" "^1.0.0-beta.16"
"@polkadot/rpc-provider" "^1.0.0-beta.16"
"@polkadot/types" "^1.0.0-beta.16"
"@polkadot/util" "^2.0.0-beta.4"
rxjs "^6.5.4"
"@polkadot/rpc-provider@^1.0.0-beta.14":
version "1.0.0-beta.14"
resolved "https://registry.yarnpkg.com/@polkadot/rpc-provider/-/rpc-provider-1.0.0-beta.14.tgz#599b6be4bc44de4094cae7af4ab54e74f6ad468c"
integrity sha512-zzREjefXYHFmbu2BXCbqyZHAoG3meErAmoTVqAo5JSqtMqOlBn4m0VVfRd1aC6feFSilCmsqFp8NWqgGbKPxtQ==
"@polkadot/rpc-provider@^1.0.0-beta.16":
version "1.0.0-beta.16"
resolved "https://registry.yarnpkg.com/@polkadot/rpc-provider/-/rpc-provider-1.0.0-beta.16.tgz#b63fa948ad5a8a2b075e231b715829ca380cd1c8"
integrity sha512-qC1CGKHYNRw1ESywhbQWRarD0JAefEGXFzINIjcQCwswpCn5HS6AlH240l2Dm5rpNN6IpNMgGcQKN+v2dW3Vlw==
dependencies:
"@babel/runtime" "^7.7.7"
"@polkadot/metadata" "^1.0.0-beta.14"
"@polkadot/metadata" "^1.0.0-beta.16"
"@polkadot/util" "^2.0.0-beta.4"
"@polkadot/util-crypto" "^2.0.0-beta.4"
eventemitter3 "^4.0.0"
@ -2308,13 +2308,13 @@
dependencies:
"@types/chrome" "^0.0.91"
"@polkadot/types@^1.0.0-beta.14":
version "1.0.0-beta.14"
resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-1.0.0-beta.14.tgz#f675dbbdaa11f086989d86471ecc44f405a5e9ec"
integrity sha512-slv6ztmwHlaco2IIrROYm9W94vCxrkB1HQzvIa5dxmUYgjV8EUbqdJoAEX7XEQpceg+6PiAfsLyox1iQQzSHOw==
"@polkadot/types@^1.0.0-beta.16":
version "1.0.0-beta.16"
resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-1.0.0-beta.16.tgz#0754a14a10a455abf049c9d0ad911cbeb78b5e79"
integrity sha512-F509K35OEfFoOghv3SLv7eOPCMT2xZkL+pPK6HTj97+AM2U+Vs9+Si4BoYNfG+q9NVLfFt+RNLFH1MtCgjNGvA==
dependencies:
"@babel/runtime" "^7.7.7"
"@polkadot/metadata" "^1.0.0-beta.14"
"@polkadot/metadata" "^1.0.0-beta.16"
"@polkadot/util" "^2.0.0-beta.4"
"@polkadot/util-crypto" "^2.0.0-beta.4"
"@types/memoizee" "^0.4.3"