Skip to content

Commit

Permalink
discovered voting power methods were already implemented in voter.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
EdNoepel committed Jul 24, 2023
1 parent 5743bc3 commit 6215f7f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 21 deletions.
6 changes: 3 additions & 3 deletions src/grant-fund.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { addressArrayToBytesArray, addressToBytes, bigIntToBytes, bytesToBigInt,
import { getProposalParamsId, getProposalsInSlate, removeProposalFromList } from './utils/grants/proposal'
import { getCurrentDistributionId, getCurrentStage, loadOrCreateDistributionPeriod } from './utils/grants/distribution'
import { getFundingStageVotingPower, getFundingVoteId, getScreeningStageVotingPower, getScreeningVoteId, loadOrCreateDistributionPeriodVote } from './utils/grants/voter'
import { getVotesFunding, getVotesScreening, loadOrCreateGrantFund } from './utils/grants/fund'
import { loadOrCreateGrantFund } from './utils/grants/fund'
import { loadOrCreateAccount } from './utils/account'

export function handleDelegateRewardClaimed(
Expand Down Expand Up @@ -266,8 +266,8 @@ export function handleDistributionPeriodStarted(
const votes = distributionPeriod.votes
for (var i=0; i<votes.length; ++i) {
const vote = DistributionPeriodVote.load(votes[i])!
vote.screeningStageVotingPower = wadToDecimal(getVotesScreening(event.address, bytesToBigInt(distributionId), Address.fromBytes(vote.voter)))
vote.fundingStageVotingPower = wadToDecimal(getVotesFunding(event.address, bytesToBigInt(distributionId), Address.fromBytes(vote.voter)))
vote.screeningStageVotingPower = getScreeningStageVotingPower(event.address, bytesToBigInt(distributionId), Address.fromBytes(vote.voter))
vote.fundingStageVotingPower = getFundingStageVotingPower(event.address, bytesToBigInt(distributionId), Address.fromBytes(vote.voter))
vote.save()
}

Expand Down
18 changes: 0 additions & 18 deletions src/utils/grants/fund.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,3 @@ export function loadOrCreateGrantFund(grantFundAddress: Address): GrantFund {
}
return grantFund
}

export function getVotesScreening(
grantFundAddress: Address,
distributionPeriodId: BigInt,
voterId: Address) : BigInt
{
const grantFundContract = GrantFundContract.bind(grantFundAddress)
return grantFundContract.getVotesScreening(distributionPeriodId.toU32(), voterId)
}

export function getVotesFunding(
grantFundAddress: Address,
distributionPeriodId: BigInt,
voterId: Address) : BigInt
{
const grantFundContract = GrantFundContract.bind(grantFundAddress)
return grantFundContract.getVotesFunding(distributionPeriodId.toU32(), voterId)
}

0 comments on commit 6215f7f

Please sign in to comment.