From 0dddfd7cb57bb6ea4e3a005b0fbac6deb1b7f2ee Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 27 Aug 2020 15:10:20 +0200 Subject: [PATCH] Adjust min multisig threshold to 2 (#3542) --- packages/page-accounts/src/modals/MultisigCreate.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/page-accounts/src/modals/MultisigCreate.tsx b/packages/page-accounts/src/modals/MultisigCreate.tsx index aa67020be1..7816d27347 100644 --- a/packages/page-accounts/src/modals/MultisigCreate.tsx +++ b/packages/page-accounts/src/modals/MultisigCreate.tsx @@ -10,7 +10,6 @@ import React, { useCallback, useState } from 'react'; import { Button, Input, InputAddressMulti, InputNumber, Modal } from '@polkadot/react-components'; import { useApi } from '@polkadot/react-hooks'; import keyring from '@polkadot/ui-keyring'; -import { BN_ONE } from '@polkadot/util'; import { useTranslation } from '../translate'; import useKnownAddresses from '../Accounts/useKnownAddresses'; @@ -28,6 +27,7 @@ interface CreateOptions { } const MAX_SIGNATORIES = 16; +const BN_TWO = new BN(2); function createMultisig (signatories: string[], threshold: BN | number, { genesisHash, name, tags = [] }: CreateOptions, success: string): ActionStatus { // we will fill in all the details below @@ -54,7 +54,7 @@ function Multisig ({ className = '', onClose, onStatusChange }: Props): React.Re const availableSignatories = useKnownAddresses(); const [{ isNameValid, name }, setName] = useState({ isNameValid: false, name: '' }); const [signatories, setSignatories] = useState(['']); - const [{ isThresholdValid, threshold }, setThreshold] = useState({ isThresholdValid: true, threshold: BN_ONE }); + const [{ isThresholdValid, threshold }, setThreshold] = useState({ isThresholdValid: true, threshold: BN_TWO }); const _createMultisig = useCallback( (): void => { @@ -74,7 +74,7 @@ function Multisig ({ className = '', onClose, onStatusChange }: Props): React.Re const _onChangeThreshold = useCallback( (threshold: BN | undefined) => - threshold && setThreshold({ isThresholdValid: threshold.gtn(0) && threshold.lten(signatories.length), threshold }), + threshold && setThreshold({ isThresholdValid: threshold.gte(BN_TWO) && threshold.lten(signatories.length), threshold }), [signatories] ); @@ -111,6 +111,7 @@ function Multisig ({ className = '', onClose, onStatusChange }: Props): React.Re isError={!isThresholdValid} label={t('threshold')} onChange={_onChangeThreshold} + value={threshold} />