From 0c95a9ab6ceb428fa3d3e261da4742756af16cff Mon Sep 17 00:00:00 2001 From: Dummy Tester 123 Date: Sun, 28 Feb 2021 13:19:57 -0600 Subject: [PATCH] This commit marks bringing back add signers only, but we have edit signers in commit log just in case we want to bring it back later. --- .../{EditSigners.tsx => AddSigners.tsx} | 77 +++---------------- packages/proposals/src/constants/labels.ts | 2 +- .../proposals/src/views/proposal/index.tsx | 4 +- 3 files changed, 15 insertions(+), 68 deletions(-) rename packages/proposals/src/components/Proposal/{EditSigners.tsx => AddSigners.tsx} (68%) diff --git a/packages/proposals/src/components/Proposal/EditSigners.tsx b/packages/proposals/src/components/Proposal/AddSigners.tsx similarity index 68% rename from packages/proposals/src/components/Proposal/EditSigners.tsx rename to packages/proposals/src/components/Proposal/AddSigners.tsx index 2a47548..6ade436 100644 --- a/packages/proposals/src/components/Proposal/EditSigners.tsx +++ b/packages/proposals/src/components/Proposal/AddSigners.tsx @@ -1,39 +1,24 @@ -import { ParsedAccount, TokenAccount } from '@oyster/common'; -import { - Button, - Modal, - Input, - Form, - Tag, - Progress, - Col, - Row, - Space, - Switch, - Radio, -} from 'antd'; +import { ParsedAccount } from '@oyster/common'; +import { Button, Modal, Input, Form, Progress } from 'antd'; import React, { useState } from 'react'; import { TimelockSet } from '../../models/timelock'; import { utils, contexts, hooks } from '@oyster/common'; import { addSigner } from '../../actions/addSigner'; import { PublicKey } from '@solana/web3.js'; import { LABELS } from '../../constants'; -import { removeSigner } from '../../actions/removeSigner'; -import { AccountLayout } from '@solana/spl-token'; const { notify } = utils; const { TextArea } = Input; const { useWallet } = contexts.Wallet; const { useConnection } = contexts.Connection; const { useAccountByMint } = hooks; -const { deserializeAccount } = contexts.Accounts; const layout = { labelCol: { span: 5 }, wrapperCol: { span: 19 }, }; -export default function EditSigners({ +export default function AddSigners({ proposal, }: { proposal: ParsedAccount; @@ -43,7 +28,6 @@ export default function EditSigners({ const adminAccount = useAccountByMint(proposal.info.adminMint); const [saving, setSaving] = useState(false); const [isModalVisible, setIsModalVisible] = useState(false); - const PROGRAM_IDS = utils.programIds(); const [savePerc, setSavePerc] = useState(0); const [failedSigners, setFailedSigners] = useState([]); @@ -52,7 +36,6 @@ export default function EditSigners({ const onSubmit = async (values: { signers: string; failedSigners: string; - type: string; }) => { const signers = values.signers.split(',').map(s => s.trim()); setSaving(true); @@ -75,36 +58,13 @@ export default function EditSigners({ for (let i = 0; i < signers.length; i++) { try { - if (values.type == LABELS.ADD) - await addSigner( - connection, - wallet.wallet, - proposal, - adminAccount.pubkey, - new PublicKey(signers[i]), - ); - else { - const tokenAccounts = await connection.getTokenAccountsByOwner( - new PublicKey(signers[i]), - { - programId: PROGRAM_IDS.token, - }, - ); - const specificToThisMint = tokenAccounts.value.filter( - a => - deserializeAccount(a.account.data).mint.toBase58() === - proposal.info.signatoryMint.toBase58(), - ); - for (let j = 0; j < specificToThisMint.length; j++) { - await removeSigner( - connection, - wallet.wallet, - proposal, - adminAccount.pubkey, - specificToThisMint[j].pubkey, - ); - } - } + await addSigner( + connection, + wallet.wallet, + proposal, + adminAccount.pubkey, + new PublicKey(signers[i]), + ); setSavePerc(Math.round(100 * ((i + 1) / signers.length))); } catch (e) { console.error(e); @@ -129,11 +89,11 @@ export default function EditSigners({ setIsModalVisible(true); }} > - {LABELS.EDIT_SIGNERS} + {LABELS.ADD_SIGNERS} ) : null} {!saving && ( <> - - - - {LABELS.REMOVE} - - {LABELS.ADD} - - {adminAccount && adminAccount.info.amount.toNumber() === 1 && ( - + )} {sigAccount && sigAccount.info.amount.toNumber() === 1 && (