Skip to content

Commit

Permalink
feat(uxd): add init/edit/mint/redeem itxs (#162)
Browse files Browse the repository at this point in the history
* add relinquish button on proposals

* use UXD RPC

* trigger vercel

* add delegate bloc inside of proposals

* State vote relinquish

* fix css

* Add names for UXP staking delegated accounts

* change color for relinquish

* add vote relinquish panel

* add unrelinquished vote on proposal cards

* fix delegation name

* feat(uxd): add init/edit/mint/redeem itxs

* chore(uxd): update uxd-client to 8.1.4-rc1, add missing profitsBeneficiary option for edit Depository

* fix(rpc): switch mainnet fallback from quiknode to helius

* feat(uxd): add proposal ui data

* feat(uxd): udpate EditController with new optional parameters

* chore(uxd): update and clean up from feedback

* Fix mintWithIdentityDepository

---------

Co-authored-by: Gregory Neut <gregory.neut@gmail.com>
  • Loading branch information
sjillen and Orelsanpls authored Dec 22, 2023
1 parent 7829697 commit 119ca0c
Show file tree
Hide file tree
Showing 41 changed files with 4,628 additions and 92 deletions.
97 changes: 58 additions & 39 deletions components/ProposalCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import styled from '@emotion/styled'
import { ChevronRightIcon } from '@heroicons/react/solid'
import ProposalStateBadge from './ProposalStateBadge'
import Link from 'next/link'
import { GovernanceAccountType, Proposal, ProposalState, VoteType } from '@solana/spl-governance'
import {
GovernanceAccountType,
Proposal,
ProposalState,
VoteType,
} from '@solana/spl-governance'
import { ApprovalProgress, VetoProgress } from './QuorumProgress'
import useRealm from '../hooks/useRealm'
import useProposalVotes from '../hooks/useProposalVotes'
Expand All @@ -17,6 +22,7 @@ import MultiChoiceVotes from './MultiChoiceVotes'
type ProposalCardProps = {
proposalPk: PublicKey
proposal: Proposal
unrelinquishedVote?: boolean
}

const StyledSvg = styled(ChevronRightIcon)``
Expand All @@ -29,12 +35,17 @@ const StyledCardWrapper = styled.div`
}
`

const ProposalCard = ({ proposalPk, proposal }: ProposalCardProps) => {
const ProposalCard = ({
proposalPk,
proposal,
unrelinquishedVote,
}: ProposalCardProps) => {
const { symbol } = useRealm()
const { fmtUrlWithCluster } = useQueryContext()
const votesData = useProposalVotes(proposal)
const isMulti = proposal.voteType !== VoteType.SINGLE_CHOICE
&& proposal.accountType === GovernanceAccountType.ProposalV2
const isMulti =
proposal.voteType !== VoteType.SINGLE_CHOICE &&
proposal.accountType === GovernanceAccountType.ProposalV2

return (
<div>
Expand All @@ -59,44 +70,52 @@ const ProposalCard = ({ proposalPk, proposal }: ProposalCardProps) => {
<StyledSvg className="default-transition h-6 ml-3 text-fgd-2 w-6" />
</div>
</div>
<ProposalTimeStatus proposal={proposal} />
</div>
{proposal.state === ProposalState.Voting ?
isMulti ?
<div className="pb-4 px-6">
<MultiChoiceVotes proposal={proposal} limit={3}/>
<div>
<ProposalTimeStatus proposal={proposal} />
</div>
:
(<div className="border-t border-fgd-4 flex flex-col lg:flex-row mt-2 p-4 gap-x-4 gap-y-3">
<div className="w-full lg:w-auto flex-1">
<VoteResults isListView proposal={proposal} />
</div>
<div className="border-r border-fgd-4 hidden lg:block" />
<div className="w-full lg:w-auto flex-1">
<ApprovalProgress
progress={votesData.yesVoteProgress}
votesRequired={votesData.yesVotesRequired}
/>
<div className="text-fgd-3 text-sm mt-4">
{unrelinquishedVote ? '** Vote not relinquished **' : null}
</div>
</div>
{proposal.state === ProposalState.Voting ? (
isMulti ? (
<div className="pb-4 px-6">
<MultiChoiceVotes proposal={proposal} limit={3} />
</div>
{votesData._programVersion !== undefined &&
// @asktree: here is some typescript gore because typescript doesn't know that a number being > 3 means it isn't 1 or 2
votesData._programVersion !== 1 &&
votesData._programVersion !== 2 &&
votesData.veto !== undefined &&
(votesData.veto.voteProgress ?? 0) > 0 ? (
<>
<div className="border-r border-fgd-4 hidden lg:block" />
) : (
<div className="border-t border-fgd-4 flex flex-col lg:flex-row mt-2 p-4 gap-x-4 gap-y-3">
<div className="w-full lg:w-auto flex-1">
<VoteResults isListView proposal={proposal} />
</div>
<div className="border-r border-fgd-4 hidden lg:block" />
<div className="w-full lg:w-auto flex-1">
<ApprovalProgress
progress={votesData.yesVoteProgress}
votesRequired={votesData.yesVotesRequired}
/>
</div>
{votesData._programVersion !== undefined &&
// @asktree: here is some typescript gore because typescript doesn't know that a number being > 3 means it isn't 1 or 2
votesData._programVersion !== 1 &&
votesData._programVersion !== 2 &&
votesData.veto !== undefined &&
(votesData.veto.voteProgress ?? 0) > 0 ? (
<>
<div className="border-r border-fgd-4 hidden lg:block" />

<div className="w-full lg:w-auto flex-1">
<VetoProgress
progress={votesData.veto.voteProgress}
votesRequired={votesData.veto.votesRequired}
/>
</div>
</>
) : undefined}
</div>)
: ""}
<div className="w-full lg:w-auto flex-1">
<VetoProgress
progress={votesData.veto.voteProgress}
votesRequired={votesData.veto.votesRequired}
/>
</div>
</>
) : undefined}
</div>
)
) : (
''
)}
</StyledCardWrapper>
</a>
</Link>
Expand Down
Loading

1 comment on commit 119ca0c

@vercel
Copy link

@vercel vercel bot commented on 119ca0c Dec 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.