Skip to content

Commit

Permalink
fix: correct voter and delegate count
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyar committed Feb 20, 2024
1 parent 5d0e0fe commit e48c7b8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions subgraphs/venus-governance/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ type Governance @entity {
"Number of proposals created"
totalProposals: BigInt!

"Total number of accounts delegates that can participate in governance by voting or creating proposals"
"Total number of accounts participating in governance as delegates or by delegating"
totalDelegates: BigInt!

"Total number of accounts participating in governance as delegates or by delegating"
"Total number of accounts delegates that can participate in governance by voting or creating proposals"
totalVoters: BigInt!

"Total number of votes delegated expressed in the smallest unit of XVS"
Expand Down
1 change: 0 additions & 1 deletion subgraphs/venus-governance/src/operations/getOrCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export const getOrCreateDelegate = (address: Address): GetOrCreateDelegateReturn
if (id != nullAddress.toHex()) {
const governance = getGovernanceEntity();
governance.totalDelegates = governance.totalDelegates.plus(BIGINT_ONE);
governance.totalVoters = governance.totalVoters.plus(BIGINT_ONE);
governance.save();
}

Expand Down
5 changes: 3 additions & 2 deletions subgraphs/venus-governance/src/operations/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export function updateDelegateChanged<E>(event: E): void {

const delegatorResult = getOrCreateDelegate(params.delegator);
const delegatorEntity = delegatorResult.entity;

delegatorEntity.delegatee = toDelegate;
delegatorEntity.save();

Expand All @@ -50,7 +51,7 @@ export function updateDelegateChanged<E>(event: E): void {
}

if (fromDelegate == nullAddress.toHexString()) {
governance.totalDelegates = governance.totalDelegates.plus(BIGINT_ONE);
governance.totalVoters = governance.totalVoters.plus(BIGINT_ONE);
governance.save();
}

Expand All @@ -62,7 +63,7 @@ export function updateDelegateChanged<E>(event: E): void {
}

if (toDelegate == nullAddress.toHexString()) {
governance.totalDelegates = governance.totalDelegates.minus(BIGINT_ONE);
governance.totalVoters = governance.totalVoters.minus(BIGINT_ONE);
governance.save();
}
}
Expand Down

0 comments on commit e48c7b8

Please sign in to comment.