diff --git a/src/routes/governance/proposals/tx-hash/cert-index/votes.ts b/src/routes/governance/proposals/tx-hash/cert-index/votes.ts index a228f29c..8c71ee17 100644 --- a/src/routes/governance/proposals/tx-hash/cert-index/votes.ts +++ b/src/routes/governance/proposals/tx-hash/cert-index/votes.ts @@ -4,7 +4,7 @@ import * as ResponseTypes from '../../../../../types/responses/governance.js'; import { getDbSync, gracefulRelease } from '../../../../../utils/database.js'; import { SQLQuery } from '../../../../../sql/index.js'; import { getSchemaForEndpoint } from '@blockfrost/openapi'; -import { dbSyncDRepToCIP129 } from '../../../../../utils/governance.js'; +import { dbSyncDRepToCIP129, getCommitteeCredentialId } from '../../../../../utils/governance.js'; import { isUnpaged } from '../../../../../utils/routes.js'; export const proposalVotesHandler = async ( @@ -38,8 +38,15 @@ export const proposalVotesHandler = async ( gracefulRelease(clientDbSync); for (const row of rows) { + if (row.voter_role === 'constitutional_committee') { + // db-sync stores the raw hot credential hash which does not distinguish + // key hashes from script hashes; encode it as a CIP-129 cc_hot id + row.voter = getCommitteeCredentialId('hot', row.voter, row.cc_voter_has_script ?? false); + continue; + } + if (!row.voter.startsWith('drep')) { - // Keep non-DRep voter unmodified + // Keep SPO voter unmodified continue; } diff --git a/src/sql/governance/proposals_proposal_votes.sql b/src/sql/governance/proposals_proposal_votes.sql index 492b58ea..ac18efc6 100644 --- a/src/sql/governance/proposals_proposal_votes.sql +++ b/src/sql/governance/proposals_proposal_votes.sql @@ -11,6 +11,7 @@ SELECT encode(vp_tx.hash, 'hex') AS "tx_hash", COALESCE(encode(ch.raw, 'hex'), dh.view, ph.view) ) AS "voter", dh.has_script AS "voter_has_script", + ch.has_script AS "cc_voter_has_script", LOWER(vote::TEXT) AS "vote" -- Yes, No, Abstain -> yes,no,abstain FROM gov_action_proposal gap JOIN tx gap_tx ON (gap_tx.id = gap.tx_id) diff --git a/src/sql/governance/unpaged/proposals_proposal_votes.sql b/src/sql/governance/unpaged/proposals_proposal_votes.sql index 270ede47..155741c4 100644 --- a/src/sql/governance/unpaged/proposals_proposal_votes.sql +++ b/src/sql/governance/unpaged/proposals_proposal_votes.sql @@ -11,6 +11,7 @@ SELECT encode(vp_tx.hash, 'hex') AS "tx_hash", COALESCE(encode(ch.raw, 'hex'), dh.view, ph.view) ) AS "voter", dh.has_script AS "voter_has_script", + ch.has_script AS "cc_voter_has_script", LOWER(vote::TEXT) AS "vote" -- Yes, No, Abstain -> yes,no,abstain FROM gov_action_proposal gap JOIN tx gap_tx ON (gap_tx.id = gap.tx_id) diff --git a/src/types/queries/governance.ts b/src/types/queries/governance.ts index 3eff92ab..13ff8535 100644 --- a/src/types/queries/governance.ts +++ b/src/types/queries/governance.ts @@ -180,6 +180,7 @@ export interface ProposalsProposalVotes { voter_role: 'constitutional_committee' | 'drep' | 'spo'; voter: string; voter_has_script: boolean; + cc_voter_has_script: boolean | null; vote: 'yes' | 'no' | 'abstain'; }