diff --git a/packages/page-democracy/src/Overview/Fasttrack.tsx b/packages/page-democracy/src/Overview/Fasttrack.tsx index 5f13bfccbb..27e1c1d615 100644 --- a/packages/page-democracy/src/Overview/Fasttrack.tsx +++ b/packages/page-democracy/src/Overview/Fasttrack.tsx @@ -99,7 +99,7 @@ function Fasttrack ({ imageHash, threshold }: Props): React.ReactElement onStart={toggleFasttrack} params={ api.tx.technicalCommittee.propose.meta.args.length === 3 - ? [threshold, proposal, proposalLength] + ? [memberThreshold, proposal, proposalLength] : [memberThreshold, proposal] } tx='technicalCommittee.propose' diff --git a/packages/page-treasury/src/Overview/Submission.tsx b/packages/page-treasury/src/Overview/Submission.tsx index 0de32c5257..f25dcf7cbf 100644 --- a/packages/page-treasury/src/Overview/Submission.tsx +++ b/packages/page-treasury/src/Overview/Submission.tsx @@ -2,6 +2,7 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. +import { SubmittableExtrinsic } from '@polkadot/api/types'; import { DeriveCollectiveProposal } from '@polkadot/api-derive/types'; import { ProposalIndex } from '@polkadot/types/interfaces'; @@ -18,6 +19,11 @@ interface Props { members: string[]; } +interface ProposalState { + proposal?: SubmittableExtrinsic<'promise'> | null; + proposalLength: number; +} + function Submission ({ councilProposals, id, isDisabled, members }: Props): React.ReactElement | null { const { t } = useTranslation(); const { api } = useApi(); @@ -28,6 +34,7 @@ function Submission ({ councilProposals, id, isDisabled, members }: Props): Reac const [isOpen, toggleOpen] = useToggle(); const [accountId, setAccountId] = useState(null); const [councilType, setCouncilType] = useState('reject'); + const [{ proposal, proposalLength }, setProposal] = useState({ proposalLength: 0 }); const [hasProposals, setHasProposals] = useState(true); const councilTypeOpt = useMemo(() => [ { text: t('Acceptance proposal to council'), value: 'accept' }, @@ -43,6 +50,14 @@ function Submission ({ councilProposals, id, isDisabled, members }: Props): Reac ); }, [councilProposals]); + useEffect((): void => { + const proposal = councilType === 'reject' + ? api.tx.treasury.rejectProposal(id) + : api.tx.treasury.approveProposal(id); + + setProposal({ proposal, proposalLength: proposal.length }); + }, [api, councilType, id]); + if (hasProposals) { return null; } @@ -93,12 +108,11 @@ function Submission ({ councilProposals, id, isDisabled, members }: Props): Reac isPrimary label={t('Send to council')} onStart={toggleOpen} - params={[ - councilThreshold, - councilType === 'reject' - ? api.tx.treasury.rejectProposal(id) - : api.tx.treasury.approveProposal(id) - ]} + params={ + api.tx.council.propose.meta.args.length === 3 + ? [councilThreshold, proposal, proposalLength] + : [councilThreshold, proposal] + } tx='council.propose' />