From 27890365381b68c998dd7e606e45aa1d635f802a Mon Sep 17 00:00:00 2001 From: Corey Rice Date: Thu, 28 Nov 2024 14:30:16 -0300 Subject: [PATCH 1/2] refactor: assert when voter exists when creating vote --- subgraphs/venus-governance/src/operations/create.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/subgraphs/venus-governance/src/operations/create.ts b/subgraphs/venus-governance/src/operations/create.ts index e4d995da..8a4a223b 100644 --- a/subgraphs/venus-governance/src/operations/create.ts +++ b/subgraphs/venus-governance/src/operations/create.ts @@ -42,9 +42,10 @@ export function createProposal(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; From 50b6b12a1f3a597cac95fd68bae8aa6d717171cb Mon Sep 17 00:00:00 2001 From: Corey Rice Date: Fri, 29 Nov 2024 09:08:26 -0300 Subject: [PATCH 2/2] fix: support zero value votes on governorAlpha2 --- subgraphs/venus-governance/src/mappings/alpha.ts | 2 ++ subgraphs/venus-governance/src/mappings/bravo.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/subgraphs/venus-governance/src/mappings/alpha.ts b/subgraphs/venus-governance/src/mappings/alpha.ts index b7a6032e..0f18c141 100644 --- a/subgraphs/venus-governance/src/mappings/alpha.ts +++ b/subgraphs/venus-governance/src/mappings/alpha.ts @@ -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); } diff --git a/subgraphs/venus-governance/src/mappings/bravo.ts b/subgraphs/venus-governance/src/mappings/bravo.ts index df02973e..ae22f753 100644 --- a/subgraphs/venus-governance/src/mappings/bravo.ts +++ b/subgraphs/venus-governance/src/mappings/bravo.ts @@ -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(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(event); const indexProposalTypeConstant = [NORMAL, FAST_TRACK, CRITICAL];