From b2c3eb8fd67d1d9a0a348420aabd379371ef8012 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 28 May 2020 20:22:14 +0200 Subject: [PATCH] Failed council close with 0 length/weight (#2839) * Failed council close with 0 length/weight * 0/0 close for tc --- packages/page-council/src/Motions/Close.tsx | 7 +++++-- packages/page-council/src/Motions/Motion.tsx | 3 ++- packages/page-tech-comm/src/Proposals/Close.tsx | 7 +++++-- packages/page-tech-comm/src/Proposals/Proposal.tsx | 3 ++- packages/react-hooks/src/useVotingStatus.ts | 14 ++++++++++---- 5 files changed, 24 insertions(+), 10 deletions(-) diff --git a/packages/page-council/src/Motions/Close.tsx b/packages/page-council/src/Motions/Close.tsx index c911ef1474..4f994b27f6 100644 --- a/packages/page-council/src/Motions/Close.tsx +++ b/packages/page-council/src/Motions/Close.tsx @@ -11,6 +11,7 @@ import { useAccounts, useApi, useToggle } from '@polkadot/react-hooks'; import { useTranslation } from '../translate'; interface Props { + hasFailed: boolean; hash: Hash; idNumber: ProposalIndex; isDisabled: boolean; @@ -18,7 +19,7 @@ interface Props { proposal: Proposal; } -function Close ({ hash, idNumber, isDisabled, members, proposal }: Props): React.ReactElement | null { +function Close ({ hasFailed, hash, idNumber, isDisabled, members, proposal }: Props): React.ReactElement | null { const { t } = useTranslation(); const { api } = useApi(); const { allAccounts } = useAccounts(); @@ -74,7 +75,9 @@ function Close ({ hash, idNumber, isDisabled, members, proposal }: Props): React onStart={toggleOpen} params={ api.tx.council.close.meta.args.length === 4 - ? [hash, idNumber, proposalWeight, proposalLength] + ? hasFailed + ? [hash, idNumber, 0, 0] + : [hash, idNumber, proposalWeight, proposalLength] : [hash, idNumber] } tx='council.close' diff --git a/packages/page-council/src/Motions/Motion.tsx b/packages/page-council/src/Motions/Motion.tsx index 56e2ad78c1..d80f073a17 100644 --- a/packages/page-council/src/Motions/Motion.tsx +++ b/packages/page-council/src/Motions/Motion.tsx @@ -25,7 +25,7 @@ interface Props { } function Motion ({ className = '', isMember, members, motion: { hash, proposal, votes }, prime }: Props): React.ReactElement | null { - const { isCloseable, isVoteable, remainingBlocks } = useVotingStatus(votes, members.length, 'council'); + const { hasFailed, isCloseable, isVoteable, remainingBlocks } = useVotingStatus(votes, members.length, 'council'); if (!votes) { return null; @@ -66,6 +66,7 @@ function Motion ({ className = '', isMember, members, motion: { hash, proposal, )} {isCloseable && ( | null { +function Close ({ hasFailed, hash, idNumber, isDisabled, members, proposal }: Props): React.ReactElement | null { const { t } = useTranslation(); const { api } = useApi(); const { allAccounts } = useAccounts(); @@ -74,7 +75,9 @@ function Close ({ hash, idNumber, isDisabled, members, proposal }: Props): React onStart={toggleOpen} params={ api.tx.technicalCommittee.close.meta.args.length === 4 - ? [hash, idNumber, proposalWeight, proposalLength] + ? hasFailed + ? [hash, idNumber, 0, 0] + : [hash, idNumber, proposalWeight, proposalLength] : [hash, idNumber] } tx='technicalCommittee.close' diff --git a/packages/page-tech-comm/src/Proposals/Proposal.tsx b/packages/page-tech-comm/src/Proposals/Proposal.tsx index 530d4e5d2c..f2fdd62499 100644 --- a/packages/page-tech-comm/src/Proposals/Proposal.tsx +++ b/packages/page-tech-comm/src/Proposals/Proposal.tsx @@ -31,7 +31,7 @@ function Proposal ({ className = '', imageHash, isMember, members, prime }: Prop const votes = useCall(api.query.technicalCommittee.voting, [imageHash], { transform: (optVotes: Option) => optVotes.unwrapOr(null) }); - const { isCloseable, isVoteable, remainingBlocks } = useVotingStatus(votes, members.length, 'technicalCommittee'); + const { hasFailed, isCloseable, isVoteable, remainingBlocks } = useVotingStatus(votes, members.length, 'technicalCommittee'); if (!proposal || !votes) { return null; @@ -85,6 +85,7 @@ function Proposal ({ className = '', imageHash, isMember, members, prime }: Prop )} {isCloseable && ( (api.derive.chain.bestNumber, []); - const [state, setState] = useState({ isCloseable: false, isVoteable: false, remainingBlocks: null }); + const [state, setState] = useState({ hasFailed: false, hasPassed: false, isCloseable: false, isVoteable: false, remainingBlocks: null }); useEffect((): void => { bestNumber && votes && setState(