diff --git a/packages/dai-plugin-governance/src/GovPollingService.js b/packages/dai-plugin-governance/src/GovPollingService.js index 82f4b2c7b..9a104aebb 100644 --- a/packages/dai-plugin-governance/src/GovPollingService.js +++ b/packages/dai-plugin-governance/src/GovPollingService.js @@ -2,7 +2,7 @@ import { PrivateService } from '@makerdao/services-core'; import { POLLING } from './utils/constants'; import { MKR } from './utils/constants'; import BigNumber from 'bignumber.js'; -import { fromBuffer } from './utils/helpers'; +import { fromBuffer, toBuffer, paddedArray } from './utils/helpers'; const POSTGRES_MAX_INT = 2147483647; @@ -82,10 +82,12 @@ export default class GovPollingService extends PrivateService { } async getOptionVotingForRankedChoice(address, pollId) { - return this.get('govQueryApi').getOptionVotingForRankedChoice( - address.toLowerCase(), - pollId - ); + const optionIdRaw = await this.get( + 'govQueryApi' + ).getOptionVotingForRankedChoice(address.toLowerCase(), pollId); + const ballotBuffer = toBuffer(optionIdRaw, { endian: 'little' }); + const ballot = paddedArray(32 - ballotBuffer.length, ballotBuffer); + return ballot.reverse().filter(choice => choice !== 0 && choice !== '0'); } async getNumUniqueVoters(pollId) { diff --git a/packages/dai-plugin-governance/src/GovQueryApiService.js b/packages/dai-plugin-governance/src/GovQueryApiService.js index a7b878cd2..0bde279dc 100644 --- a/packages/dai-plugin-governance/src/GovQueryApiService.js +++ b/packages/dai-plugin-governance/src/GovQueryApiService.js @@ -120,7 +120,7 @@ export default class QueryApi extends PublicService { }`; const response = await this.getQueryResponse(this.serverUrl, query); if (!response.currentVote.nodes[0]) return null; - return response.currentVote.nodes[0].optionId; + return response.currentVote.nodes[0].optionIdRaw; } async getBlockNumber(unixTime) {