diff --git a/packages/page-council/src/Motions/ProposeExternal.tsx b/packages/page-council/src/Motions/ProposeExternal.tsx index cd767234b0..a935dd0ebb 100644 --- a/packages/page-council/src/Motions/ProposeExternal.tsx +++ b/packages/page-council/src/Motions/ProposeExternal.tsx @@ -10,6 +10,7 @@ import { useApi, useToggle } from '@polkadot/react-hooks'; import { isHex } from '@polkadot/util'; import { useTranslation } from '../translate'; +import { getThreshold } from './thresholds'; interface Props { className?: string; @@ -33,7 +34,7 @@ function ProposeExternal ({ className = '', isMember, members }: Props): React.R const [accountId, setAcountId] = useState(null); const [{ proposal, proposalLength }, setProposal] = useState({ proposalLength: 0 }); const [{ hash, isHashValid }, setHash] = useState({ hash: '', isHashValid: false }); - const threshold = Math.ceil((members.length || 0) * 0.6); // 60 for Polkadot + const threshold = Math.ceil((members.length || 0) * getThreshold(api)); const _onChangeHash = useCallback( (hash?: string): void => setHash({ hash, isHashValid: isHex(hash, 256) }), diff --git a/packages/page-council/src/Motions/ProposeMotion.tsx b/packages/page-council/src/Motions/ProposeMotion.tsx index 28af4a6867..ffe6bbf0d2 100644 --- a/packages/page-council/src/Motions/ProposeMotion.tsx +++ b/packages/page-council/src/Motions/ProposeMotion.tsx @@ -11,6 +11,7 @@ import { useApi, useToggle } from '@polkadot/react-hooks'; import { BN_ZERO } from '@polkadot/util'; import { useTranslation } from '../translate'; +import { getThreshold } from './thresholds'; interface Props { isMember: boolean; @@ -38,9 +39,9 @@ function Propose ({ isMember, members }: Props): React.ReactElement { useEffect((): void => { members && setThreshold({ isThresholdValid: members.length !== 0, - threshold: new BN(Math.ceil(members.length * 0.5)) + threshold: new BN(Math.ceil(members.length * getThreshold(api))) }); - }, [members]); + }, [api, members]); const _setMethod = useCallback( (proposal?: SubmittableExtrinsic<'promise'> | null) => setProposal({ diff --git a/packages/page-council/src/Motions/Slashing.tsx b/packages/page-council/src/Motions/Slashing.tsx index ecbc7f9768..b6413e1a5a 100644 --- a/packages/page-council/src/Motions/Slashing.tsx +++ b/packages/page-council/src/Motions/Slashing.tsx @@ -9,6 +9,7 @@ import { Button, Dropdown, Input, InputAddress, Modal, TxButton } from '@polkado import { useApi, useToggle } from '@polkadot/react-hooks'; import { useTranslation } from '../translate'; +import { getThreshold } from './thresholds'; import useAvailableSlashes from './useAvailableSlashes'; interface Props { @@ -31,7 +32,7 @@ function Slashing ({ className = '', isMember, members }: Props): React.ReactEle const [proposal, setProposal] = useState(null); const [eras, setEras] = useState([]); const [selectedEra, setSelectedEra] = useState(0); - const threshold = Math.ceil((members.length || 0) * 0.5); + const threshold = Math.ceil((members.length || 0) * getThreshold(api)); useEffect((): void => { setEras( diff --git a/packages/page-council/src/Motions/thresholds.ts b/packages/page-council/src/Motions/thresholds.ts new file mode 100644 index 0000000000..7af462caaf --- /dev/null +++ b/packages/page-council/src/Motions/thresholds.ts @@ -0,0 +1,18 @@ +// Copyright 2017-2020 @polkadot/app-council authors & contributors +// This software may be modified and distributed under the terms +// of the Apache-2.0 license. See the LICENSE file for details. + +import { ApiPromise } from '@polkadot/api'; + +const THRESHOLDS: Record = { + // Polkadot + '0x91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3': 0.6, + // Kusama + '0xb0a8d493285c2df73290dfb7e61f870f17b41801197a149ca93654499ea3dafe': 0.5 +}; + +export function getThreshold (api: ApiPromise): number { + return THRESHOLDS[api.genesisHash.toHex()] || 0.5; +} + +export { THRESHOLDS }; diff --git a/packages/page-democracy/src/Overview/Fasttrack.tsx b/packages/page-democracy/src/Overview/Fasttrack.tsx index 1edccba475..9fccafe1ee 100644 --- a/packages/page-democracy/src/Overview/Fasttrack.tsx +++ b/packages/page-democracy/src/Overview/Fasttrack.tsx @@ -37,7 +37,7 @@ function Fasttrack ({ imageHash, threshold }: Props): React.ReactElement const [votingBlocks, setVotingBlocks] = useState(DEF_VOTING); const [{ proposal, proposalLength }, setProposal] = useState({ proposalLength: 0 }); const memberThreshold = useMemo( - () => Math.ceil(members.length * 0.5), + () => Math.ceil(members.length * 0.66), [members] ); diff --git a/packages/page-treasury/src/Overview/Submission.tsx b/packages/page-treasury/src/Overview/Submission.tsx index 3cf59c60d3..1f384fcded 100644 --- a/packages/page-treasury/src/Overview/Submission.tsx +++ b/packages/page-treasury/src/Overview/Submission.tsx @@ -44,7 +44,7 @@ function Submission ({ councilProposals, id, isDisabled, members }: Props): Reac useEffect((): void => { setHasProposals( !!councilProposals - .map(({ votes }): number => votes ? votes.index.toNumber() : -1) + .map(({ votes }) => votes ? votes.index.toNumber() : -1) .filter((index) => index !== -1) .length );