Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions apps/api-gateway/meshrc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ export default processConfig(
"Query.!{transfers}",
"Query.!{transfer}",
"Query.!{votingPowerHistory}",
'Query.!{accountBalances}',
'Query.!{accountBalance}',
'Query.!{delegation}',
'Query.!{tokens}',
'Query.!{token}',
// 'Query.!{votingPowerHistorys}' FIXME: Leave endpoint active for now as it is still used by the notification bot
]
"Query.!{accountBalances}",
"Query.!{accountBalance}",
"Query.!{delegation}",
"Query.!{tokens}",
"Query.!{token}",
"Query.!{votesOnchain}",
// "Query.!{votesOnchains}", TODO: Leave endpoint active for now as it is still used by the [notification bot](https://github.com/blockful/notification-system/blob/main/packages/anticapture-client/queries/votes.graphql)
// 'Query.!{votingPowerHistorys}' TODO: Leave endpoint active for now as it is still used by the notification bot
],
},
},
],
Expand Down
176 changes: 78 additions & 98 deletions apps/api-gateway/schema.graphql

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions apps/api-gateway/src/resolvers/rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const daoItemQueries = [
"proposal",
"proposalNonVoters",
"proposals",
"votes",
"proposalsActivity",
"token",
"tokenMetrics",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,21 @@ interface ProposalHeaderProps {
daoId: string;
setIsVotingModalOpen: (isOpen: boolean) => void;
votingPower: string;
votesOnchain: GetAccountPowerQuery["votesOnchain"] | null;
votes: GetAccountPowerQuery["votes"] | null;
address: string | undefined;
proposalStatus: string;
}

export const ProposalHeader = ({
daoId,
votingPower,
votesOnchain,
votes,
setIsVotingModalOpen,
address,
proposalStatus,
}: ProposalHeaderProps) => {
const supportValue = votes?.items[0]?.support;

return (
<div className="text-primary bg-surface-background border-border-default sticky -top-[57px] z-20 flex h-[65px] w-full shrink-0 items-center justify-between gap-6 border-b py-2 lg:top-0">
<div className="mx-auto flex w-full flex-1 items-center justify-between px-5">
Expand Down Expand Up @@ -53,7 +55,7 @@ export const ProposalHeader = ({

<p className="text-secondary flex items-center gap-2 whitespace-nowrap text-[14px] font-normal leading-[20px] lg:hidden">
Your VP: <span className="text-primary">{votingPower}</span>{" "}
{/* {daoId.toUpperCase()} voted {votesOnchain?.support} on this proposal */}
{/* {daoId.toUpperCase()} voted {votes?.support} on this proposal */}
</p>

{address && (
Expand All @@ -69,7 +71,7 @@ export const ProposalHeader = ({

{/* If already voted: show voted badge */}
{address ? (
!votesOnchain?.support ? (
!supportValue ? (
proposalStatus.toLowerCase() === "ongoing" && (
<Button
className="hidden lg:flex"
Expand All @@ -82,7 +84,7 @@ export const ProposalHeader = ({
) : (
<div className="hidden items-center gap-4 lg:flex">
<div className="bg-secondary ml-4 h-[28px] w-px shrink-0" />
<VotedBadge vote={Number(votesOnchain?.support)} />
<VotedBadge vote={Number(supportValue)} />
</div>
)
) : proposalStatus.toLowerCase() === "ongoing" ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const ProposalSection = () => {
daoId: daoEnum,
});

const { votingPower, votesOnchain } = useVoterInfo({
const { votingPower, votes } = useVoterInfo({
address: address ?? "",
daoId: daoEnum,
proposalId,
Expand All @@ -58,13 +58,15 @@ export const ProposalSection = () => {
return <div className="text-primary p-4">Proposal not found</div>;
}

const supportValue = votes?.items[0]?.support;

return (
<div className="w-full">
<ProposalHeader
daoId={daoId as string}
setIsVotingModalOpen={setIsVotingModalOpen}
votingPower={votingPower}
votesOnchain={votesOnchain}
votes={votes}
address={address}
proposalStatus={proposal.status}
/>
Expand All @@ -78,16 +80,16 @@ export const ProposalSection = () => {
<ProposalStatusSection proposal={proposal} />

{address ? (
!votesOnchain?.support ? (
!supportValue ? (
<Button
className="flex w-full lg:hidden"
onClick={() => setIsVotingModalOpen(true)}
>
Cast your vote
<ArrowRight className="size-[14px]" />
<ArrowRight className="size-3.5" />
</Button>
) : (
<VotedBadge vote={Number(votesOnchain?.support)} />
<VotedBadge vote={Number(supportValue)} />
)
) : (
<div className="flex w-full lg:hidden">
Expand All @@ -114,7 +116,7 @@ export const ProposalSection = () => {
export const VotedBadge = ({ vote }: { vote: number }) => {
return (
<div className="flex w-full items-center justify-center gap-2 lg:hidden">
<p className="text-secondary flex items-center gap-2 text-[12px] font-medium leading-[16px]">
<p className="text-secondary flex items-center gap-2 text-[12px] font-medium leading-4">
You voted
</p>
{getVoteText(vote)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ export const TabsVotedContent = ({
const columns: ColumnDef<VoteWithHistoricalPower>[] = useMemo(
() => [
{
accessorKey: "voterAccountId",
accessorKey: "voterAddress",
size: 200,
cell: ({ row }) => {
const voterAddress = row.getValue("voterAccountId") as string;
const voterAddress = row.getValue("voterAddress") as string;
const vote = row.original;

// Handle loading row
Expand Down Expand Up @@ -156,8 +156,8 @@ export const TabsVotedContent = ({
accessorKey: "support",
size: 120,
cell: ({ row }) => {
const support = row.getValue("support") as string;
const voterAddress = row.getValue("voterAccountId") as string;
const support = row.getValue("support") as number;
const voterAddress = row.getValue("voterAddress") as string;
const vote = row.original;

// Handle loading row
Expand Down Expand Up @@ -189,19 +189,19 @@ export const TabsVotedContent = ({
return <div className="flex h-10 items-center p-2" />;
}

const getChoiceInfo = (support: string) => {
const getChoiceInfo = (support: number) => {
switch (support) {
case "1":
case 1:
return {
label: "For",
icon: <CheckCircle2 className="text-success size-4" />,
};
case "0":
case 0:
return {
label: "Against",
icon: <XCircle className="text-error size-4" />,
};
case "2":
case 2:
return {
label: "Abstain",
icon: <CircleMinus className="text-secondary size-4" />,
Expand Down Expand Up @@ -240,7 +240,7 @@ export const TabsVotedContent = ({
size: 120,
cell: ({ row }) => {
const timestamp = row.getValue("timestamp") as string;
const voterAddress = row.getValue("voterAccountId") as string;
const voterAddress = row.getValue("voterAddress") as string;
const vote = row.original;

// Handle loading row
Expand Down Expand Up @@ -315,7 +315,7 @@ export const TabsVotedContent = ({
size: 160,
cell: ({ row }) => {
const votingPower = row.getValue("votingPower") as string;
const voterAddress = row.getValue("voterAccountId") as string;
const voterAddress = row.getValue("voterAddress") as string;
const vote = row.original;

// Handle loading row
Expand Down Expand Up @@ -397,7 +397,7 @@ export const TabsVotedContent = ({
accessorKey: "votingPowerVariation",
size: 160,
cell: ({ row }) => {
const voterAddress = row.getValue("voterAccountId") as string;
const voterAddress = row.getValue("voterAddress") as string;
const votingPowerVariation = row.getValue("votingPowerVariation") as {
previousVotingPower: string;
currentVotingPower: string;
Expand Down Expand Up @@ -503,14 +503,13 @@ export const TabsVotedContent = ({
// Add description row if the vote has a reason
if (vote.reason && vote.reason.trim() !== "") {
data.push({
voterAccountId: `__DESCRIPTION_${vote.voterAccountId}__`,
txHash: "",
daoId: vote.daoId,
voterAddress: `__DESCRIPTION_${vote.voterAddress}__`,
transactionHash: "",
proposalId: vote.proposalId,
support: "",
support: 0,
votingPower: "",
reason: vote.reason,
timestamp: "",
timestamp: 0,
isSubRow: true,
} as VoteWithHistoricalPower);
}
Expand All @@ -519,14 +518,13 @@ export const TabsVotedContent = ({
// Add loading row if there are more pages or currently loading
if (hasNextPage || isLoadingMore) {
data.push({
voterAccountId: "__LOADING_ROW__",
txHash: "",
daoId: "",
voterAddress: "__LOADING_ROW__",
transactionHash: "",
proposalId: "",
support: "",
support: 0,
votingPower: "",
reason: "",
timestamp: "",
timestamp: 0,
isSubRow: false,
} as VoteWithHistoricalPower);
}
Expand All @@ -538,8 +536,7 @@ export const TabsVotedContent = ({
const hasValidData =
votes.length > 0 &&
votes.some(
(vote) =>
vote.voterAccountId && vote.voterAccountId !== "__LOADING_ROW__",
(vote) => vote.voterAddress && vote.voterAddress !== "__LOADING_ROW__",
);

if (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { TabsVotedContent } from "@/features/governance/components/proposal-over
import { DaoIdEnum } from "@/shared/types/daos";
import { useParams } from "next/navigation";
import {
useGetVotesOnchainsTotalCountQuery,
useGetProposalNonVotersQuery,
useGetVotesQuery,
} from "@anticapture/graphql-client/hooks";
import { formatUnits } from "viem";
import { TabsDidntVoteContent } from "@/features/governance/components/proposal-overview/TabsDidntVoteContent";
Expand All @@ -29,7 +29,7 @@ export const VotesTabContent = ({
const TabsContent = TabsContentMapping[activeTab];

// Get votes for this proposal
const { data } = useGetVotesOnchainsTotalCountQuery({
const { data } = useGetVotesQuery({
variables: {
proposalId: proposal.id,
},
Expand Down Expand Up @@ -76,7 +76,7 @@ export const VotesTabContent = ({
>
Voted
<div className="text-secondary font-inter hidden text-[12px] font-medium not-italic leading-[16px] lg:block">
{data?.votesOnchains?.totalCount} voters / {totalVotes} VP
{data?.votes?.totalCount} voters / {totalVotes} VP
</div>
</div>
<div
Expand Down
9 changes: 5 additions & 4 deletions apps/dashboard/features/governance/hooks/useAccountPower.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { formatUnits } from "viem";
export interface UseAccountPowerResult {
accountPower: GetAccountPowerQuery["votingPowerByAccountId"] | null;
votingPower: string;
votesOnchain: GetAccountPowerQuery["votesOnchain"] | null;
votes: GetAccountPowerQuery["votes"] | null;
hasVoted: boolean;
loading: boolean;
error: ApolloError | undefined;
Expand All @@ -34,6 +34,7 @@ export const useVoterInfo = ({
const { data, loading, error, refetch } = useGetAccountPowerQuery({
variables: {
address,
addresses: [address],
proposalId,
},
context: {
Expand All @@ -48,7 +49,7 @@ export const useVoterInfo = ({
return {
accountPower: null,
votingPower: "0",
votesOnchain: null,
votes: null,
hasVoted: false,
loading,
error,
Expand All @@ -63,8 +64,8 @@ export const useVoterInfo = ({
formatUnits(BigInt(data.votingPowerByAccountId.votingPower), decimals),
),
),
votesOnchain: data.votesOnchain || null,
hasVoted: !!data.votesOnchain,
votes: data.votes || null,
hasVoted: !!data.votes,
loading,
error,
refetch,
Expand Down
Loading