Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display day breakdown for voting locks #2234

Merged
merged 1 commit into from
Feb 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/app-address-book/src/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function Overview ({ className, onStatusChange }: Props): React.ReactElement<Pro
</Table>
</>
)
: t('no contracts yet, add an existing contact')
: t('no addresses saved yet, add any existing address')
}
</div>
);
Expand Down
26 changes: 17 additions & 9 deletions packages/app-democracy/src/Overview/Voting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { PropIndex, Proposal } from '@polkadot/types/interfaces';

import React, { useMemo, useState } from 'react';
import { Button, Dropdown, Modal, ProposedAction, VoteAccount, VoteActions, VoteToggle } from '@polkadot/react-components';
import { useAccounts, useToggle } from '@polkadot/react-hooks';
import { useAccounts, useApi, useToggle } from '@polkadot/react-hooks';
import { isBoolean } from '@polkadot/util';

import { useTranslation } from '../translate';
Expand All @@ -18,20 +18,28 @@ interface Props {

export default function Voting ({ proposal, referendumId }: Props): React.ReactElement<Props> | null {
const { t } = useTranslation();
const { api } = useApi();
const { hasAccounts } = useAccounts();
const [accountId, setAccountId] = useState<string | null>(null);
const [conviction, setConviction] = useState(0);
const [isVotingOpen, toggleVoting] = useToggle();
const [aye, setVoteValue] = useState(true);
const [enact] = useState(
(api.consts.democracy.enactmentPeriod.toNumber() * api.consts.timestamp.minimumPeriod.toNumber() / 1000 * 2) / 60 / 60 / 24
);
const convictionOpts = useMemo(() => [
{ text: t('0.1x of voting balance, no lockup period'), value: 0 },
{ text: t('1x of voting balance, locked for 1x enactment'), value: 1 },
{ text: t('2x of voting balance, locked for 2x enactment'), value: 2 },
{ text: t('3x of voting balance, locked for 4x enactment'), value: 3 },
{ text: t('4x of voting balance, locked for 8x enactment'), value: 4 },
{ text: t('5x of voting balance, locked for 16x enactment'), value: 5 },
{ text: t('6x of voting balance, locked for 32x enactment'), value: 6 }
], [t]);
{ text: t('0.1x voting balance, no lockup period'), value: 0 },
...[[1, 1], [2, 2], [3, 4], [4, 8], [5, 16], [6, 32]].map(([value, lock]): { text: string; value: number } => ({
text: t('{{value}}x voting balance, locked for {{lock}}x enactment ({{period}} days)', {
replace: {
lock,
period: (enact * lock).toFixed(2),
value
}
}),
value
}))
], [t, enact]);

if (!hasAccounts) {
return null;
Expand Down
1 change: 0 additions & 1 deletion packages/app-extrinsics/src/Selection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ class Selection extends TxComponent<Props, State> {
icon='sign-in'
extrinsic={extrinsic}
ref={this.button}
withSpinner
/>
</Button.Group>
</div>
Expand Down