diff --git a/src/components/Proposals/SnapshotProposalDetails/SnapshotProposalVoteItem.tsx b/src/components/Proposals/SnapshotProposalDetails/SnapshotProposalVoteItem.tsx index 95df867cbf..17560334ec 100644 --- a/src/components/Proposals/SnapshotProposalDetails/SnapshotProposalVoteItem.tsx +++ b/src/components/Proposals/SnapshotProposalDetails/SnapshotProposalVoteItem.tsx @@ -1,6 +1,5 @@ import { Grid, GridItem, Text, Flex } from '@chakra-ui/react'; import { useTranslation } from 'react-i18next'; -import useSnapshotProposal from '../../../hooks/DAO/loaders/snapshot/useSnapshotProposal'; import useDisplayName from '../../../hooks/utils/useDisplayName'; import { useFractal } from '../../../providers/App/AppProvider'; import { @@ -17,7 +16,6 @@ interface ISnapshotProposalVoteItem { export default function SnapshotProposalVoteItem({ proposal, vote }: ISnapshotProposalVoteItem) { const { t } = useTranslation(); - const { getVoteWeight } = useSnapshotProposal(proposal); const { displayName } = useDisplayName(vote.voter); const { readOnly: { user }, @@ -62,7 +60,7 @@ export default function SnapshotProposalVoteItem({ proposal, vote }: ISnapshotPr - {getVoteWeight(vote)} {proposal.strategies[0].params.symbol} + {vote.votingWeight} {proposal.strategies[0].params.symbol} diff --git a/src/components/Proposals/SnapshotProposalDetails/hooks/useTotalVotes.ts b/src/components/Proposals/SnapshotProposalDetails/hooks/useTotalVotes.ts index f38fb85737..fcdf62d885 100644 --- a/src/components/Proposals/SnapshotProposalDetails/hooks/useTotalVotes.ts +++ b/src/components/Proposals/SnapshotProposalDetails/hooks/useTotalVotes.ts @@ -1,18 +1,16 @@ import { useState, useEffect } from 'react'; -import useSnapshotProposal from '../../../../hooks/DAO/loaders/snapshot/useSnapshotProposal'; import { ExtendedSnapshotProposal } from '../../../../types'; export default function useTotalVotes({ proposal }: { proposal?: ExtendedSnapshotProposal }) { const [totalVotesCasted, setTotalVotesCasted] = useState(0); - const { getVoteWeight } = useSnapshotProposal(proposal); useEffect(() => { if (proposal) { let newTotalVotesCasted = 0; - proposal.votes.forEach(vote => (newTotalVotesCasted += getVoteWeight(vote))); + proposal.votes.forEach(vote => (newTotalVotesCasted += vote.votingWeight)); setTotalVotesCasted(newTotalVotesCasted); } - }, [proposal, totalVotesCasted, getVoteWeight]); + }, [proposal, totalVotesCasted]); return { totalVotesCasted }; } diff --git a/src/hooks/DAO/loaders/snapshot/useSnapshotProposal.ts b/src/hooks/DAO/loaders/snapshot/useSnapshotProposal.ts index 793dfab355..e6e0f15e7c 100644 --- a/src/hooks/DAO/loaders/snapshot/useSnapshotProposal.ts +++ b/src/hooks/DAO/loaders/snapshot/useSnapshotProposal.ts @@ -27,8 +27,6 @@ export default function useSnapshotProposal(proposal: FractalProposal | null | u [snapshotProposal] ); - const getVoteWeight = useCallback((vote: SnapshotVote) => vote.votingWeight, []); - const loadProposal = useCallback(async () => { if (snapshotProposal?.snapshotProposalId) { const proposalQueryResult = await client @@ -135,12 +133,12 @@ export default function useSnapshotProposal(proposal: FractalProposal | null | u const existingChoiceType = votesBreakdown[voteChoice]; if (existingChoiceType) { votesBreakdown[voteChoice] = { - total: existingChoiceType.total + getVoteWeight(vote), + total: existingChoiceType.total + vote.votingWeight, votes: [...existingChoiceType.votes, vote], }; } else { votesBreakdown[voteChoice] = { - total: getVoteWeight(vote), + total: vote.votingWeight, votes: [vote], }; } @@ -152,12 +150,12 @@ export default function useSnapshotProposal(proposal: FractalProposal | null | u const existingChoiceType = votesBreakdown[voteChoice]; if (existingChoiceType) { votesBreakdown[voteChoice] = { - total: existingChoiceType.total + getVoteWeight(vote), + total: existingChoiceType.total + vote.votingWeight, votes: [...existingChoiceType.votes, vote], }; } else { votesBreakdown[voteChoice] = { - total: getVoteWeight(vote), + total: vote.votingWeight, votes: [vote], }; } @@ -170,12 +168,12 @@ export default function useSnapshotProposal(proposal: FractalProposal | null | u if (existingChoiceType) { votesBreakdown[choiceKey] = { - total: existingChoiceType.total + getVoteWeight(vote), + total: existingChoiceType.total + vote.votingWeight, votes: [...existingChoiceType.votes, vote], }; } else { votesBreakdown[choiceKey] = { - total: getVoteWeight(vote), + total: vote.votingWeight, votes: [vote], }; } @@ -190,7 +188,7 @@ export default function useSnapshotProposal(proposal: FractalProposal | null | u votes: votesQueryResult, } as ExtendedSnapshotProposal); } - }, [snapshotProposal?.snapshotProposalId, proposal, snapshotProposal?.state, getVoteWeight]); + }, [snapshotProposal?.snapshotProposalId, proposal, snapshotProposal?.state]); const loadVotingWeight = useCallback(async () => { if (snapshotProposal?.snapshotProposalId) { @@ -230,7 +228,6 @@ export default function useSnapshotProposal(proposal: FractalProposal | null | u return { loadVotingWeight, loadProposal, - getVoteWeight, snapshotProposal, isSnapshotProposal, extendedSnapshotProposal,