From f37d5687863a19bfafbf1bdd8bde388ff32dc1da Mon Sep 17 00:00:00 2001 From: agrippa Date: Thu, 5 Oct 2023 21:22:00 +0000 Subject: [PATCH] hide withdraw button for membership tokens --- components/TokenBalance/TokenDeposit.tsx | 50 +++++++++++++++--------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/components/TokenBalance/TokenDeposit.tsx b/components/TokenBalance/TokenDeposit.tsx index 0bf0f3b283..bc6dd1c7a1 100644 --- a/components/TokenBalance/TokenDeposit.tsx +++ b/components/TokenBalance/TokenDeposit.tsx @@ -7,7 +7,11 @@ import { import { PublicKey, Transaction, TransactionInstruction } from '@solana/web3.js' import BN from 'bn.js' import useRealm from '@hooks/useRealm' -import { getProposal, ProposalState } from '@solana/spl-governance' +import { + getProposal, + GoverningTokenType, + ProposalState, +} from '@solana/spl-governance' import { getUnrelinquishedVoteRecords } from '@models/api' import { withRelinquishVote } from '@solana/spl-governance' import { withWithdrawGoverningTokens } from '@solana/spl-governance' @@ -67,6 +71,13 @@ export const TokenDeposit = ({ const realm = useRealmQuery().data?.result const config = useRealmConfigQuery().data?.result + const relevantTokenConfig = + tokenRole === GoverningTokenRole.Community + ? config?.account.communityTokenConfig + : config?.account.councilTokenConfig + const isMembership = + relevantTokenConfig?.tokenType === GoverningTokenType.Membership + const { realmInfo, realmTokenAccount, @@ -345,24 +356,25 @@ export const TokenDeposit = ({ Deposit ) : null} - {(inAccountDetails || isVsr) && ( - - Withdraw - - )} + {!isMembership && // Membership tokens can't be withdrawn (that is their whole point, actually) + (inAccountDetails || isVsr) && ( + + Withdraw + + )} }