From ce3401a1d1c97196a9e3ba3219b4ab418539bdbf Mon Sep 17 00:00:00 2001 From: fabiolalombardim Date: Thu, 25 May 2023 21:02:12 +0200 Subject: [PATCH] voting turnout fix --- src/services/lite/utils.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/services/lite/utils.ts b/src/services/lite/utils.ts index 2a065dc8..5e83bdb8 100644 --- a/src/services/lite/utils.ts +++ b/src/services/lite/utils.ts @@ -154,12 +154,20 @@ export const calculateProposalTotal = (choices: Choice[], decimals: any) => { return result } -export const getTotalVoters = (choices: Choice[]) => { - let votersTotal = 0 - choices.map((choice: Choice) => { - votersTotal += choice.walletAddresses.length +const getUsers = (options: Choice[]) => { + const addresses: string[] = [] + + options.map(option => { + return option.walletAddresses.map(wallet => addresses.push(wallet.address)) }) - return votersTotal + + return new Set(addresses) +} + +export const getTotalVoters = (choices: Choice[]) => { + const totalVoters = getUsers(choices) + + return totalVoters.size } export const getTreasuryPercentage = (proposalTotal: BigNumber, totalSupply: number, decimals: any) => {