Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/routes/governance/proposals/tx-hash/cert-index/votes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions src/sql/governance/proposals_proposal_votes.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/sql/governance/unpaged/proposals_proposal_votes.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/types/queries/governance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

Expand Down
Loading