From dda1ec1df423d3a571180064794956eff7995a38 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Wed, 10 Jun 2020 17:11:48 +0200 Subject: [PATCH] Filter multisig accounts on accounts page (#2924) --- .../src/Accounts/modals/MultisigApprove.tsx | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/page-accounts/src/Accounts/modals/MultisigApprove.tsx b/packages/page-accounts/src/Accounts/modals/MultisigApprove.tsx index 5411f1788e..81d756780c 100644 --- a/packages/page-accounts/src/Accounts/modals/MultisigApprove.tsx +++ b/packages/page-accounts/src/Accounts/modals/MultisigApprove.tsx @@ -2,9 +2,10 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { H256, Multisig } from '@polkadot/types/interfaces'; +import { AccountId, H256, Multisig } from '@polkadot/types/interfaces'; import React, { useEffect, useMemo, useState } from 'react'; +import { registry } from '@polkadot/react-api'; import { Dropdown, InputAddress, Modal, TxButton } from '@polkadot/react-components'; import { useApi } from '@polkadot/react-hooks'; @@ -29,7 +30,9 @@ function MultisigApprove ({ className = '', onClose, ongoing, threshold, who }: const { api } = useApi(); const [hash, setHash] = useState(ongoing[0][0].toHex()); const [multisig, setMultisig] = useState<[H256, Multisig] | null>(null); + const [others, setOthers] = useState([]); const [signatory, setSignatory] = useState(null); + const [whoFilter, setWhoFilter] = useState([]); const [type, setType] = useState('aye'); const calltypes = useMemo( () => [ @@ -49,6 +52,20 @@ function MultisigApprove ({ className = '', onClose, ongoing, threshold, who }: ); }, [hash, ongoing]); + useEffect((): void => { + setOthers( + who + .map((w) => registry.createType('AccountId', w)) + .filter((w) => !w.eq(signatory)) + ); + }, [signatory, who]); + + useEffect((): void => { + setWhoFilter( + who.map((w) => registry.createType('AccountId', w).toString()) + ); + }, [who]); + return ( ('The signatory to send the approval/cancel from')} label={t('signatory')} onChange={setSignatory} @@ -83,7 +100,7 @@ function MultisigApprove ({ className = '', onClose, ongoing, threshold, who }: isDisabled={!multisig} label={type === 'aye' ? 'Approve' : 'Reject'} onStart={onClose} - params={[threshold, who.filter((who) => who !== signatory), multisig ? multisig[1].when : null, hash]} + params={[threshold, others, multisig ? multisig[1].when : null, hash]} tx={`${api.tx.multisig ? 'multisig' : 'utility'}.${type === 'aye' ? 'approveAsMulti' : 'cancelAsMulti'}`} />