diff --git a/.yarn/cache/@blockfrost-openapi-npm-0.1.61-beta.15-cb8ef7f224-29385370a8.zip b/.yarn/cache/@blockfrost-openapi-npm-0.1.61-beta.15-cb8ef7f224-29385370a8.zip deleted file mode 100644 index a1f8966e..00000000 Binary files a/.yarn/cache/@blockfrost-openapi-npm-0.1.61-beta.15-cb8ef7f224-29385370a8.zip and /dev/null differ diff --git a/.yarn/cache/@blockfrost-openapi-npm-0.1.61-beta.22-8259101df5-4aeaafe458.zip b/.yarn/cache/@blockfrost-openapi-npm-0.1.61-beta.22-8259101df5-4aeaafe458.zip new file mode 100644 index 00000000..b22ee29b Binary files /dev/null and b/.yarn/cache/@blockfrost-openapi-npm-0.1.61-beta.22-8259101df5-4aeaafe458.zip differ diff --git a/package.json b/package.json index 006b179a..1a8dcea5 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "dependencies": { "@blockfrost/blockfrost-js": "5.4.0", "@blockfrost/blockfrost-utils": "2.8.0", - "@blockfrost/openapi": "0.1.61-beta.15", + "@blockfrost/openapi": "0.1.61-beta.22", "@emurgo/cardano-serialization-lib-nodejs": "11.5.0", "@emurgo/cip14-js": "^3.0.1", "@fastify/cors": "^8.3.0", diff --git a/src/app.ts b/src/app.ts index bbca82fd..86209999 100644 --- a/src/app.ts +++ b/src/app.ts @@ -122,6 +122,11 @@ const start = (options = {}): FastifyInstance => { registerRoute(app, import('./routes/governance/dreps/drep-id/delegators.js')); registerRoute(app, import('./routes/governance/dreps/drep-id/metadata.js')); registerRoute(app, import('./routes/governance/dreps/drep-id/updates.js')); + registerRoute(app, import('./routes/governance/dreps/drep-id/votes.js')); + registerRoute(app, import('./routes/governance/proposals/index.js')); + registerRoute(app, import('./routes/governance/proposals/tx-hash/cert-index/index.js')); + registerRoute(app, import('./routes/governance/proposals/tx-hash/cert-index/votes.js')); + registerRoute(app, import('./routes/governance/votes.js')); } // health @@ -158,6 +163,7 @@ const start = (options = {}): FastifyInstance => { registerRoute(app, import('./routes/pools/pool-id/metadata.js')); registerRoute(app, import('./routes/pools/pool-id/relays.js')); registerRoute(app, import('./routes/pools/pool-id/updates.js')); + registerRoute(app, import('./routes/pools/pool-id/votes.js')); // root registerRoute(app, import('./routes/root/index.js')); diff --git a/src/routes/governance/dreps/drep-id/votes.ts b/src/routes/governance/dreps/drep-id/votes.ts new file mode 100644 index 00000000..936c87d8 --- /dev/null +++ b/src/routes/governance/dreps/drep-id/votes.ts @@ -0,0 +1,34 @@ +import { FastifyInstance, FastifyRequest } from 'fastify'; +import * as QueryTypes from '../../../../types/queries/governance.js'; +import * as ResponseTypes from '../../../../types/responses/governance.js'; +import { getDbSync } from '../../../../utils/database.js'; +import { SQLQuery } from '../../../../sql/index.js'; +import { getSchemaForEndpoint } from '@blockfrost/openapi'; + +async function route(fastify: FastifyInstance) { + fastify.route({ + url: '/governance/dreps/:drep_id/votes', + method: 'GET', + schema: getSchemaForEndpoint('/governance/dreps/{drep_id}/votes'), + + handler: async (request: FastifyRequest, reply) => { + const clientDbSync = await getDbSync(fastify); + + const { rows }: { rows: ResponseTypes.DRepsDrepIDVotes } = + await clientDbSync.query( + SQLQuery.get('governance_dreps_drep_id_votes'), + [request.query.order, request.query.count, request.query.page, request.params.drep_id], + ); + + clientDbSync.release(); + + if (rows.length === 0) { + return reply.send([]); + } + + return reply.send(rows); + }, + }); +} + +export default route; diff --git a/src/routes/governance/proposals/index.ts b/src/routes/governance/proposals/index.ts new file mode 100644 index 00000000..ce5ed671 --- /dev/null +++ b/src/routes/governance/proposals/index.ts @@ -0,0 +1,34 @@ +import { FastifyInstance, FastifyRequest } from 'fastify'; +import * as QueryTypes from '../../../types/queries/governance.js'; +import * as ResponseTypes from '../../../types/responses/governance.js'; +import { getDbSync } from '../../../utils/database.js'; +import { SQLQuery } from '../../../sql/index.js'; +import { getSchemaForEndpoint } from '@blockfrost/openapi'; + +async function route(fastify: FastifyInstance) { + fastify.route({ + url: '/governance/proposals', + method: 'GET', + schema: getSchemaForEndpoint('/governance/proposals'), + + handler: async (request: FastifyRequest, reply) => { + const clientDbSync = await getDbSync(fastify); + + const { rows }: { rows: ResponseTypes.DRepsDrepIDVotes } = + await clientDbSync.query( + SQLQuery.get('governance_proposals'), + [request.query.order, request.query.count, request.query.page], + ); + + clientDbSync.release(); + + if (rows.length === 0) { + return reply.send([]); + } + + return reply.send(rows); + }, + }); +} + +export default route; diff --git a/src/routes/governance/proposals/tx-hash/cert-index/index.ts b/src/routes/governance/proposals/tx-hash/cert-index/index.ts new file mode 100644 index 00000000..9f065ae5 --- /dev/null +++ b/src/routes/governance/proposals/tx-hash/cert-index/index.ts @@ -0,0 +1,35 @@ +import { FastifyInstance, FastifyRequest } from 'fastify'; +import * as QueryTypes from '../../../../../types/queries/governance.js'; +import * as ResponseTypes from '../../../../../types/responses/governance.js'; +import { getDbSync } from '../../../../../utils/database.js'; +import { SQLQuery } from '../../../../../sql/index.js'; +import { getSchemaForEndpoint } from '@blockfrost/openapi'; +import { handle404 } from '../../../../../utils/error-handler.js'; + +async function route(fastify: FastifyInstance) { + fastify.route({ + url: '/governance/proposals/:tx_hash/:cert_index', + method: 'GET', + schema: getSchemaForEndpoint('/governance/proposals/{tx_hash}/{cert_index}'), + + handler: async (request: FastifyRequest, reply) => { + const clientDbSync = await getDbSync(fastify); + + const { rows }: { rows: ResponseTypes.ProposalsProposal[] } = + await clientDbSync.query( + SQLQuery.get('governance_proposals_proposal'), + [request.params.tx_hash, request.params.cert_index], + ); + + clientDbSync.release(); + const row = rows[0]; + + if (!row) { + return handle404(reply); + } + return reply.send(row); + }, + }); +} + +export default route; diff --git a/src/routes/governance/proposals/tx-hash/cert-index/votes.ts b/src/routes/governance/proposals/tx-hash/cert-index/votes.ts new file mode 100644 index 00000000..11981248 --- /dev/null +++ b/src/routes/governance/proposals/tx-hash/cert-index/votes.ts @@ -0,0 +1,40 @@ +import { FastifyInstance, FastifyRequest } from 'fastify'; +import * as QueryTypes from '../../../../../types/queries/governance.js'; +import * as ResponseTypes from '../../../../../types/responses/governance.js'; +import { getDbSync } from '../../../../../utils/database.js'; +import { SQLQuery } from '../../../../../sql/index.js'; +import { getSchemaForEndpoint } from '@blockfrost/openapi'; + +async function route(fastify: FastifyInstance) { + fastify.route({ + url: '/governance/proposals/:tx_hash/:cert_index/votes', + method: 'GET', + schema: getSchemaForEndpoint('/governance/proposals/{tx_hash}/{cert_index}/votes'), + + handler: async (request: FastifyRequest, reply) => { + const clientDbSync = await getDbSync(fastify); + + const { rows }: { rows: ResponseTypes.ProposalsProposalVote } = + await clientDbSync.query( + SQLQuery.get('governance_proposals_proposal_votes'), + [ + request.query.order, + request.query.count, + request.query.page, + request.params.tx_hash, + request.params.cert_index, + ], + ); + + clientDbSync.release(); + + if (rows.length === 0) { + return reply.send([]); + } + + return reply.send(rows); + }, + }); +} + +export default route; diff --git a/src/routes/governance/votes.ts b/src/routes/governance/votes.ts new file mode 100644 index 00000000..9cf26a96 --- /dev/null +++ b/src/routes/governance/votes.ts @@ -0,0 +1,35 @@ +import { FastifyInstance, FastifyRequest } from 'fastify'; +import * as QueryTypes from '../../types/queries/governance.js'; +import * as ResponseTypes from '../../types/responses/governance.js'; +import { getDbSync } from '../../utils/database.js'; +import { SQLQuery } from '../../sql/index.js'; +import { getSchemaForEndpoint } from '@blockfrost/openapi'; + +async function route(fastify: FastifyInstance) { + fastify.route({ + url: '/governance/votes', + method: 'GET', + schema: getSchemaForEndpoint('/governance/votes'), + + handler: async (request: FastifyRequest, reply) => { + const clientDbSync = await getDbSync(fastify); + + const { rows }: { rows: ResponseTypes.DRepsDrepIDVotes } = + await clientDbSync.query(SQLQuery.get('governance_votes'), [ + request.query.order, + request.query.count, + request.query.page, + ]); + + clientDbSync.release(); + + if (rows.length === 0) { + return reply.send([]); + } + + return reply.send(rows); + }, + }); +} + +export default route; diff --git a/src/routes/pools/pool-id/votes.ts b/src/routes/pools/pool-id/votes.ts new file mode 100644 index 00000000..60235e7e --- /dev/null +++ b/src/routes/pools/pool-id/votes.ts @@ -0,0 +1,77 @@ +import { FastifyInstance, FastifyRequest } from 'fastify'; +import { getSchemaForEndpoint } from '@blockfrost/openapi'; +import { isUnpaged } from '../../../utils/routes.js'; +import { toJSONStream } from '../../../utils/string-utils.js'; +import { SQLQuery } from '../../../sql/index.js'; +import * as QueryTypes from '../../../types/queries/pools.js'; +import * as ResponseTypes from '../../../types/responses/pools.js'; +import { getDbSync } from '../../../utils/database.js'; +import { handle400Custom, handle404 } from '../../../utils/error-handler.js'; +import { validateAndConvertPool } from '../../../utils/validation.js'; + +async function route(fastify: FastifyInstance) { + fastify.route({ + url: '/pools/:pool_id/votes', + method: 'GET', + schema: getSchemaForEndpoint('/pools/{pool_id}/votes'), + handler: async (request: FastifyRequest, reply) => { + const clientDbSync = await getDbSync(fastify); + + try { + // validate (and convert hex->bech32 if needed) pool ID + const pool_id = validateAndConvertPool(request.params.pool_id); + + if (!pool_id) { + clientDbSync.release(); + return handle400Custom(reply, 'Invalid or malformed pool id format.'); + } + + const query404_pool = await clientDbSync.query( + SQLQuery.get('pools_404'), + [pool_id], + ); + + if (query404_pool.rows.length === 0) { + clientDbSync.release(); + return handle404(reply); + } + + const unpaged = isUnpaged(request); + const { rows }: { rows: ResponseTypes.PoolVotes } = unpaged + ? await clientDbSync.query( + SQLQuery.get('pools_pool_id_updates_unpaged'), + [request.query.order, pool_id], + ) + : await clientDbSync.query(SQLQuery.get('pools_pool_id_votes'), [ + request.query.order, + request.query.count, + request.query.page, + pool_id, + ]); + + clientDbSync.release(); + + if (rows.length === 0) { + return reply.send([]); + } + + if (unpaged) { + // Use of Reply.raw functions is at your own risk as you are skipping all the Fastify logic of handling the HTTP response + // https://www.fastify.io/docs/latest/Reference/Reply/#raw + reply.raw.writeHead(200, { 'Content-Type': 'application/json' }); + await toJSONStream(rows, reply.raw); + return reply; + } else { + return reply.send(rows); + } + } catch (error) { + if (clientDbSync) { + clientDbSync.release(); + } + throw error; + } + }, + }); +} + +export default route; diff --git a/src/sql/governance/dreps_drep_id_votes.sql b/src/sql/governance/dreps_drep_id_votes.sql new file mode 100644 index 00000000..c01c00a7 --- /dev/null +++ b/src/sql/governance/dreps_drep_id_votes.sql @@ -0,0 +1,29 @@ +SELECT encode(tx.hash, 'hex') AS "tx_hash", + vp.index AS "cert_index", + LOWER(vote::TEXT) AS "vote" -- Yes, No, Abstain -> yes,no,abstain +FROM voting_procedure vp + JOIN drep_hash dh ON (vp.drep_voter = dh.id) + JOIN tx ON (vp.tx_id = tx.id) +WHERE dh.view = $4 +ORDER BY CASE + WHEN LOWER($1) = 'desc' THEN vp.id + END DESC, + CASE + WHEN LOWER($1) <> 'desc' + OR $1 IS NULL THEN vp.id + END ASC +LIMIT CASE + WHEN $2 >= 1 + AND $2 <= 100 THEN $2 + ELSE 100 + END OFFSET CASE + WHEN $3 > 1 + AND $3 < 2147483647 THEN ($3 - 1) * ( + CASE + WHEN $2 >= 1 + AND $2 <= 100 THEN $2 + ELSE 100 + END + ) + ELSE 0 + END \ No newline at end of file diff --git a/src/sql/governance/proposals.sql b/src/sql/governance/proposals.sql new file mode 100644 index 00000000..51fe4c4e --- /dev/null +++ b/src/sql/governance/proposals.sql @@ -0,0 +1,31 @@ +SELECT encode(tx.hash, 'hex') AS "tx_hash", + ga.index AS "cert_index", + ( + LOWER( + regexp_replace(type::TEXT, '(?<=.{1})([A-Z])', '_\1', 'g') + ) + ) AS "governance_type" -- type HardForkInitiation, NewCommittee, NewConstitution, InfoAction, NoConfidence, ParameterChange, TreasuryWithdrawals +FROM governance_action ga + JOIN tx ON (ga.tx_id = tx.id) +ORDER BY CASE + WHEN LOWER($1) = 'desc' THEN ga.id + END DESC, + CASE + WHEN LOWER($1) <> 'desc' + OR $1 IS NULL THEN ga.id + END ASC +LIMIT CASE + WHEN $2 >= 1 + AND $2 <= 100 THEN $2 + ELSE 100 + END OFFSET CASE + WHEN $3 > 1 + AND $3 < 2147483647 THEN ($3 - 1) * ( + CASE + WHEN $2 >= 1 + AND $2 <= 100 THEN $2 + ELSE 100 + END + ) + ELSE 0 + END \ No newline at end of file diff --git a/src/sql/governance/proposals_proposal.sql b/src/sql/governance/proposals_proposal.sql new file mode 100644 index 00000000..ceb0b562 --- /dev/null +++ b/src/sql/governance/proposals_proposal.sql @@ -0,0 +1,24 @@ +SELECT encode(tx.hash, 'hex') AS "tx_hash", + ga.index AS "cert_index", + ( + LOWER( + regexp_replace(type::TEXT, '(?<=.{1})([A-Z])', '_\1', 'g') + ) + ) AS "governance_type", + -- type HardForkInitiation, NewCommittee, NewConstitution, InfoAction, NoConfidence, ParameterChange, TreasuryWithdrawals + ga.description AS "governance_description", + ga.deposit::TEXT AS "deposit", + sa.view AS "return_address", + ga.ratified_epoch AS "ratified_epoch", + ga.enacted_epoch AS "enacted_epoch", + ga.dropped_epoch AS "dropped_epoch", + ga.expired_epoch AS "expired_epoch", + ga.expiration AS "expiration", + va.url AS "anchor_url", + encode(va.data_hash, 'hex') AS "anchor_hash" +FROM governance_action ga + JOIN tx ON (ga.tx_id = tx.id) + JOIN stake_address sa ON (ga.return_address = sa.id) + LEFT JOIN voting_anchor va ON (va.id = ga.voting_anchor_id) +WHERE encode(tx.hash, 'hex') = $1 + AND ga.index = $2 \ No newline at end of file diff --git a/src/sql/governance/proposals_proposal_votes.sql b/src/sql/governance/proposals_proposal_votes.sql new file mode 100644 index 00000000..2e838f7c --- /dev/null +++ b/src/sql/governance/proposals_proposal_votes.sql @@ -0,0 +1,51 @@ +WITH queried_proposal AS ( + SELECT ga.id AS "id" + FROM governance_action ga + JOIN tx ON (ga.tx_id = tx.id) + WHERE encode(tx.hash, 'hex') = $4 + AND ga.index = $5 +) +SELECT encode(tx.hash, 'hex') AS "tx_hash", + vp.index AS "cert_index", + ( + CASE + WHEN vp.voter_role::TEXT = 'ConstitutionalCommittee' THEN 'constitutional_committee' + ELSE LOWER(vp.voter_role::TEXT) + END + ) AS "voter_role", + -- ConstitutionalCommittee, DRep, SPO -> constitutional_committee, drep, spo + ( + COALESCE(encode(committee_voter, 'hex'), dh.view, ph.view) + ) AS "voter", + LOWER(vote::TEXT) AS "vote" -- Yes, No, Abstain -> yes,no,abstain +FROM voting_procedure vp + JOIN governance_action ga ON (ga.id = vp.governance_action_id) + JOIN tx ON (vp.tx_id = tx.id) + LEFT JOIN drep_hash dh ON (vp.drep_voter = dh.id) + LEFT JOIN pool_hash ph ON (vp.pool_voter = ph.id) +WHERE ga.id = ( + SELECT id + FROM queried_proposal + ) +ORDER BY CASE + WHEN LOWER($1) = 'desc' THEN vp.id + END DESC, + CASE + WHEN LOWER($1) <> 'desc' + OR $1 IS NULL THEN vp.id + END ASC +LIMIT CASE + WHEN $2 >= 1 + AND $2 <= 100 THEN $2 + ELSE 100 + END OFFSET CASE + WHEN $3 > 1 + AND $3 < 2147483647 THEN ($3 - 1) * ( + CASE + WHEN $2 >= 1 + AND $2 <= 100 THEN $2 + ELSE 100 + END + ) + ELSE 0 + END \ No newline at end of file diff --git a/src/sql/governance/votes.sql b/src/sql/governance/votes.sql new file mode 100644 index 00000000..5af922fd --- /dev/null +++ b/src/sql/governance/votes.sql @@ -0,0 +1,47 @@ +SELECT encode(tx.hash, 'hex') AS "tx_hash", + vp.index AS "cert_index", + ( + CASE + WHEN vp.voter_role = 'ConstitutionalCommittee' THEN 'constitutional_committee' + ELSE LOWER(vp.voter_role::TEXT) + END + ) AS "voter_role", + -- ConstitutionalCommittee, DRep, SPO -> constitutional_committee, drep, spo + ( + CASE + WHEN vp.voter_role::TEXT = 'ConstitutionalCommittee' THEN 'constitutional_committee' + ELSE LOWER(vp.voter_role::TEXT) + END + ) AS "voter_role", + -- ConstitutionalCommittee, DRep, SPO -> constitutional_committee, drep, spo + ( + COALESCE(encode(committee_voter, 'hex'), dh.view, ph.view) + ) AS "voter", + LOWER(vote::TEXT) AS "vote" -- Yes, No, Abstain -> yes,no,abstain +FROM voting_procedure vp + JOIN governance_action ga ON (ga.id = vp.governance_action_id) + JOIN tx ON (vp.tx_id = tx.id) + LEFT JOIN drep_hash dh ON (vp.drep_voter = dh.id) + LEFT JOIN pool_hash ph ON (vp.pool_voter = ph.id) +ORDER BY CASE + WHEN LOWER($1) = 'desc' THEN vp.id + END DESC, + CASE + WHEN LOWER($1) <> 'desc' + OR $1 IS NULL THEN vp.id + END ASC +LIMIT CASE + WHEN $2 >= 1 + AND $2 <= 100 THEN $2 + ELSE 100 + END OFFSET CASE + WHEN $3 > 1 + AND $3 < 2147483647 THEN ($3 - 1) * ( + CASE + WHEN $2 >= 1 + AND $2 <= 100 THEN $2 + ELSE 100 + END + ) + ELSE 0 + END \ No newline at end of file diff --git a/src/sql/index.ts b/src/sql/index.ts index 94318c77..9a1bd3ef 100644 --- a/src/sql/index.ts +++ b/src/sql/index.ts @@ -92,6 +92,11 @@ const QUERY_FILES = { governance_dreps_drep_id_delegators: 'governance/dreps_drep_id_delegators.sql', governance_dreps_drep_id_metadata: 'governance/dreps_drep_id_metadata.sql', governance_dreps_drep_id_updates: 'governance/dreps_drep_id_updates.sql', + governance_dreps_drep_id_votes: 'governance/dreps_drep_id_votes.sql', + governance_proposals: 'governance/proposals.sql', + governance_proposals_proposal: 'governance/proposals_proposal.sql', + governance_proposals_proposal_votes: 'governance/proposals_proposal_votes.sql', + governance_votes: 'governance/votes.sql', metadata_txs_labels: 'metadata/metadata_txs_labels.sql', metadata_txs_labels_unpaged: 'metadata/unpaged/metadata_txs_labels.sql', metadata_txs_labels_label: 'metadata/metadata_txs_labels_label.sql', @@ -130,6 +135,7 @@ const QUERY_FILES = { pools_retiring_unpaged: 'pools/unpaged/pools_retiring.sql', pools_pool_id_updates: 'pools/pools_pool_id_updates.sql', pools_pool_id_updates_unpaged: 'pools/unpaged/pools_pool_id_updates.sql', + pools_pool_id_votes: 'pools/pools_pool_id_votes.sql', scripts_404: 'scripts/scripts_404.sql', scripts: 'scripts/scripts.sql', scripts_unpaged: 'scripts/unpaged/scripts.sql', diff --git a/src/sql/pools/pools_pool_id_votes.sql b/src/sql/pools/pools_pool_id_votes.sql new file mode 100644 index 00000000..307cbc8a --- /dev/null +++ b/src/sql/pools/pools_pool_id_votes.sql @@ -0,0 +1,29 @@ +SELECT encode(tx.hash, 'hex') AS "tx_hash", + vp.index AS "cert_index", + LOWER(vote::TEXT) AS "vote" -- Yes, No, Abstain -> yes,no,abstain +FROM voting_procedure vp + JOIN pool_hash ph ON (vp.pool_voter = ph.id) + JOIN tx ON (vp.tx_id = tx.id) +WHERE ph.view = $4 +ORDER BY CASE + WHEN LOWER($1) = 'desc' THEN vp.id + END DESC, + CASE + WHEN LOWER($1) <> 'desc' + OR $1 IS NULL THEN vp.id + END ASC +LIMIT CASE + WHEN $2 >= 1 + AND $2 <= 100 THEN $2 + ELSE 100 + END OFFSET CASE + WHEN $3 > 1 + AND $3 < 2147483647 THEN ($3 - 1) * ( + CASE + WHEN $2 >= 1 + AND $2 <= 100 THEN $2 + ELSE 100 + END + ) + ELSE 0 + END \ No newline at end of file diff --git a/src/types/queries/epochs.ts b/src/types/queries/epochs.ts index e9ab1388..e6de43fd 100644 --- a/src/types/queries/epochs.ts +++ b/src/types/queries/epochs.ts @@ -101,25 +101,25 @@ export interface EpochParameters { max_collateral_inputs: number; coins_per_utxo_word: string; // deprecated coins_per_utxo_size: string; - p1: number | null; - p2a: number | null; - p2b: number | null; - p3: number | null; - p4: number | null; - p5a: number | null; - p5b: number | null; - p5c: number | null; - p5d: number | null; - p6: number | null; - p7: number | null; - q1: number | null; - q2a: number | null; - q2b: number | null; - q4: number | null; - min_c_c_size: string | null; - cc_term_limit: string | null; - gov_expiration: string | null; - gov_deposit: string | null; + pvt_motion_no_confidence: number | null; + pvt_committee_normal: number | null; + pvt_committee_no_confidence: number | null; + pvt_hard_fork_initiation: number | null; + dvt_motion_no_confidence: number | null; + dvt_committee_normal: number | null; + dvt_committee_no_confidence: number | null; + dvt_update_to_constitution: number | null; + dvt_hard_fork_initiation: number | null; + dvt_p_p_network_group: number | null; + dvt_p_p_economic_group: number | null; + dvt_p_p_technical_group: number | null; + dvt_p_p_gov_group: number | null; + dvt_treasury_withdrawal: number | null; + committee_min_size: string | null; + committee_max_term_length: string | null; + gov_action_lifetime: string | null; + gov_action_deposit: string | null; + drep_deposit: string | null; drep_activity: string | null; registered_tx_id: number | null; } diff --git a/src/types/queries/governance.ts b/src/types/queries/governance.ts index bc2387ed..7c65ff73 100644 --- a/src/types/queries/governance.ts +++ b/src/types/queries/governance.ts @@ -51,11 +51,72 @@ export interface DRepsDrepIDMetadata { } export interface DRepsDrepIDUpdates { tx_hash: string; - /** @description Certificate within the transaction */ cert_index: number; - /** - * @description Action in the certificate - * @enum {string} - */ action: 'registered' | 'deregistered'; } + +export interface DRepsDrepIDVotes { + tx_hash: string; + cert_index: number; + voter_role: 'constitutional_committee' | 'drep' | 'spo'; + committee_voter_hash: string | null; + vote: 'yes' | 'no' | 'abstain'; +} + +export interface RequestParametersProposal { + Params: { + tx_hash: string; + cert_index: number; + }; +} + +export interface RequestParametersProposalVotes { + Params: { + tx_hash: string; + cert_index: number; + }; + Querystring: { + count: number; + page: number; + order: Order; + }; +} + +export interface Votes { + tx_hash: string; + cert_index: number; + voter_role: 'constitutional_committee' | 'drep' | 'spo'; + committee_voter_hash: string | null; + vote: 'yes' | 'no' | 'abstain'; +} + +export interface ProposalsProposal { + tx_hash: string; + cert_index: number; + governance_type: + | 'hard_fork_initiation' + | 'new_committee' + | 'new_constitution' + | 'info_action' + | 'no_confidence' + | 'parameter_change' + | 'treasury_withdrawals'; + governance_description: string | null; + deposit: string; + return_address: string; + ratified_epoch: number | null; + enacted_epoch: number | null; + dropped_epoch: number | null; + expired_epoch: number | null; + expiration: number; + anchor_url: string | null; + anchor_hash: string | null; +} + +export interface ProposalsProposalVote { + tx_hash: string; + cert_index: number; + voter_role: 'constitutional_committee' | 'drep' | 'spo'; + voter: string; + vote: 'yes' | 'no' | 'abstain'; +} diff --git a/src/types/queries/pools.ts b/src/types/queries/pools.ts index 9f65ee50..6e7fa95c 100644 --- a/src/types/queries/pools.ts +++ b/src/types/queries/pools.ts @@ -99,3 +99,11 @@ export interface PoolRelays { dns_srv: string; port: number; } + +export interface PoolVotes { + tx_hash: string; + cert_index: number; + voter_role: 'constitutional_committee' | 'drep' | 'spo'; + committee_voter_hash: string | null; + vote: 'yes' | 'no' | 'abstain'; +} diff --git a/src/types/responses/governance.ts b/src/types/responses/governance.ts index e66d9b21..6413d32c 100644 --- a/src/types/responses/governance.ts +++ b/src/types/responses/governance.ts @@ -5,3 +5,7 @@ export type DRepsDrepID = OpenApiResponseTypes['drep_details_content']; export type DRepsDrepIDMetadata = OpenApiResponseTypes['drep_metadata']; export type DRepsDrepIDUpdates = OpenApiResponseTypes['drep_updates']; export type DRepsDrepIDDelegators = OpenApiResponseTypes['drep_delegators']; +export type DRepsDrepIDVotes = OpenApiResponseTypes['drep_votes']; +export type Proposals = OpenApiResponseTypes['proposal_content']; +export type ProposalsProposal = OpenApiResponseTypes['proposal_details_content']; +export type ProposalsProposalVote = OpenApiResponseTypes['proposal_details_votes']; diff --git a/src/types/responses/pools.ts b/src/types/responses/pools.ts index 96731bd6..a4d27c0b 100644 --- a/src/types/responses/pools.ts +++ b/src/types/responses/pools.ts @@ -9,3 +9,4 @@ export type PoolBlocks = OpenApiResponseTypes['pool_blocks']; export type PoolHistory = OpenApiResponseTypes['pool_history']; export type PoolUpdates = OpenApiResponseTypes['pool_updates']; export type PoolRelays = OpenApiResponseTypes['pool_relays']; +export type PoolVotes = OpenApiResponseTypes['pool_votes']; diff --git a/yarn-project.nix b/yarn-project.nix index daeffb72..26a27cc1 100644 --- a/yarn-project.nix +++ b/yarn-project.nix @@ -1085,7 +1085,7 @@ cacheEntries = { "word-wrap@npm:1.2.3" = { filename = "word-wrap-npm-1.2.3-7fb15ab002-30b48f91fc.zip"; sha512 = "30b48f91fcf12106ed3186ae4fa86a6a1842416df425be7b60485de14bec665a54a68e4b5156647dec3a70f25e84d270ca8bc8cd23182ed095f5c7206a938c1f"; }; "type-check@npm:0.3.2" = { filename = "type-check-npm-0.3.2-a4a38bb0b6-dd3b149564.zip"; sha512 = "dd3b1495642731bc0e1fc40abe5e977e0263005551ac83342ecb6f4f89551d106b368ec32ad3fb2da19b3bd7b2d1f64330da2ea9176d8ddbfe389fb286eb5124"; }; "levn@npm:0.3.0" = { filename = "levn-npm-0.3.0-48d774b1c2-0d084a5242.zip"; sha512 = "0d084a524231a8246bb10fec48cdbb35282099f6954838604f3c7fc66f2e16fa66fd9cc2f3f20a541a113c4dafdf181e822c887c8a319c9195444e6c64ac395e"; }; -"@blockfrost/openapi@npm:0.1.61-beta.15" = { filename = "@blockfrost-openapi-npm-0.1.61-beta.15-cb8ef7f224-29385370a8.zip"; sha512 = "29385370a8981efc37cd1948ffb157e34b3a52c2a3231d27f87043cd86856120a0ecdc5fe01919ffb00853acf4be5b3bc085a842869a17c4f35ac6631a1166ed"; }; +"@blockfrost/openapi@npm:0.1.61-beta.22" = { filename = "@blockfrost-openapi-npm-0.1.61-beta.22-8259101df5-4aeaafe458.zip"; sha512 = "4aeaafe458b7ca6afb83022b91a0109a578db478af1d0a0351ea11c008898b65621cc24154e079e7817562db9fc205e78acdde8526c17622ca07ca6a91964dfd"; }; "yaml@npm:2.3.4" = { filename = "yaml-npm-2.3.4-8bb6dc2c0d-e6d1dae1c6.zip"; sha512 = "e6d1dae1c6383bcc8ba11796eef3b8c02d5082911c6723efeeb5ba50fc8e881df18d645e64de68e421b577296000bea9c75d6d9097c2f6699da3ae0406c030d8"; }; "cbor@npm:9.0.1" = { filename = "cbor-npm-9.0.1-3a5a6b7751-42333ac3d4.zip"; sha512 = "42333ac3d42cc3f6fcc7a529e68417a2dd8099eda43ca4be1304cdc5bc7494efe058e2db8a3d3b46ae60d69c7331ea813c22dbd019c4ac592d23e599d72bbcc9"; }; }; diff --git a/yarn.lock b/yarn.lock index eaabc7ce..8761526b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -136,14 +136,14 @@ __metadata: languageName: node linkType: hard -"@blockfrost/openapi@npm:0.1.61-beta.15": - version: 0.1.61-beta.15 - resolution: "@blockfrost/openapi@npm:0.1.61-beta.15" +"@blockfrost/openapi@npm:0.1.61-beta.22": + version: 0.1.61-beta.22 + resolution: "@blockfrost/openapi@npm:0.1.61-beta.22" dependencies: ajv: ^8.12.0 cbor: ^9.0.1 yaml: ^2.3.4 - checksum: 29385370a8981efc37cd1948ffb157e34b3a52c2a3231d27f87043cd86856120a0ecdc5fe01919ffb00853acf4be5b3bc085a842869a17c4f35ac6631a1166ed + checksum: 4aeaafe458b7ca6afb83022b91a0109a578db478af1d0a0351ea11c008898b65621cc24154e079e7817562db9fc205e78acdde8526c17622ca07ca6a91964dfd languageName: node linkType: hard @@ -1956,7 +1956,7 @@ __metadata: "@blockfrost/blockfrost-js": 5.4.0 "@blockfrost/blockfrost-tests": 1.10.0 "@blockfrost/blockfrost-utils": 2.8.0 - "@blockfrost/openapi": 0.1.61-beta.15 + "@blockfrost/openapi": 0.1.61-beta.22 "@emurgo/cardano-serialization-lib-nodejs": 11.5.0 "@emurgo/cip14-js": ^3.0.1 "@esbuild/darwin-x64": "npm:0.16.17"