Skip to content

[ENG-4] Ensure Voting Button disappears after voting #2688

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Mar 7, 2025
14 changes: 6 additions & 8 deletions src/components/Proposals/ProposalVotes/context/VoteContext.tsx
Copy link
Member

Choose a reason for hiding this comment

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

Nothing in this file fixes anything, it just cleans up the code a little tiny bit kinda

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
FractalProposal,
GovernanceType,
MultisigProposal,
SnapshotProposal,
} from '../../../../types';

interface IVoteContext {
Expand Down Expand Up @@ -61,9 +60,8 @@ export function VoteContextProvider({
const { governance } = useFractal();
const userAccount = useAccount();
const { safe } = useDaoInfoStore();
const { loadVotingWeight } = useSnapshotProposal(proposal as SnapshotProposal);
const { loadVotingWeight, snapshotProposal } = useSnapshotProposal(proposal);
const { remainingTokenIds } = useUserERC721VotingTokens(null, proposal.proposalId, true);
const { snapshotProposal } = useSnapshotProposal(proposal);
const publicClient = useNetworkPublicClient();

const getHasVoted = useCallback(() => {
Expand Down Expand Up @@ -132,11 +130,11 @@ export function VoteContextProvider({
address: azoriusProposal.votingStrategy,
client: publicClient,
});
newCanVote =
(await ozLinearVotingContract.read.getVotingWeight([
userAccount.address,
Number(proposal.proposalId),
])) > 0n;
const votingWeight = await ozLinearVotingContract.read.getVotingWeight([
userAccount.address,
Number(proposal.proposalId),
]);
newCanVote = votingWeight > 0n;
} else if (governance.type === GovernanceType.AZORIUS_ERC721) {
const votingWeight = await erc721VotingWeight();
newCanVote = votingWeight > 0n && remainingTokenIdsLength > 0;
Expand Down
4 changes: 2 additions & 2 deletions src/utils/azorius.ts
Copy link
Member

Choose a reason for hiding this comment

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

Here's where the actual issue was. We were basically ignoring the "voted list" for proposal 0 and only proposal 0, accidentally.

Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const getProposalVotes = (

if (erc20VotedEvents !== undefined) {
const erc20ProposalVoteEvents = erc20VotedEvents.filter(voteEvent => {
if (!voteEvent.args.proposalId) return false;
if (voteEvent.args.proposalId === undefined) return false;
return proposalId === voteEvent.args.proposalId;
});

Expand All @@ -146,7 +146,7 @@ const getProposalVotes = (
return events;
} else if (erc721VotedEvents !== undefined) {
const erc721ProposalVoteEvents = erc721VotedEvents.filter(voteEvent => {
if (!voteEvent.args.proposalId) return false;
if (voteEvent.args.proposalId === undefined) return false;
return proposalId === voteEvent.args.proposalId;
});

Expand Down