diff --git a/packages/page-council/src/Motions/ProposeExternal.tsx b/packages/page-council/src/Motions/ProposeExternal.tsx index 44fd05b765..ff2afefbde 100644 --- a/packages/page-council/src/Motions/ProposeExternal.tsx +++ b/packages/page-council/src/Motions/ProposeExternal.tsx @@ -22,6 +22,7 @@ interface HashState { hash?: string; isHashValid: boolean; } + interface ProposalState { proposal?: SubmittableExtrinsic<'promise'> | null; proposalLength: number; diff --git a/packages/page-council/src/Motions/Slashing.tsx b/packages/page-council/src/Motions/Slashing.tsx index f7a7a8b699..98267dd522 100644 --- a/packages/page-council/src/Motions/Slashing.tsx +++ b/packages/page-council/src/Motions/Slashing.tsx @@ -2,7 +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 { CallFunction } from '@polkadot/types/types'; +import { SubmittableExtrinsic } from '@polkadot/api/types'; import React, { useEffect, useState } from 'react'; import { Button, Dropdown, Input, InputAddress, Modal, TxButton } from '@polkadot/react-components'; @@ -23,13 +23,18 @@ interface Option { value: number; } +interface ProposalState { + proposal?: SubmittableExtrinsic<'promise'> | null; + proposalLength: number; +} + function Slashing ({ className = '', isMember, members }: Props): React.ReactElement { const { t } = useTranslation(); const { api } = useApi(); const slashes = useAvailableSlashes(); const [isVisible, toggleVisible] = useToggle(); const [accountId, setAcountId] = useState(null); - const [proposal, setProposal] = useState(null); + const [{ proposal, proposalLength }, setProposal] = useState({ proposal: null, proposalLength: 0 }); const [eras, setEras] = useState([]); const [selectedEra, setSelectedEra] = useState(0); const threshold = Math.ceil((members.length || 0) * getThreshold(api)); @@ -50,12 +55,14 @@ function Slashing ({ className = '', isMember, members }: Props): React.ReactEle useEffect((): void => { const actioned = selectedEra && slashes && slashes.find(([era]): boolean => era.eqn(selectedEra)); + const proposal = actioned + ? api.tx.staking.cancelDeferredSlash(actioned[0], actioned[1].map((_, index): number => index)) + : null; - setProposal((): any => - actioned - ? api.tx.staking.cancelDeferredSlash(actioned[0], actioned[1].map((_, index): number => index)) - : null - ); + setProposal({ + proposal, + proposalLength: proposal?.encodedLength || 0 + }); }, [api, selectedEra, slashes]); return ( @@ -121,7 +128,11 @@ function Slashing ({ className = '', isMember, members }: Props): React.ReactEle isDisabled={!threshold || !members.includes(accountId || '') || !proposal} label={t('Revert')} onStart={toggleVisible} - params={[threshold, proposal]} + params={ + api.tx.council.propose.meta.args.length === 3 + ? [threshold, proposal, proposalLength] + : [threshold, proposal] + } tx='council.propose' />