Show council reserved voting amount (#5179)

This commit is contained in:
Jaco 2021-05-01 07:46:23 +03:00 committed by GitHub
parent 6bac862800
commit 3a36f54342
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,10 +2,11 @@
// SPDX-License-Identifier: Apache-2.0
import type { DeriveElectionsInfo } from '@polkadot/api-derive/types';
import type { BalanceOf } from '@polkadot/types/interfaces';
import React, { useEffect, useState } from 'react';
import React, { useEffect, useMemo, useState } from 'react';
import { Button, InputAddress, InputAddressMulti, Modal, TxButton, VoteValue } from '@polkadot/react-components';
import { Button, InputAddress, InputAddressMulti, InputBalance, Modal, TxButton, VoteValue } from '@polkadot/react-components';
import { useApi, useToggle } from '@polkadot/react-hooks';
import { BN_ZERO } from '@polkadot/util';
@ -51,6 +52,13 @@ function Vote ({ electionsInfo }: Props): React.ReactElement<Props> {
});
}, [api, accountId, available]);
const bondValue = useMemo(
() => ((api.consts.electionsPhragmen || api.consts.elections).votingBondBase as BalanceOf).add(
((api.consts.electionsPhragmen || api.consts.elections).votingBondFactor as BalanceOf).muln(votes.length)
),
[api, votes]
);
return (
<>
<Button
@ -96,6 +104,14 @@ function Vote ({ electionsInfo }: Props): React.ReactElement<Props> {
valueLabel={t<string>('my ordered votes')}
/>
</Modal.Columns>
<Modal.Columns hint={t('The amount will be reserved for the duration of your vote')}>
<InputBalance
defaultValue={bondValue}
help={t<string>('The amount that is reserved')}
isDisabled
label={t<string>('voting bond')}
/>
</Modal.Columns>
</Modal.Content>
<Modal.Actions onCancel={toggleVisible}>
<TxButton