Skip to content

Commit

Permalink
hide withdraw button for membership tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
asktree committed Oct 5, 2023
1 parent bcce9ae commit f37d568
Showing 1 changed file with 31 additions and 19 deletions.
50 changes: 31 additions & 19 deletions components/TokenBalance/TokenDeposit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -345,24 +356,25 @@ export const TokenDeposit = ({
Deposit
</Button>
) : null}
{(inAccountDetails || isVsr) && (
<SecondaryButton
tooltipMessage={withdrawTooltipContent}
className="sm:w-1/2 max-w-[200px]"
disabled={
!connected ||
!hasTokensDeposited ||
(!councilVote &&
toManyCommunityOutstandingProposalsForUser) ||
toManyCouncilOutstandingProposalsForUse ||
wallet?.publicKey?.toBase58() !==
depositTokenRecord.account.governingTokenOwner.toBase58()
}
onClick={withdrawAllTokens}
>
Withdraw
</SecondaryButton>
)}
{!isMembership && // Membership tokens can't be withdrawn (that is their whole point, actually)
(inAccountDetails || isVsr) && (
<SecondaryButton
tooltipMessage={withdrawTooltipContent}
className="sm:w-1/2 max-w-[200px]"
disabled={
!connected ||
!hasTokensDeposited ||
(!councilVote &&
toManyCommunityOutstandingProposalsForUser) ||
toManyCouncilOutstandingProposalsForUse ||
wallet?.publicKey?.toBase58() !==
depositTokenRecord.account.governingTokenOwner.toBase58()
}
onClick={withdrawAllTokens}
>
Withdraw
</SecondaryButton>
)}
</div>
</>
}
Expand Down

0 comments on commit f37d568

Please sign in to comment.