Skip to content

Commit

Permalink
fix: get or create delegate when creating vote
Browse files Browse the repository at this point in the history
deployer has voted without delegating for example
  • Loading branch information
coreyar committed Feb 16, 2024
1 parent 1bed22c commit f3259de
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions subgraphs/venus-governance/src/operations/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { VoteCast as VoteCastBravo } from '../../generated/GovernorBravoDelegate
import { Proposal, Vote } from '../../generated/schema';
import { ABSTAIN, AGAINST, BIGINT_ONE, FOR, NORMAL } from '../constants';
import { getVoteId } from '../utilities/ids';
import { getDelegate, getGovernanceEntity, getProposal } from './get';
import { getGovernanceEntity, getProposal } from './get';
import { getOrCreateDelegate } from './getOrCreate';

export function createProposal<E>(event: E): Proposal {
const id = event.params.id.toString();
Expand Down Expand Up @@ -51,7 +52,7 @@ export function createVoteAlpha(event: VoteCastAlpha): Vote {

export function createVoteBravo(event: VoteCastBravo): Vote {
const proposal = getProposal(event.params.proposalId.toString());
const voter = getDelegate(event.params.voter);
const voter = getOrCreateDelegate(event.params.voter).entity;
const id = getVoteId(event.params.voter, event.params.proposalId);
const vote = new Vote(id);
vote.proposal = proposal.id;
Expand Down

0 comments on commit f3259de

Please sign in to comment.