Skip to content
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

refactor: assert when voter exists when creating vote #198

Merged
merged 2 commits into from
Nov 29, 2024
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
2 changes: 2 additions & 0 deletions subgraphs/venus-governance/src/mappings/alpha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ export function handleVoteCast(event: VoteCast): void {
}

export function handleVoteCastV2(event: VoteCast): void {
// Always check for a delegate in order to support 0 value votes
getOrCreateDelegate(event.params.voter);
createVoteAlpha(event);
updateAlphaProposalVotes(event.params.proposalId, event.params.votes, event.params.support);
}
2 changes: 2 additions & 0 deletions subgraphs/venus-governance/src/mappings/bravo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ import {
} from '../operations/update';

export function handleProposalCreated(event: ProposalCreated): void {
// Always check for a delegate in order to support 0 value votes
getOrCreateDelegate(event.params.proposer);
createProposal<ProposalCreated>(event);
}

export function handleProposalCreatedV2(event: ProposalCreatedV2): void {
// Always check for a delegate in order to support 0 value votes
getOrCreateDelegate(event.params.proposer);
const proposal = createProposal<ProposalCreatedV2>(event);
const indexProposalTypeConstant = [NORMAL, FAST_TRACK, CRITICAL];
Expand Down
3 changes: 2 additions & 1 deletion subgraphs/venus-governance/src/operations/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ export function createProposal<E>(event: E): Proposal {

export function createVoteAlpha(event: VoteCastAlpha): Vote {
const id = getVoteId(event.params.voter, event.params.proposalId);
const voter = getDelegate(event.params.voter);
const vote = new Vote(id);
vote.proposal = getProposalId(event.params.proposalId);
vote.voter = event.params.voter;
vote.voter = voter.id;
vote.votes = event.params.votes;
vote.support = event.params.support ? FOR : AGAINST;

Expand Down
Loading