Skip to content

Commit

Permalink
fix: don't convert to cip129 non-drep voters
Browse files Browse the repository at this point in the history
  • Loading branch information
slowbackspace committed Dec 13, 2024
1 parent 1492789 commit 443278d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Support for CIP129 DRep ID - you can query DReps using both legacy format and CIP129 format. The `drep_id` and `hex` fields will reflect the format of the query param

### Changed

- looser validation for cost model size
- BREAKING CHANGE: Endpoints `/governance/dreps` and `/governance/proposals/{tx_hash}/{cert_index}/votes` are now using CIP129 format
- Looser validation for cost model size in `epochs/:num/parameters`

## [2.4.0] - 2024-11-20

Expand Down
7 changes: 6 additions & 1 deletion src/routes/governance/proposals/tx-hash/cert-index/votes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ async function route(fastify: FastifyInstance) {
gracefulRelease(clientDbSync);

for (const row of rows) {
// Convert voter id to cip129 format
if (!row.voter.startsWith('drep')) {
// Keep non-DRep voter unmodified
continue;
}

// Convert voter id to CIP129 format
const cip129DRep = dbSyncDRepToCIP129({
drep_id: row.voter,
has_script: row.voter_has_script,
Expand Down
3 changes: 0 additions & 3 deletions src/utils/governance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,11 @@ export const dbSyncDRepToCIP129 = <T extends { drep_id: string; has_script: bool
};

export interface DRepValidationResult {
// TODO: maybe rename to raw, raw prop to hex,
dbSync: {
id: string;
raw: string | null;
hasScript: boolean;
};
// cip129 is set when the bechDrepId
cip129: {
// CIP129 bech32 representation of dRep ID
id: string;
Expand Down Expand Up @@ -183,7 +181,6 @@ export const validateDRepId = (bechDrepId: string): DRepValidationResult => {
* @param {{drep_id: string; hex: string}} data - DRep dbsync data
* @returns Object - DRep data object with CIP-0129 compatible bech32 ID and hex in case of CIP-0129 drepId. Otherwise the data remain unmodified.
*
* @throws {Error} If the DRep ID prefix is invalid, an error is thrown.
*/
export const enhanceDRep = <T extends { drep_id: string; hex: string }>(
data: T,
Expand Down

0 comments on commit 443278d

Please sign in to comment.