Skip to content

Commit

Permalink
fix(cip-1694): enable schema for delgators and updates
Browse files Browse the repository at this point in the history
  • Loading branch information
1000101 committed Dec 17, 2023
1 parent 3ba9b33 commit 5bd15dd
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 20 deletions.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"dependencies": {
"@blockfrost/blockfrost-js": "5.4.0",
"@blockfrost/blockfrost-utils": "2.8.0",
"@blockfrost/openapi": "0.1.61-beta.0",
"@blockfrost/openapi": "0.1.61-beta.3",
"@emurgo/cardano-serialization-lib-nodejs": "11.5.0",
"@emurgo/cip14-js": "^3.0.1",
"@fastify/cors": "^8.3.0",
Expand Down
5 changes: 2 additions & 3 deletions src/routes/governance/dreps/drep-id/delegators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ 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 { getSchemaForEndpoint } from '@blockfrost/openapi';

async function route(fastify: FastifyInstance) {
fastify.route({
url: '/governance/dreps/:drep_id/delegators',
method: 'GET',
// TODO: SCHEMA
// schema: getSchemaForEndpoint('/governance/dreps/{drep_id}/delegators'),
schema: getSchemaForEndpoint('/governance/dreps/{drep_id}/delegators'),

handler: async (request: FastifyRequest<QueryTypes.RequestParametersDRepID>, reply) => {
const clientDbSync = await getDbSync(fastify);
Expand Down
6 changes: 3 additions & 3 deletions src/routes/governance/dreps/drep-id/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import * as ResponseTypes from '../../../../types/responses/governance.js';
import { getDbSync } from '../../../../utils/database.js';
import { handle404 } from '../../../../utils/error-handler.js';
import { SQLQuery } from '../../../../sql/index.js';
//import { getSchemaForEndpoint } from '@blockfrost/openapi';
import { getSchemaForEndpoint } from '@blockfrost/openapi';

async function route(fastify: FastifyInstance) {
fastify.route({
url: '/governance/dreps/:drep_id',
method: 'GET',
// TODO: SCHEMA
//schema: getSchemaForEndpoint('/governance/dreps/{drep_id}'),
schema: getSchemaForEndpoint('/governance/dreps/{drep_id}'),

handler: async (request: FastifyRequest<QueryTypes.RequestDRepID>, reply) => {
const clientDbSync = await getDbSync(fastify);

Expand Down
6 changes: 3 additions & 3 deletions src/routes/governance/dreps/drep-id/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import * as ResponseTypes from '../../../../types/responses/governance.js';
import { getDbSync } from '../../../../utils/database.js';
import { handle404 } from '../../../../utils/error-handler.js';
import { SQLQuery } from '../../../../sql/index.js';
//import { getSchemaForEndpoint } from '@blockfrost/openapi';
import { getSchemaForEndpoint } from '@blockfrost/openapi';

async function route(fastify: FastifyInstance) {
fastify.route({
url: '/governance/dreps/:drep_id/metadata',
method: 'GET',
// TODO: SCHEMA
// schema: getSchemaForEndpoint('/governance/dreps/{drep_id}/metadata'),
schema: getSchemaForEndpoint('/governance/dreps/{drep_id}/metadata'),

handler: async (request: FastifyRequest<QueryTypes.RequestDRepID>, reply) => {
const clientDbSync = await getDbSync(fastify);

Expand Down
7 changes: 3 additions & 4 deletions src/routes/governance/dreps/drep-id/updates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,21 @@ 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 { getSchemaForEndpoint } from '@blockfrost/openapi';

async function route(fastify: FastifyInstance) {
fastify.route({
url: '/governance/dreps/:drep_id/updates',
method: 'GET',
// TODO: SCHEMA
// schema: getSchemaForEndpoint('/governance/dreps/{drep_id}/updates'),
schema: getSchemaForEndpoint('/governance/dreps/{drep_id}/updates'),

handler: async (request: FastifyRequest<QueryTypes.RequestParametersDRepID>, reply) => {
const clientDbSync = await getDbSync(fastify);

const { rows }: { rows: ResponseTypes.DRepsDrepIDUpdates } =
await clientDbSync.query<QueryTypes.DRepsDrepIDUpdates>(
SQLQuery.get('governance_dreps_drep_id_updates'),
[request.query.order, request.query.count, request.query.page, request.params.drep_id],
[(request.query.order, request.query.count, request.query.page, request.params.drep_id)],
);

clientDbSync.release();
Expand Down
2 changes: 1 addition & 1 deletion yarn-project.nix
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ cacheEntries = {
"JSONStream@npm:1.3.5" = { filename = "JSONStream-npm-1.3.5-1987f2e6dd-2605fa1242.zip"; sha512 = "2605fa124260c61bad38bb65eba30d2f72216a78e94d0ab19b11b4e0327d572b8d530c0c9cc3b0764f727ad26d39e00bf7ebad57781ca6368394d73169c59e46"; };
"eslint-plugin-prettier@npm:5.0.0" = { filename = "eslint-plugin-prettier-npm-5.0.0-2f21113cba-84e88744b9.zip"; sha512 = "84e88744b9050f2d5ef31b94e85294dda16f3a53c2449f9d33eac8ae6264889b459bf35a68e438fb6b329c2a1d6491aac4bfa00d86317e7009de3dad0311bec6"; };
"supertest@npm:6.3.3" = { filename = "supertest-npm-6.3.3-2e2b5bc83a-38239e517f.zip"; sha512 = "38239e517f7ba62b7a139a79c5c48d55f8d67b5ff4b6e51d5b07732ca8bbc4a28ffa1b10916fbb403dd013a054dbf028edc5850057d9a43aecbff439d494673e"; };
"@blockfrost/openapi@npm:0.1.61-beta.0" = { filename = "@blockfrost-openapi-npm-0.1.61-beta.0-32e9de66b5-d8041d9159.zip"; sha512 = "d8041d9159784111a639810d8297f5787608eabd6dcdf0d9b3648f8f8c7ce0598ca3cc6afb0a8fa99ce51e5176ca187f264839a4fdf7a2fa0d888a796d8a7064"; };
"@blockfrost/openapi@npm:0.1.61-beta.3" = { filename = "@blockfrost-openapi-npm-0.1.61-beta.3-df13aa2be1-2ad49b931a.zip"; sha512 = "2ad49b931a6f91fc17ca7f1c5d651f4272ced90e4d46e370a4f6c86eb69e39ffb1aee29deca80382d47cde575e1176113f090f88ad49df7400b7345bed1ea169"; };
"@types/pg@npm:8.10.2" = { filename = "@types-pg-npm-8.10.2-de8ade0e64-49da89f64c.zip"; sha512 = "49da89f64cec1bd12a3fbc0c72b17d685c2fee579726a529f62fcab395dbc5696d80455073409947a577164b3c53a90181a331e4a5d9357679f724d4ce37f4b9"; };
"axios@npm:1.5.0" = { filename = "axios-npm-1.5.0-35a845e191-e7405a5dbb.zip"; sha512 = "e7405a5dbbea97760d0e6cd58fecba311b0401ddb4a8efbc4108f5537da9b3f278bde566deb777935a960beec4fa18e7b8353881f2f465e4f2c0e949fead35be"; };
"@types/express@npm:4.17.17" = { filename = "@types-express-npm-4.17.17-46fe8173db-0196dacc27.zip"; sha512 = "0196dacc275ac3ce89d7364885cb08e7fb61f53ca101f65886dbf1daf9b7eb05c0943e2e4bbd01b0cc5e50f37e0eea7e4cbe97d0304094411ac73e1b7998f4da"; };
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,14 @@ __metadata:
languageName: node
linkType: hard

"@blockfrost/openapi@npm:0.1.61-beta.0":
version: 0.1.61-beta.0
resolution: "@blockfrost/openapi@npm:0.1.61-beta.0"
"@blockfrost/openapi@npm:0.1.61-beta.3":
version: 0.1.61-beta.3
resolution: "@blockfrost/openapi@npm:0.1.61-beta.3"
dependencies:
ajv: ^8.12.0
cbor: ^9.0.1
yaml: ^2.3.4
checksum: d8041d9159784111a639810d8297f5787608eabd6dcdf0d9b3648f8f8c7ce0598ca3cc6afb0a8fa99ce51e5176ca187f264839a4fdf7a2fa0d888a796d8a7064
checksum: 2ad49b931a6f91fc17ca7f1c5d651f4272ced90e4d46e370a4f6c86eb69e39ffb1aee29deca80382d47cde575e1176113f090f88ad49df7400b7345bed1ea169
languageName: node
linkType: hard

Expand Down Expand Up @@ -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.0
"@blockfrost/openapi": 0.1.61-beta.3
"@emurgo/cardano-serialization-lib-nodejs": 11.5.0
"@emurgo/cip14-js": ^3.0.1
"@esbuild/darwin-x64": "npm:0.16.17"
Expand Down

0 comments on commit 5bd15dd

Please sign in to comment.