Skip to content

Commit

Permalink
Merge branch 'dao-subgraph' of https://github.com/Into-the-Fathom/fat…
Browse files Browse the repository at this point in the history
…hom-dao-smart-contracts into dao-subgraph
  • Loading branch information
ssubik committed Dec 14, 2022
2 parents 04b742b + 090c018 commit 8a12aa9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions subgraph/src/governance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,27 @@ export function proposalCreatedHandler(event: ProposalCreated): void {
}

export function voteCastHandler(event: VoteCast): void {
voteCast(event.params.proposalId.toHexString(), event.params.support);
voteCast(event.params.proposalId.toHexString(), event.params.support, event.params.weight);
}

export function voteCastWithParamsHandler(event: VoteCastWithParams): void {
voteCast(event.params.proposalId.toHexString(), event.params.support);
voteCast(event.params.proposalId.toHexString(), event.params.support, event.params.weight);
}

function voteCast(proposalId: string, support: number): void {
function voteCast(proposalId: string, support: number, weight: BigInt): void {
let proposal = Proposal.load(proposalId)

// increment vote type count
// increment vote type by weight
if (proposal != null) {
switch(u32(support)) {
case VoteType.Against:
proposal.againstVotes = proposal.againstVotes.plus(BigInt.fromString('1'))
proposal.againstVotes = proposal.againstVotes.plus(weight)
break;
case VoteType.For:
proposal.forVotes = proposal.forVotes.plus(BigInt.fromString('1'))
proposal.forVotes = proposal.forVotes.plus(weight)
break;
case VoteType.Abstain:
proposal.abstainVotes = proposal.abstainVotes.plus(BigInt.fromString('1'))
proposal.abstainVotes = proposal.abstainVotes.plus(weight)
break;
}
proposal.save()
Expand Down

0 comments on commit 8a12aa9

Please sign in to comment.