From b34ef89c340d9b670a67ff5d407a5ed72dedb19d Mon Sep 17 00:00:00 2001 From: slowbackspace Date: Thu, 31 Oct 2024 14:05:09 +0100 Subject: [PATCH 1/3] feat: add DReps endpoints --- .vscode/settings.json | 3 +- CHANGELOG.MD | 4 + src/BlockFrostAPI.ts | 21 ++ src/endpoints/api/governance/dreps/index.ts | 252 +++++++++++++++++ test/fixtures/endpoints.ts | 297 ++++++++++++++++++++ 5 files changed, 576 insertions(+), 1 deletion(-) create mode 100644 src/endpoints/api/governance/dreps/index.ts diff --git a/.vscode/settings.json b/.vscode/settings.json index d57d4141..2fda706d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -14,6 +14,8 @@ "commitlint", "delegators", "deregistrations", + "drep", + "dreps", "emurgo", "id", "io", @@ -41,5 +43,4 @@ "**/.pnp.*": true }, "eslint.nodePath": ".yarn/sdks", - "prettier.prettierPath": ".yarn/sdks/prettier/index.js" } diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 1c6254a0..b967b185 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- methods for querying governance DReps endpoints - `dreps`, `drepsById`, `drepsByIdDelegators`, `drepsByIdDelegatorsAll`, `drepsByIdMetadata`, `drepsByIdUpdates`, `drepsByIdUpdatesAll`, `drepsByIdVotes`, `drepsByIdVotesAll` + ## [5.6.0] - 2024-10-03 ### Added diff --git a/src/BlockFrostAPI.ts b/src/BlockFrostAPI.ts index 7c57c611..679d81ee 100644 --- a/src/BlockFrostAPI.ts +++ b/src/BlockFrostAPI.ts @@ -60,6 +60,17 @@ import { blocksAddressesAll, } from './endpoints/api/blocks'; +import { + dreps, + drepsById, + drepsByIdDelegators, + drepsByIdDelegatorsAll, + drepsByIdMetadata, + drepsByIdUpdates, + drepsByIdUpdatesAll, + drepsByIdVotes, + drepsByIdVotesAll, +} from './endpoints/api/governance/dreps'; import { epochs, epochsBlocks, @@ -257,6 +268,16 @@ class BlockFrostAPI { blocksAddresses = blocksAddresses; blocksAddressesAll = blocksAddressesAll; + dreps = dreps; + drepsById = drepsById; + drepsByIdDelegators = drepsByIdDelegators; + drepsByIdDelegatorsAll = drepsByIdDelegatorsAll; + drepsByIdMetadata = drepsByIdMetadata; + drepsByIdUpdates = drepsByIdUpdates; + drepsByIdUpdatesAll = drepsByIdUpdatesAll; + drepsByIdVotes = drepsByIdVotes; + drepsByIdVotesAll = drepsByIdVotesAll; + epochs = epochs; epochsBlocks = epochsBlocks; epochsBlocksAll = epochsBlocksAll; diff --git a/src/endpoints/api/governance/dreps/index.ts b/src/endpoints/api/governance/dreps/index.ts new file mode 100644 index 00000000..d8e17446 --- /dev/null +++ b/src/endpoints/api/governance/dreps/index.ts @@ -0,0 +1,252 @@ +import { getPaginationOptions, paginateMethod } from '../../../../utils'; +import { components } from '@blockfrost/openapi'; +import { BlockFrostAPI } from '../../../../index'; +import { AllMethodOptions, PaginationOptions } from '../../../../types'; +import { handleError } from '../../../../utils/errors'; + +/** + * Obtains list of Delegate Representatives (DReps). + * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/dreps | API docs for of Delegate Representatives (DReps)} + * + * @param pagination - Optional, Pagination options + * @returns List of registered stake pools. + * + */ +export async function dreps( + this: BlockFrostAPI, + pagination?: PaginationOptions, +): Promise { + const paginationOptions = getPaginationOptions(pagination); + + try { + const res = await this.instance( + `governance/dreps`, + { + searchParams: { + page: paginationOptions.page, + count: paginationOptions.count, + order: paginationOptions.order, + }, + }, + ); + return res.body; + } catch (error) { + throw handleError(error); + } +} + +/** + * Obtains information of a specific DRep. + * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/dreps/%7Bdrep_id%7D | API docs for Stake Pool} + * + * @param drepId - DRep ID + * @returns Information of a specific DRep + * + */ +export async function drepsById( + this: BlockFrostAPI, + drepId: string, +): Promise { + try { + const res = await this.instance( + `governance/dreps/${drepId}`, + ); + return res.body; + } catch (error) { + throw handleError(error); + } +} + +/** + * Obtains DRep metadata. + * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/dreps/%7Bdrep_id%7D/metadata | API docs for DRep Metadata} + * + * @param drepId - DRep ID + * @returns DRep Metadata + * + */ +export async function drepsByIdMetadata( + this: BlockFrostAPI, + drepId: string, + pagination?: PaginationOptions, +): Promise { + const paginationOptions = getPaginationOptions(pagination); + + try { + const res = await this.instance( + `governance/dreps/${drepId}/metadata`, + { + searchParams: { + page: paginationOptions.page, + count: paginationOptions.count, + order: paginationOptions.order, + }, + }, + ); + return res.body; + } catch (error) { + throw handleError(error); + } +} + +/** + * Obtains current DRep delegators. + * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/dreps/%7Bdrep_id%7D/delegators | API docs for DRep Delegators} + * + * @param drepId - DRep ID + * @returns Current DRep delegators + * + */ +export async function drepsByIdDelegators( + this: BlockFrostAPI, + drepId: string, + pagination?: PaginationOptions, +): Promise { + const paginationOptions = getPaginationOptions(pagination); + + try { + const res = await this.instance( + `governance/dreps/${drepId}/delegators`, + { + searchParams: { + page: paginationOptions.page, + count: paginationOptions.count, + order: paginationOptions.order, + }, + }, + ); + return res.body; + } catch (error) { + throw handleError(error); + } +} + +/** + * Obtains current DRep delegators. + * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/dreps/%7Bdrep_id%7D/delegators | API docs for DRep Delegators} + * @remarks + * Variant of `drepsByIdDelegators` method for fetching all pages with built-in requests batching + * + * @param drepId - DRep ID + * @param allMethodOptions - Optional, Options for request batching + * @returns Current DRep delegators + * + */ +export async function drepsByIdDelegatorsAll( + this: BlockFrostAPI, + drepId: string, + allMethodOptions?: AllMethodOptions, +): Promise { + return paginateMethod( + pagination => this.drepsByIdDelegators(drepId, pagination), + allMethodOptions, + ); +} + +/** + * Obtains List of certificate updates to the DRep. + * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/dreps/%7Bdrep_id%7D/updates | API docs for DRep Updates} + * + * @param drepId - DRep ID + * @returns List of certificate updates to the DRep + * + */ +export async function drepsByIdUpdates( + this: BlockFrostAPI, + drepId: string, + pagination?: PaginationOptions, +): Promise { + const paginationOptions = getPaginationOptions(pagination); + + try { + const res = await this.instance( + `governance/dreps/${drepId}/updates`, + { + searchParams: { + page: paginationOptions.page, + count: paginationOptions.count, + order: paginationOptions.order, + }, + }, + ); + return res.body; + } catch (error) { + throw handleError(error); + } +} + +/** + * Obtains List of certificate updates to the DRep. + * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/dreps/%7Bdrep_id%7D/updates | API docs for History of DRep updates} + * @remarks + * Variant of `drepsByIdUpdates` method for fetching all pages with built-in requests batching + * + * @param drepId - DRep ID + * @param allMethodOptions - Optional, Options for request batching + * @returns List of certificate updates to the DRep + * + */ +export async function drepsByIdUpdatesAll( + this: BlockFrostAPI, + drepId: string, + allMethodOptions?: AllMethodOptions, +): Promise { + return paginateMethod( + pagination => this.drepsByIdUpdates(drepId, pagination), + allMethodOptions, + ); +} + +/** + * Obtains History of DRep votes. + * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/dreps/%7Bdrep_id%7D/votes | API docs for History of DRep votes} + * + * @param drepId - DRep ID + * @returns History of DRep votes + * + */ +export async function drepsByIdVotes( + this: BlockFrostAPI, + drepId: string, + pagination?: PaginationOptions, +): Promise { + const paginationOptions = getPaginationOptions(pagination); + + try { + const res = await this.instance( + `governance/dreps/${drepId}/votes`, + { + searchParams: { + page: paginationOptions.page, + count: paginationOptions.count, + order: paginationOptions.order, + }, + }, + ); + return res.body; + } catch (error) { + throw handleError(error); + } +} + +/** + * Obtains History of DRep votes. + * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/dreps/%7Bdrep_id%7D/votes | API docs for History of DRep votes} + * @remarks + * Variant of `drepsByIdVotes` method for fetching all pages with built-in requests batching + * + * @param drepId - DRep ID + * @param allMethodOptions - Optional, Options for request batching + * @returns History of DRep votes + * + */ +export async function drepsByIdVotesAll( + this: BlockFrostAPI, + drepId: string, + allMethodOptions?: AllMethodOptions, +): Promise { + return paginateMethod( + pagination => this.drepsByIdVotes(drepId, pagination), + allMethodOptions, + ); +} diff --git a/test/fixtures/endpoints.ts b/test/fixtures/endpoints.ts index 07ff9d31..2109b856 100644 --- a/test/fixtures/endpoints.ts +++ b/test/fixtures/endpoints.ts @@ -983,4 +983,301 @@ export default [ }, }, }, + { + command: (SDK: BlockFrostAPI) => SDK.dreps(), + path: mainnetUrl(`governance/dreps`), + endpointMock: [ + { + drep_id: 'drep1mvdu8slennngja7w4un6knwezufra70887zuxpprd64jxfveahn', + hex: 'db1bc3c3f99ce68977ceaf27ab4dd917123ef9e73f85c304236eab23', + }, + { + drep_id: 'drep1cxayn4fgy27yaucvhamsvqj3v6835mh3tjjx6x8hdnr4', + hex: 'c1ba49d52822bc4ef30cbf77060251668f1a6ef15ca46d18f76cc758', + }, + ], + response: [ + { + drep_id: 'drep1mvdu8slennngja7w4un6knwezufra70887zuxpprd64jxfveahn', + hex: 'db1bc3c3f99ce68977ceaf27ab4dd917123ef9e73f85c304236eab23', + }, + { + drep_id: 'drep1cxayn4fgy27yaucvhamsvqj3v6835mh3tjjx6x8hdnr4', + hex: 'c1ba49d52822bc4ef30cbf77060251668f1a6ef15ca46d18f76cc758', + }, + ], + }, + { + command: (SDK: BlockFrostAPI) => + SDK.drepsById('drep1mvdu8slennngja7w4un6knwezufra70887zuxpprd64jxfveahn'), + path: mainnetUrl( + `governance/dreps/drep1mvdu8slennngja7w4un6knwezufra70887zuxpprd64jxfveahn`, + ), + endpointMock: { + drep_id: 'drep15cfxz9exyn5rx0807zvxfrvslrjqfchrd4d47kv9e0f46uedqtc', + hex: 'a61261172624e8333ceff098648d90f8e404e2e36d5b5f5985cbd35d', + amount: '2000000', + active: true, + active_epoch: 420, + has_script: true, + }, + response: { + drep_id: 'drep15cfxz9exyn5rx0807zvxfrvslrjqfchrd4d47kv9e0f46uedqtc', + hex: 'a61261172624e8333ceff098648d90f8e404e2e36d5b5f5985cbd35d', + amount: '2000000', + active: true, + active_epoch: 420, + has_script: true, + }, + }, + { + command: (SDK: BlockFrostAPI) => + SDK.drepsByIdMetadata( + 'drep1mvdu8slennngja7w4un6knwezufra70887zuxpprd64jxfveahn', + ), + path: mainnetUrl( + `governance/dreps/drep1mvdu8slennngja7w4un6knwezufra70887zuxpprd64jxfveahn/metadata`, + ), + endpointMock: { + drep_id: 'drep15cfxz9exyn5rx0807zvxfrvslrjqfchrd4d47kv9e0f46uedqtc', + hex: 'a61261172624e8333ceff098648d90f8e404e2e36d5b5f5985cbd35d', + url: 'https://aaa.xyz/drep.json', + hash: 'a14a5ad4f36bddc00f92ddb39fd9ac633c0fd43f8bfa57758f9163d10ef916de', + json_metadata: { + '@context': { + CIP100: + 'https://github.com/cardano-foundation/CIPs/blob/master/CIP-0100/README.md#', + CIP119: + 'https://github.com/cardano-foundation/CIPs/blob/master/CIP-0119/README.md#', + hashAlgorithm: 'CIP100:hashAlgorithm', + body: { + '@id': 'CIP119:body', + '@context': { + references: { + '@id': 'CIP119:references', + '@container': '@set', + '@context': { + GovernanceMetadata: 'CIP100:GovernanceMetadataReference', + Other: 'CIP100:OtherReference', + label: 'CIP100:reference-label', + uri: 'CIP100:reference-uri', + }, + }, + paymentAddress: 'CIP119:paymentAddress', + givenName: 'CIP119:givenName', + image: { + '@id': 'CIP119:image', + '@context': { + ImageObject: 'https://schema.org/ImageObject', + }, + }, + objectives: 'CIP119:objectives', + motivations: 'CIP119:motivations', + qualifications: 'CIP119:qualifications', + }, + }, + }, + hashAlgorithm: 'blake2b-256', + body: { + paymentAddress: + 'addr1q86dnpkva4mm859c8ur7tjxn57zgsu6vg8pdetkdve3fsacnq7twy06u2ev5759vutpjgzfryx0ud8hzedhzerava35qwh3x34', + givenName: 'Ryan Williams', + image: { + '@type': 'ImageObject', + contentUrl: 'https://avatars.githubusercontent.com/u/44342099?v=4', + sha256: + '2a21e4f7b20c8c72f573707b068fb8fc6d8c64d5035c4e18ecae287947fe2b2e', + }, + objectives: 'Buy myself an island.', + motivations: 'I really would like to own an island.', + qualifications: + 'I have my 100m swimming badge, so I would be qualified to be able to swim around island.', + references: [ + { + '@type': 'Other', + label: 'A cool island for Ryan', + uri: "https://www.google.com/maps/place/World's+only+5th+order+recursive+island/@62.6511465,-97.7946829,15.75z/data=!4m14!1m7!3m6!1s0x5216a167810cee39:0x11431abdfe4c7421!2sWorld's+only+5th+order+recursive+island!8m2!3d62.651114!4d-97.7872244!16s%2Fg%2F11spwk2b6n!3m5!1s0x5216a167810cee39:0x11431abdfe4c7421!8m2!3d62.651114!4d-97.7872244!16s%2Fg%2F11spwk2b6n?authuser=0&entry=ttu", + }, + { + '@type': 'Link', + label: "Ryan's Twitter", + uri: 'https://twitter.com/Ryun1_', + }, + ], + }, + }, + bytes: + '\\x7b0a20202240636f6e74657874223a207b0a2020202022406c616e6775616765223a2022656e2d7573222c0a2020202022434950313030223a202268747470733a2f2f6769746875622e636f6d2f63617264616e6f2d666f756e646174696f6e2f434950732f626c6f622f6d61737465722f4349502d303130302f524541444d452e6', + }, + response: { + drep_id: 'drep15cfxz9exyn5rx0807zvxfrvslrjqfchrd4d47kv9e0f46uedqtc', + hex: 'a61261172624e8333ceff098648d90f8e404e2e36d5b5f5985cbd35d', + url: 'https://aaa.xyz/drep.json', + hash: 'a14a5ad4f36bddc00f92ddb39fd9ac633c0fd43f8bfa57758f9163d10ef916de', + json_metadata: { + '@context': { + CIP100: + 'https://github.com/cardano-foundation/CIPs/blob/master/CIP-0100/README.md#', + CIP119: + 'https://github.com/cardano-foundation/CIPs/blob/master/CIP-0119/README.md#', + hashAlgorithm: 'CIP100:hashAlgorithm', + body: { + '@id': 'CIP119:body', + '@context': { + references: { + '@id': 'CIP119:references', + '@container': '@set', + '@context': { + GovernanceMetadata: 'CIP100:GovernanceMetadataReference', + Other: 'CIP100:OtherReference', + label: 'CIP100:reference-label', + uri: 'CIP100:reference-uri', + }, + }, + paymentAddress: 'CIP119:paymentAddress', + givenName: 'CIP119:givenName', + image: { + '@id': 'CIP119:image', + '@context': { + ImageObject: 'https://schema.org/ImageObject', + }, + }, + objectives: 'CIP119:objectives', + motivations: 'CIP119:motivations', + qualifications: 'CIP119:qualifications', + }, + }, + }, + hashAlgorithm: 'blake2b-256', + body: { + paymentAddress: + 'addr1q86dnpkva4mm859c8ur7tjxn57zgsu6vg8pdetkdve3fsacnq7twy06u2ev5759vutpjgzfryx0ud8hzedhzerava35qwh3x34', + givenName: 'Ryan Williams', + image: { + '@type': 'ImageObject', + contentUrl: 'https://avatars.githubusercontent.com/u/44342099?v=4', + sha256: + '2a21e4f7b20c8c72f573707b068fb8fc6d8c64d5035c4e18ecae287947fe2b2e', + }, + objectives: 'Buy myself an island.', + motivations: 'I really would like to own an island.', + qualifications: + 'I have my 100m swimming badge, so I would be qualified to be able to swim around island.', + references: [ + { + '@type': 'Other', + label: 'A cool island for Ryan', + uri: "https://www.google.com/maps/place/World's+only+5th+order+recursive+island/@62.6511465,-97.7946829,15.75z/data=!4m14!1m7!3m6!1s0x5216a167810cee39:0x11431abdfe4c7421!2sWorld's+only+5th+order+recursive+island!8m2!3d62.651114!4d-97.7872244!16s%2Fg%2F11spwk2b6n!3m5!1s0x5216a167810cee39:0x11431abdfe4c7421!8m2!3d62.651114!4d-97.7872244!16s%2Fg%2F11spwk2b6n?authuser=0&entry=ttu", + }, + { + '@type': 'Link', + label: "Ryan's Twitter", + uri: 'https://twitter.com/Ryun1_', + }, + ], + }, + }, + bytes: + '\\x7b0a20202240636f6e74657874223a207b0a2020202022406c616e6775616765223a2022656e2d7573222c0a2020202022434950313030223a202268747470733a2f2f6769746875622e636f6d2f63617264616e6f2d666f756e646174696f6e2f434950732f626c6f622f6d61737465722f4349502d303130302f524541444d452e6', + }, + }, + { + command: (SDK: BlockFrostAPI) => + SDK.drepsByIdDelegators( + 'drep1mvdu8slennngja7w4un6knwezufra70887zuxpprd64jxfveahn', + ), + path: mainnetUrl( + `governance/dreps/drep1mvdu8slennngja7w4un6knwezufra70887zuxpprd64jxfveahn/delegators`, + ), + endpointMock: [ + { + address: 'stake1ux4vspfvwuus9uwyp5p3f0ky7a30jq5j80jxse0fr7pa56sgn8kha', + amount: '1137959159981411', + }, + { + address: 'stake1uylayej7esmarzd4mk4aru37zh9yz0luj3g9fsvgpfaxulq564r5u', + amount: '16958865648', + }, + ], + response: [ + { + address: 'stake1ux4vspfvwuus9uwyp5p3f0ky7a30jq5j80jxse0fr7pa56sgn8kha', + amount: '1137959159981411', + }, + { + address: 'stake1uylayej7esmarzd4mk4aru37zh9yz0luj3g9fsvgpfaxulq564r5u', + amount: '16958865648', + }, + ], + }, + { + command: (SDK: BlockFrostAPI) => + SDK.drepsByIdUpdates( + 'drep1mvdu8slennngja7w4un6knwezufra70887zuxpprd64jxfveahn', + ), + path: mainnetUrl( + `governance/dreps/drep1mvdu8slennngja7w4un6knwezufra70887zuxpprd64jxfveahn/updates`, + ), + endpointMock: [ + { + tx_hash: + 'f4097fbdb87ab7c7ab44b30d4e2b81713a058488975d1ab8b05c381dd946a393', + cert_index: 0, + action: 'registered', + }, + { + tx_hash: + 'dd3243af975be4b5bedce4e5f5b483b2386d5ad207d05e0289c1df0eb261447e', + cert_index: 0, + action: 'deregistered', + }, + ], + response: [ + { + tx_hash: + 'f4097fbdb87ab7c7ab44b30d4e2b81713a058488975d1ab8b05c381dd946a393', + cert_index: 0, + action: 'registered', + }, + { + tx_hash: + 'dd3243af975be4b5bedce4e5f5b483b2386d5ad207d05e0289c1df0eb261447e', + cert_index: 0, + action: 'deregistered', + }, + ], + }, + { + command: (SDK: BlockFrostAPI) => + SDK.drepsByIdVotes( + 'drep1mvdu8slennngja7w4un6knwezufra70887zuxpprd64jxfveahn', + ), + path: mainnetUrl( + `governance/dreps/drep1mvdu8slennngja7w4un6knwezufra70887zuxpprd64jxfveahn/votes`, + ), + endpointMock: [ + { + tx_hash: 'b302de601defdf11a5261ed31a263804dac4a582a888c998ce24dec5', + cert_index: 2, + vote: 'yes', + }, + { + tx_hash: 'b302de601defdf11a5261ed31a263804dac4a582a888c998ce24dec5', + cert_index: 3, + vote: 'abstain', + }, + ], + response: [ + { + tx_hash: 'b302de601defdf11a5261ed31a263804dac4a582a888c998ce24dec5', + cert_index: 2, + vote: 'yes', + }, + { + tx_hash: 'b302de601defdf11a5261ed31a263804dac4a582a888c998ce24dec5', + cert_index: 3, + vote: 'abstain', + }, + ], + }, ] as const; From 5dfcb356a858ff3407aa34afdf08689bbcc713f1 Mon Sep 17 00:00:00 2001 From: slowbackspace Date: Thu, 31 Oct 2024 15:09:53 +0100 Subject: [PATCH 2/3] feat: add proposals endpoints --- CHANGELOG.MD | 3 +- src/BlockFrostAPI.ts | 21 ++ src/endpoints/api/governance/dreps/index.ts | 2 +- .../api/governance/proposals/index.ts | 223 ++++++++++++++++++ 4 files changed, 247 insertions(+), 2 deletions(-) create mode 100644 src/endpoints/api/governance/proposals/index.ts diff --git a/CHANGELOG.MD b/CHANGELOG.MD index b967b185..ef87fbf9 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -9,7 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- methods for querying governance DReps endpoints - `dreps`, `drepsById`, `drepsByIdDelegators`, `drepsByIdDelegatorsAll`, `drepsByIdMetadata`, `drepsByIdUpdates`, `drepsByIdUpdatesAll`, `drepsByIdVotes`, `drepsByIdVotesAll` +- methods for querying [governance](https://docs.blockfrost.io/#tag/cardano--governance) DReps endpoints - `dreps`, `drepsById`, `drepsByIdDelegators`, `drepsByIdDelegatorsAll`, `drepsByIdMetadata`, `drepsByIdUpdates`, `drepsByIdUpdatesAll`, `drepsByIdVotes`, `drepsByIdVotesAll` +- methods for querying [governance](https://docs.blockfrost.io/#tag/cardano--governance) proposals endpoints - `proposals`, `proposal`, `proposalMetadata`, `proposalParameters`, `proposalVotes`, `proposalVotesAll`, `proposalWithdrawals`, `proposalWithdrawalsAll`, ## [5.6.0] - 2024-10-03 diff --git a/src/BlockFrostAPI.ts b/src/BlockFrostAPI.ts index 679d81ee..e181f8ab 100644 --- a/src/BlockFrostAPI.ts +++ b/src/BlockFrostAPI.ts @@ -71,6 +71,18 @@ import { drepsByIdVotes, drepsByIdVotesAll, } from './endpoints/api/governance/dreps'; + +import { + proposals, + proposal, + proposalMetadata, + proposalParameters, + proposalVotes, + proposalVotesAll, + proposalWithdrawals, + proposalWithdrawalsAll, +} from './endpoints/api/governance/proposals'; + import { epochs, epochsBlocks, @@ -331,6 +343,15 @@ class BlockFrostAPI { poolsExtended = poolsExtended; poolsExtendedAll = poolsExtendedAll; + proposals = proposals; + proposal = proposal; + proposalMetadata = proposalMetadata; + proposalParameters = proposalParameters; + proposalVotes = proposalVotes; + proposalVotesAll = proposalVotesAll; + proposalWithdrawals = proposalWithdrawals; + proposalWithdrawalsAll = proposalWithdrawalsAll; + root = root; scripts = scripts; diff --git a/src/endpoints/api/governance/dreps/index.ts b/src/endpoints/api/governance/dreps/index.ts index d8e17446..845ac915 100644 --- a/src/endpoints/api/governance/dreps/index.ts +++ b/src/endpoints/api/governance/dreps/index.ts @@ -6,7 +6,7 @@ import { handleError } from '../../../../utils/errors'; /** * Obtains list of Delegate Representatives (DReps). - * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/dreps | API docs for of Delegate Representatives (DReps)} + * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/dreps | API docs for Delegate Representatives (DReps)} * * @param pagination - Optional, Pagination options * @returns List of registered stake pools. diff --git a/src/endpoints/api/governance/proposals/index.ts b/src/endpoints/api/governance/proposals/index.ts new file mode 100644 index 00000000..b0568c60 --- /dev/null +++ b/src/endpoints/api/governance/proposals/index.ts @@ -0,0 +1,223 @@ +import { getPaginationOptions, paginateMethod } from '../../../../utils'; +import { components } from '@blockfrost/openapi'; +import { BlockFrostAPI } from '../../../../index'; +import { AllMethodOptions, PaginationOptions } from '../../../../types'; +import { handleError } from '../../../../utils/errors'; + +/** + * Obtains list of proposals. + * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/proposals | API docs for Proposals} + * + * @param pagination - Optional, Pagination options + * @returns List of proposals + * + */ +export async function proposals( + this: BlockFrostAPI, + pagination?: PaginationOptions, +): Promise { + const paginationOptions = getPaginationOptions(pagination); + + try { + const res = await this.instance( + `governance/proposals`, + { + searchParams: { + page: paginationOptions.page, + count: paginationOptions.count, + order: paginationOptions.order, + }, + }, + ); + return res.body; + } catch (error) { + throw handleError(error); + } +} + +/** + * Obtains a specific Proposal + * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/proposals/%tx_hash%7D/%cert_index%7D | API docs for Specific Proposal} + * + * @param txHash - Transaction Hash + * @param cert_index - Index of the certificate within the proposal transaction. + * @returns Proposal information + * + */ +export async function proposal( + this: BlockFrostAPI, + txHash: string, + certIndex: number, +): Promise { + try { + const res = await this.instance( + `governance/proposals/${txHash}/${certIndex}`, + ); + return res.body; + } catch (error) { + throw handleError(error); + } +} + +/** + * Obtains a parameters of specific proposal + * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/proposals/%tx_hash%7D/%cert_index%7D/parameters | API docs for Specific Proposal parameters} + * + * @param txHash - Transaction Hash + * @param cert_index - Index of the certificate within the proposal transaction. + * @returns Parameters proposal details. + * + */ +export async function proposalParameters( + this: BlockFrostAPI, + txHash: string, + certIndex: number, +): Promise { + try { + const res = await this.instance< + components['schemas']['proposal_parameters'] + >(`governance/proposals/${txHash}/${certIndex}/parameters`); + return res.body; + } catch (error) { + throw handleError(error); + } +} + +/** + * Obtains Specific withdrawals proposal + * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/proposals/%tx_hash%7D/%cert_index%7D/withdrawals | API docs for Specific withdrawals proposal} + * + * @param txHash - Transaction Hash + * @param cert_index - Index of the certificate within the proposal transaction. + * @returns Parameters withdrawals details. + * + */ +export async function proposalWithdrawals( + this: BlockFrostAPI, + txHash: string, + certIndex: number, + pagination?: PaginationOptions, +): Promise { + const paginationOptions = getPaginationOptions(pagination); + + try { + const res = await this.instance< + components['schemas']['proposal_withdrawals'] + >(`governance/proposals/${txHash}/${certIndex}/withdrawals`, { + searchParams: { + page: paginationOptions.page, + count: paginationOptions.count, + order: paginationOptions.order, + }, + }); + return res.body; + } catch (error) { + throw handleError(error); + } +} + +/** + * Obtains Specific withdrawals proposal + * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/proposals/%tx_hash%7D/%cert_index%7D/withdrawals | API docs for Specific withdrawals proposal} + * @remarks + * Variant of `proposalWithdrawals` method for fetching all pages with built-in requests batching + * + * @param txHash - Transaction Hash + * @param cert_index - Index of the certificate within the proposal transaction. + * @param allMethodOptions - Optional, Options for request batching + * @returns Parameters withdrawals details. + * + */ +export async function proposalWithdrawalsAll( + this: BlockFrostAPI, + txHash: string, + certIndex: number, + allMethodOptions?: AllMethodOptions, +): Promise { + return paginateMethod( + pagination => this.proposalWithdrawals(txHash, certIndex, pagination), + allMethodOptions, + ); +} + +/** + * Obtains History of Proposal votes. + * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/proposals/%tx_hash%7D/%cert_index%7D/votes | API docs for Proposal votes​} + * + * @param txHash - Transaction Hash + * @param cert_index - Index of the certificate within the proposal transaction. + * @returns History of Proposal votes. + * + */ +export async function proposalVotes( + this: BlockFrostAPI, + txHash: string, + certIndex: number, + pagination?: PaginationOptions, +): Promise { + const paginationOptions = getPaginationOptions(pagination); + + try { + const res = await this.instance( + `governance/proposals/${txHash}/${certIndex}/votes`, + { + searchParams: { + page: paginationOptions.page, + count: paginationOptions.count, + order: paginationOptions.order, + }, + }, + ); + return res.body; + } catch (error) { + throw handleError(error); + } +} + +/** + * Obtains History of Proposal votes. + * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/proposals/%tx_hash%7D/%cert_index%7D/votes | API docs for Proposal votes​} + * @remarks + * Variant of `proposalVotes` method for fetching all pages with built-in requests batching + * + * @param txHash - Transaction Hash + * @param cert_index - Index of the certificate within the proposal transaction. + * @param allMethodOptions - Optional, Options for request batching + * @returns History of DRep votes + * + */ +export async function proposalVotesAll( + this: BlockFrostAPI, + txHash: string, + certIndex: number, + allMethodOptions?: AllMethodOptions, +): Promise { + return paginateMethod( + pagination => this.proposalVotes(txHash, certIndex, pagination), + allMethodOptions, + ); +} + +/** + * Obtains Proposal metadata information. + * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/proposals/%tx_hash%7D/%cert_index%7D/metadata | API docs for Proposal metadata} + * + * @param txHash - Transaction Hash + * @param cert_index - Index of the certificate within the proposal transaction. + * @returns Proposal metadata information + * + */ +export async function proposalMetadata( + this: BlockFrostAPI, + txHash: string, + certIndex: number, +): Promise { + try { + const res = await this.instance( + `governance/proposals/${txHash}/${certIndex}/metadata`, + ); + return res.body; + } catch (error) { + throw handleError(error); + } +} From f483a028d1a54d00b2fadbd72d209cb46e17d2a6 Mon Sep 17 00:00:00 2001 From: slowbackspace Date: Thu, 31 Oct 2024 16:16:43 +0100 Subject: [PATCH 3/3] chore: wrap gov endpoints under BlockfrostAPI.governance --- CHANGELOG.MD | 4 +- src/BlockFrostAPI.ts | 45 +- src/endpoints/api/governance/dreps/index.ts | 252 ---------- src/endpoints/api/governance/index.ts | 451 ++++++++++++++++++ .../api/governance/proposals/index.ts | 223 --------- test/fixtures/endpoints.ts | 224 ++++++++- 6 files changed, 675 insertions(+), 524 deletions(-) delete mode 100644 src/endpoints/api/governance/dreps/index.ts create mode 100644 src/endpoints/api/governance/index.ts delete mode 100644 src/endpoints/api/governance/proposals/index.ts diff --git a/CHANGELOG.MD b/CHANGELOG.MD index ef87fbf9..d715ca71 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -9,8 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- methods for querying [governance](https://docs.blockfrost.io/#tag/cardano--governance) DReps endpoints - `dreps`, `drepsById`, `drepsByIdDelegators`, `drepsByIdDelegatorsAll`, `drepsByIdMetadata`, `drepsByIdUpdates`, `drepsByIdUpdatesAll`, `drepsByIdVotes`, `drepsByIdVotesAll` -- methods for querying [governance](https://docs.blockfrost.io/#tag/cardano--governance) proposals endpoints - `proposals`, `proposal`, `proposalMetadata`, `proposalParameters`, `proposalVotes`, `proposalVotesAll`, `proposalWithdrawals`, `proposalWithdrawalsAll`, +- Methods for querying [governance DReps endpoints](https://docs.blockfrost.io/#tag/cardano--governance.) - `governance.dreps`, `governance.drepsById`, `governance.drepsByIdDelegators`, `governance.drepsByIdMetadata`, `governance.drepsByIdUpdates`, `governance.drepsByIdVotes` +- Methods for querying [governance proposals endpoints](https://docs.blockfrost.io/#tag/cardano--governance.) - `governance.proposals`, `governance.proposal`, `governance.proposalMetadata`, `governance.proposalParameters`, `governance.proposalVotes`, `governance.proposalWithdrawals` ## [5.6.0] - 2024-10-03 diff --git a/src/BlockFrostAPI.ts b/src/BlockFrostAPI.ts index e181f8ab..0f57f268 100644 --- a/src/BlockFrostAPI.ts +++ b/src/BlockFrostAPI.ts @@ -60,28 +60,7 @@ import { blocksAddressesAll, } from './endpoints/api/blocks'; -import { - dreps, - drepsById, - drepsByIdDelegators, - drepsByIdDelegatorsAll, - drepsByIdMetadata, - drepsByIdUpdates, - drepsByIdUpdatesAll, - drepsByIdVotes, - drepsByIdVotesAll, -} from './endpoints/api/governance/dreps'; - -import { - proposals, - proposal, - proposalMetadata, - proposalParameters, - proposalVotes, - proposalVotesAll, - proposalWithdrawals, - proposalWithdrawalsAll, -} from './endpoints/api/governance/proposals'; +import { GovernanceAPI } from './endpoints/api/governance'; import { epochs, @@ -195,6 +174,7 @@ class BlockFrostAPI { instance: Got; /** @ignore */ rateLimiter: Bottleneck | undefined; + governance: GovernanceAPI; constructor(options?: Options) { this.options = validateOptions(options); @@ -229,6 +209,8 @@ class BlockFrostAPI { this.userAgent, this.rateLimiter, ); + + this.governance = new GovernanceAPI(this); } accounts = accounts; @@ -280,16 +262,6 @@ class BlockFrostAPI { blocksAddresses = blocksAddresses; blocksAddressesAll = blocksAddressesAll; - dreps = dreps; - drepsById = drepsById; - drepsByIdDelegators = drepsByIdDelegators; - drepsByIdDelegatorsAll = drepsByIdDelegatorsAll; - drepsByIdMetadata = drepsByIdMetadata; - drepsByIdUpdates = drepsByIdUpdates; - drepsByIdUpdatesAll = drepsByIdUpdatesAll; - drepsByIdVotes = drepsByIdVotes; - drepsByIdVotesAll = drepsByIdVotesAll; - epochs = epochs; epochsBlocks = epochsBlocks; epochsBlocksAll = epochsBlocksAll; @@ -343,15 +315,6 @@ class BlockFrostAPI { poolsExtended = poolsExtended; poolsExtendedAll = poolsExtendedAll; - proposals = proposals; - proposal = proposal; - proposalMetadata = proposalMetadata; - proposalParameters = proposalParameters; - proposalVotes = proposalVotes; - proposalVotesAll = proposalVotesAll; - proposalWithdrawals = proposalWithdrawals; - proposalWithdrawalsAll = proposalWithdrawalsAll; - root = root; scripts = scripts; diff --git a/src/endpoints/api/governance/dreps/index.ts b/src/endpoints/api/governance/dreps/index.ts deleted file mode 100644 index 845ac915..00000000 --- a/src/endpoints/api/governance/dreps/index.ts +++ /dev/null @@ -1,252 +0,0 @@ -import { getPaginationOptions, paginateMethod } from '../../../../utils'; -import { components } from '@blockfrost/openapi'; -import { BlockFrostAPI } from '../../../../index'; -import { AllMethodOptions, PaginationOptions } from '../../../../types'; -import { handleError } from '../../../../utils/errors'; - -/** - * Obtains list of Delegate Representatives (DReps). - * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/dreps | API docs for Delegate Representatives (DReps)} - * - * @param pagination - Optional, Pagination options - * @returns List of registered stake pools. - * - */ -export async function dreps( - this: BlockFrostAPI, - pagination?: PaginationOptions, -): Promise { - const paginationOptions = getPaginationOptions(pagination); - - try { - const res = await this.instance( - `governance/dreps`, - { - searchParams: { - page: paginationOptions.page, - count: paginationOptions.count, - order: paginationOptions.order, - }, - }, - ); - return res.body; - } catch (error) { - throw handleError(error); - } -} - -/** - * Obtains information of a specific DRep. - * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/dreps/%7Bdrep_id%7D | API docs for Stake Pool} - * - * @param drepId - DRep ID - * @returns Information of a specific DRep - * - */ -export async function drepsById( - this: BlockFrostAPI, - drepId: string, -): Promise { - try { - const res = await this.instance( - `governance/dreps/${drepId}`, - ); - return res.body; - } catch (error) { - throw handleError(error); - } -} - -/** - * Obtains DRep metadata. - * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/dreps/%7Bdrep_id%7D/metadata | API docs for DRep Metadata} - * - * @param drepId - DRep ID - * @returns DRep Metadata - * - */ -export async function drepsByIdMetadata( - this: BlockFrostAPI, - drepId: string, - pagination?: PaginationOptions, -): Promise { - const paginationOptions = getPaginationOptions(pagination); - - try { - const res = await this.instance( - `governance/dreps/${drepId}/metadata`, - { - searchParams: { - page: paginationOptions.page, - count: paginationOptions.count, - order: paginationOptions.order, - }, - }, - ); - return res.body; - } catch (error) { - throw handleError(error); - } -} - -/** - * Obtains current DRep delegators. - * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/dreps/%7Bdrep_id%7D/delegators | API docs for DRep Delegators} - * - * @param drepId - DRep ID - * @returns Current DRep delegators - * - */ -export async function drepsByIdDelegators( - this: BlockFrostAPI, - drepId: string, - pagination?: PaginationOptions, -): Promise { - const paginationOptions = getPaginationOptions(pagination); - - try { - const res = await this.instance( - `governance/dreps/${drepId}/delegators`, - { - searchParams: { - page: paginationOptions.page, - count: paginationOptions.count, - order: paginationOptions.order, - }, - }, - ); - return res.body; - } catch (error) { - throw handleError(error); - } -} - -/** - * Obtains current DRep delegators. - * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/dreps/%7Bdrep_id%7D/delegators | API docs for DRep Delegators} - * @remarks - * Variant of `drepsByIdDelegators` method for fetching all pages with built-in requests batching - * - * @param drepId - DRep ID - * @param allMethodOptions - Optional, Options for request batching - * @returns Current DRep delegators - * - */ -export async function drepsByIdDelegatorsAll( - this: BlockFrostAPI, - drepId: string, - allMethodOptions?: AllMethodOptions, -): Promise { - return paginateMethod( - pagination => this.drepsByIdDelegators(drepId, pagination), - allMethodOptions, - ); -} - -/** - * Obtains List of certificate updates to the DRep. - * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/dreps/%7Bdrep_id%7D/updates | API docs for DRep Updates} - * - * @param drepId - DRep ID - * @returns List of certificate updates to the DRep - * - */ -export async function drepsByIdUpdates( - this: BlockFrostAPI, - drepId: string, - pagination?: PaginationOptions, -): Promise { - const paginationOptions = getPaginationOptions(pagination); - - try { - const res = await this.instance( - `governance/dreps/${drepId}/updates`, - { - searchParams: { - page: paginationOptions.page, - count: paginationOptions.count, - order: paginationOptions.order, - }, - }, - ); - return res.body; - } catch (error) { - throw handleError(error); - } -} - -/** - * Obtains List of certificate updates to the DRep. - * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/dreps/%7Bdrep_id%7D/updates | API docs for History of DRep updates} - * @remarks - * Variant of `drepsByIdUpdates` method for fetching all pages with built-in requests batching - * - * @param drepId - DRep ID - * @param allMethodOptions - Optional, Options for request batching - * @returns List of certificate updates to the DRep - * - */ -export async function drepsByIdUpdatesAll( - this: BlockFrostAPI, - drepId: string, - allMethodOptions?: AllMethodOptions, -): Promise { - return paginateMethod( - pagination => this.drepsByIdUpdates(drepId, pagination), - allMethodOptions, - ); -} - -/** - * Obtains History of DRep votes. - * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/dreps/%7Bdrep_id%7D/votes | API docs for History of DRep votes} - * - * @param drepId - DRep ID - * @returns History of DRep votes - * - */ -export async function drepsByIdVotes( - this: BlockFrostAPI, - drepId: string, - pagination?: PaginationOptions, -): Promise { - const paginationOptions = getPaginationOptions(pagination); - - try { - const res = await this.instance( - `governance/dreps/${drepId}/votes`, - { - searchParams: { - page: paginationOptions.page, - count: paginationOptions.count, - order: paginationOptions.order, - }, - }, - ); - return res.body; - } catch (error) { - throw handleError(error); - } -} - -/** - * Obtains History of DRep votes. - * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/dreps/%7Bdrep_id%7D/votes | API docs for History of DRep votes} - * @remarks - * Variant of `drepsByIdVotes` method for fetching all pages with built-in requests batching - * - * @param drepId - DRep ID - * @param allMethodOptions - Optional, Options for request batching - * @returns History of DRep votes - * - */ -export async function drepsByIdVotesAll( - this: BlockFrostAPI, - drepId: string, - allMethodOptions?: AllMethodOptions, -): Promise { - return paginateMethod( - pagination => this.drepsByIdVotes(drepId, pagination), - allMethodOptions, - ); -} diff --git a/src/endpoints/api/governance/index.ts b/src/endpoints/api/governance/index.ts new file mode 100644 index 00000000..94b54476 --- /dev/null +++ b/src/endpoints/api/governance/index.ts @@ -0,0 +1,451 @@ +import { getPaginationOptions, paginateMethod } from '../../../utils'; +import { components } from '@blockfrost/openapi'; +import { BlockFrostAPI } from '../../../index'; +import { AllMethodOptions, PaginationOptions } from '../../../types'; +import { handleError } from '../../../utils/errors'; + +export class GovernanceAPI { + blockfrostAPI: BlockFrostAPI; + + constructor(blockfrostAPI: BlockFrostAPI) { + this.blockfrostAPI = blockfrostAPI; + } + + /** + * Obtains list of Delegate Representatives (DReps). + * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/dreps | API docs for Delegate Representatives (DReps)} + * + * @param pagination - Optional, Pagination options + * @returns List of registered stake pools. + * + */ + async dreps( + pagination?: PaginationOptions, + ): Promise { + const paginationOptions = getPaginationOptions(pagination); + + try { + const res = await this.blockfrostAPI.instance< + components['schemas']['dreps'] + >(`governance/dreps`, { + searchParams: { + page: paginationOptions.page, + count: paginationOptions.count, + order: paginationOptions.order, + }, + }); + return res.body; + } catch (error) { + throw handleError(error); + } + } + + /** + * Obtains information of a specific DRep. + * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/dreps/%7Bdrep_id%7D | API docs for Stake Pool} + * + * @param drepId - DRep ID + * @returns Information of a specific DRep + * + */ + async drepsById(drepId: string): Promise { + try { + const res = await this.blockfrostAPI.instance< + components['schemas']['drep'] + >(`governance/dreps/${drepId}`); + return res.body; + } catch (error) { + throw handleError(error); + } + } + + /** + * Obtains DRep metadata. + * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/dreps/%7Bdrep_id%7D/metadata | API docs for DRep Metadata} + * + * @param drepId - DRep ID + * @returns DRep Metadata + * + */ + async drepsByIdMetadata( + drepId: string, + pagination?: PaginationOptions, + ): Promise { + const paginationOptions = getPaginationOptions(pagination); + + try { + const res = await this.blockfrostAPI.instance< + components['schemas']['drep_metadata'] + >(`governance/dreps/${drepId}/metadata`, { + searchParams: { + page: paginationOptions.page, + count: paginationOptions.count, + order: paginationOptions.order, + }, + }); + return res.body; + } catch (error) { + throw handleError(error); + } + } + + /** + * Obtains current DRep delegators. + * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/dreps/%7Bdrep_id%7D/delegators | API docs for DRep Delegators} + * + * @param drepId - DRep ID + * @returns Current DRep delegators + * + */ + async drepsByIdDelegators( + drepId: string, + pagination?: PaginationOptions, + ): Promise { + const paginationOptions = getPaginationOptions(pagination); + + try { + const res = await this.blockfrostAPI.instance< + components['schemas']['drep_delegators'] + >(`governance/dreps/${drepId}/delegators`, { + searchParams: { + page: paginationOptions.page, + count: paginationOptions.count, + order: paginationOptions.order, + }, + }); + return res.body; + } catch (error) { + throw handleError(error); + } + } + + /** + * Obtains current DRep delegators. + * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/dreps/%7Bdrep_id%7D/delegators | API docs for DRep Delegators} + * @remarks + * Variant of `drepsByIdDelegators` method for fetching all pages with built-in requests batching + * + * @param drepId - DRep ID + * @param allMethodOptions - Optional, Options for request batching + * @returns Current DRep delegators + * + */ + async drepsByIdDelegatorsAll( + drepId: string, + allMethodOptions?: AllMethodOptions, + ): Promise { + return paginateMethod( + pagination => this.drepsByIdDelegators(drepId, pagination), + allMethodOptions, + ); + } + + /** + * Obtains List of certificate updates to the DRep. + * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/dreps/%7Bdrep_id%7D/updates | API docs for DRep Updates} + * + * @param drepId - DRep ID + * @returns List of certificate updates to the DRep + * + */ + async drepsByIdUpdates( + drepId: string, + pagination?: PaginationOptions, + ): Promise { + const paginationOptions = getPaginationOptions(pagination); + + try { + const res = await this.blockfrostAPI.instance< + components['schemas']['drep_updates'] + >(`governance/dreps/${drepId}/updates`, { + searchParams: { + page: paginationOptions.page, + count: paginationOptions.count, + order: paginationOptions.order, + }, + }); + return res.body; + } catch (error) { + throw handleError(error); + } + } + + /** + * Obtains List of certificate updates to the DRep. + * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/dreps/%7Bdrep_id%7D/updates | API docs for History of DRep updates} + * @remarks + * Variant of `drepsByIdUpdates` method for fetching all pages with built-in requests batching + * + * @param drepId - DRep ID + * @param allMethodOptions - Optional, Options for request batching + * @returns List of certificate updates to the DRep + * + */ + async drepsByIdUpdatesAll( + drepId: string, + allMethodOptions?: AllMethodOptions, + ): Promise { + return paginateMethod( + pagination => this.drepsByIdUpdates(drepId, pagination), + allMethodOptions, + ); + } + + /** + * Obtains History of DRep votes. + * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/dreps/%7Bdrep_id%7D/votes | API docs for History of DRep votes} + * + * @param drepId - DRep ID + * @returns History of DRep votes + * + */ + async drepsByIdVotes( + drepId: string, + pagination?: PaginationOptions, + ): Promise { + const paginationOptions = getPaginationOptions(pagination); + + try { + const res = await this.blockfrostAPI.instance< + components['schemas']['drep_votes'] + >(`governance/dreps/${drepId}/votes`, { + searchParams: { + page: paginationOptions.page, + count: paginationOptions.count, + order: paginationOptions.order, + }, + }); + return res.body; + } catch (error) { + throw handleError(error); + } + } + + /** + * Obtains History of DRep votes. + * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/dreps/%7Bdrep_id%7D/votes | API docs for History of DRep votes} + * @remarks + * Variant of `drepsByIdVotes` method for fetching all pages with built-in requests batching + * + * @param drepId - DRep ID + * @param allMethodOptions - Optional, Options for request batching + * @returns History of DRep votes + * + */ + async drepsByIdVotesAll( + drepId: string, + allMethodOptions?: AllMethodOptions, + ): Promise { + return paginateMethod( + pagination => this.drepsByIdVotes(drepId, pagination), + allMethodOptions, + ); + } + /** + * Obtains list of proposals. + * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/proposals | API docs for Proposals} + * + * @param pagination - Optional, Pagination options + * @returns List of proposals + * + */ + async proposals( + pagination?: PaginationOptions, + ): Promise { + const paginationOptions = getPaginationOptions(pagination); + + try { + const res = await this.blockfrostAPI.instance< + components['schemas']['proposals'] + >(`governance/proposals`, { + searchParams: { + page: paginationOptions.page, + count: paginationOptions.count, + order: paginationOptions.order, + }, + }); + return res.body; + } catch (error) { + throw handleError(error); + } + } + + /** + * Obtains a specific Proposal + * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/proposals/%tx_hash%7D/%cert_index%7D | API docs for Specific Proposal} + * + * @param txHash - Transaction Hash + * @param cert_index - Index of the certificate within the proposal transaction. + * @returns Proposal information + * + */ + async proposal( + txHash: string, + certIndex: number, + ): Promise { + try { + const res = await this.blockfrostAPI.instance< + components['schemas']['proposal'] + >(`governance/proposals/${txHash}/${certIndex}`); + return res.body; + } catch (error) { + throw handleError(error); + } + } + + /** + * Obtains a parameters of specific proposal + * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/proposals/%tx_hash%7D/%cert_index%7D/parameters | API docs for Specific Proposal parameters} + * + * @param txHash - Transaction Hash + * @param cert_index - Index of the certificate within the proposal transaction. + * @returns Parameters proposal details. + * + */ + async proposalParameters( + txHash: string, + certIndex: number, + ): Promise { + try { + const res = await this.blockfrostAPI.instance< + components['schemas']['proposal_parameters'] + >(`governance/proposals/${txHash}/${certIndex}/parameters`); + return res.body; + } catch (error) { + throw handleError(error); + } + } + + /** + * Obtains Specific withdrawals proposal + * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/proposals/%tx_hash%7D/%cert_index%7D/withdrawals | API docs for Specific withdrawals proposal} + * + * @param txHash - Transaction Hash + * @param cert_index - Index of the certificate within the proposal transaction. + * @returns Parameters withdrawals details. + * + */ + async proposalWithdrawals( + txHash: string, + certIndex: number, + pagination?: PaginationOptions, + ): Promise { + const paginationOptions = getPaginationOptions(pagination); + + try { + const res = await this.blockfrostAPI.instance< + components['schemas']['proposal_withdrawals'] + >(`governance/proposals/${txHash}/${certIndex}/withdrawals`, { + searchParams: { + page: paginationOptions.page, + count: paginationOptions.count, + order: paginationOptions.order, + }, + }); + return res.body; + } catch (error) { + throw handleError(error); + } + } + + /** + * Obtains Specific withdrawals proposal + * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/proposals/%tx_hash%7D/%cert_index%7D/withdrawals | API docs for Specific withdrawals proposal} + * @remarks + * Variant of `proposalWithdrawals` method for fetching all pages with built-in requests batching + * + * @param txHash - Transaction Hash + * @param cert_index - Index of the certificate within the proposal transaction. + * @param allMethodOptions - Optional, Options for request batching + * @returns Parameters withdrawals details. + * + */ + async proposalWithdrawalsAll( + txHash: string, + certIndex: number, + allMethodOptions?: AllMethodOptions, + ): Promise { + return paginateMethod( + pagination => this.proposalWithdrawals(txHash, certIndex, pagination), + allMethodOptions, + ); + } + + /** + * Obtains History of Proposal votes. + * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/proposals/%tx_hash%7D/%cert_index%7D/votes | API docs for Proposal votes} + * + * @param txHash - Transaction Hash + * @param cert_index - Index of the certificate within the proposal transaction. + * @returns History of Proposal votes. + * + */ + async proposalVotes( + txHash: string, + certIndex: number, + pagination?: PaginationOptions, + ): Promise { + const paginationOptions = getPaginationOptions(pagination); + + try { + const res = await this.blockfrostAPI.instance< + components['schemas']['proposal_votes'] + >(`governance/proposals/${txHash}/${certIndex}/votes`, { + searchParams: { + page: paginationOptions.page, + count: paginationOptions.count, + order: paginationOptions.order, + }, + }); + return res.body; + } catch (error) { + throw handleError(error); + } + } + + /** + * Obtains History of Proposal votes. + * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/proposals/%tx_hash%7D/%cert_index%7D/votes | API docs for Proposal votes} + * @remarks + * Variant of `proposalVotes` method for fetching all pages with built-in requests batching + * + * @param txHash - Transaction Hash + * @param cert_index - Index of the certificate within the proposal transaction. + * @param allMethodOptions - Optional, Options for request batching + * @returns History of DRep votes + * + */ + async proposalVotesAll( + txHash: string, + certIndex: number, + allMethodOptions?: AllMethodOptions, + ): Promise { + return paginateMethod( + pagination => this.proposalVotes(txHash, certIndex, pagination), + allMethodOptions, + ); + } + + /** + * Obtains Proposal metadata information. + * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/proposals/%tx_hash%7D/%cert_index%7D/metadata | API docs for Proposal metadata} + * + * @param txHash - Transaction Hash + * @param cert_index - Index of the certificate within the proposal transaction. + * @returns Proposal metadata information + * + */ + async proposalMetadata( + txHash: string, + certIndex: number, + ): Promise { + try { + const res = await this.blockfrostAPI.instance< + components['schemas']['proposal_metadata'] + >(`governance/proposals/${txHash}/${certIndex}/metadata`); + return res.body; + } catch (error) { + throw handleError(error); + } + } +} diff --git a/src/endpoints/api/governance/proposals/index.ts b/src/endpoints/api/governance/proposals/index.ts deleted file mode 100644 index b0568c60..00000000 --- a/src/endpoints/api/governance/proposals/index.ts +++ /dev/null @@ -1,223 +0,0 @@ -import { getPaginationOptions, paginateMethod } from '../../../../utils'; -import { components } from '@blockfrost/openapi'; -import { BlockFrostAPI } from '../../../../index'; -import { AllMethodOptions, PaginationOptions } from '../../../../types'; -import { handleError } from '../../../../utils/errors'; - -/** - * Obtains list of proposals. - * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/proposals | API docs for Proposals} - * - * @param pagination - Optional, Pagination options - * @returns List of proposals - * - */ -export async function proposals( - this: BlockFrostAPI, - pagination?: PaginationOptions, -): Promise { - const paginationOptions = getPaginationOptions(pagination); - - try { - const res = await this.instance( - `governance/proposals`, - { - searchParams: { - page: paginationOptions.page, - count: paginationOptions.count, - order: paginationOptions.order, - }, - }, - ); - return res.body; - } catch (error) { - throw handleError(error); - } -} - -/** - * Obtains a specific Proposal - * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/proposals/%tx_hash%7D/%cert_index%7D | API docs for Specific Proposal} - * - * @param txHash - Transaction Hash - * @param cert_index - Index of the certificate within the proposal transaction. - * @returns Proposal information - * - */ -export async function proposal( - this: BlockFrostAPI, - txHash: string, - certIndex: number, -): Promise { - try { - const res = await this.instance( - `governance/proposals/${txHash}/${certIndex}`, - ); - return res.body; - } catch (error) { - throw handleError(error); - } -} - -/** - * Obtains a parameters of specific proposal - * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/proposals/%tx_hash%7D/%cert_index%7D/parameters | API docs for Specific Proposal parameters} - * - * @param txHash - Transaction Hash - * @param cert_index - Index of the certificate within the proposal transaction. - * @returns Parameters proposal details. - * - */ -export async function proposalParameters( - this: BlockFrostAPI, - txHash: string, - certIndex: number, -): Promise { - try { - const res = await this.instance< - components['schemas']['proposal_parameters'] - >(`governance/proposals/${txHash}/${certIndex}/parameters`); - return res.body; - } catch (error) { - throw handleError(error); - } -} - -/** - * Obtains Specific withdrawals proposal - * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/proposals/%tx_hash%7D/%cert_index%7D/withdrawals | API docs for Specific withdrawals proposal} - * - * @param txHash - Transaction Hash - * @param cert_index - Index of the certificate within the proposal transaction. - * @returns Parameters withdrawals details. - * - */ -export async function proposalWithdrawals( - this: BlockFrostAPI, - txHash: string, - certIndex: number, - pagination?: PaginationOptions, -): Promise { - const paginationOptions = getPaginationOptions(pagination); - - try { - const res = await this.instance< - components['schemas']['proposal_withdrawals'] - >(`governance/proposals/${txHash}/${certIndex}/withdrawals`, { - searchParams: { - page: paginationOptions.page, - count: paginationOptions.count, - order: paginationOptions.order, - }, - }); - return res.body; - } catch (error) { - throw handleError(error); - } -} - -/** - * Obtains Specific withdrawals proposal - * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/proposals/%tx_hash%7D/%cert_index%7D/withdrawals | API docs for Specific withdrawals proposal} - * @remarks - * Variant of `proposalWithdrawals` method for fetching all pages with built-in requests batching - * - * @param txHash - Transaction Hash - * @param cert_index - Index of the certificate within the proposal transaction. - * @param allMethodOptions - Optional, Options for request batching - * @returns Parameters withdrawals details. - * - */ -export async function proposalWithdrawalsAll( - this: BlockFrostAPI, - txHash: string, - certIndex: number, - allMethodOptions?: AllMethodOptions, -): Promise { - return paginateMethod( - pagination => this.proposalWithdrawals(txHash, certIndex, pagination), - allMethodOptions, - ); -} - -/** - * Obtains History of Proposal votes. - * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/proposals/%tx_hash%7D/%cert_index%7D/votes | API docs for Proposal votes​} - * - * @param txHash - Transaction Hash - * @param cert_index - Index of the certificate within the proposal transaction. - * @returns History of Proposal votes. - * - */ -export async function proposalVotes( - this: BlockFrostAPI, - txHash: string, - certIndex: number, - pagination?: PaginationOptions, -): Promise { - const paginationOptions = getPaginationOptions(pagination); - - try { - const res = await this.instance( - `governance/proposals/${txHash}/${certIndex}/votes`, - { - searchParams: { - page: paginationOptions.page, - count: paginationOptions.count, - order: paginationOptions.order, - }, - }, - ); - return res.body; - } catch (error) { - throw handleError(error); - } -} - -/** - * Obtains History of Proposal votes. - * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/proposals/%tx_hash%7D/%cert_index%7D/votes | API docs for Proposal votes​} - * @remarks - * Variant of `proposalVotes` method for fetching all pages with built-in requests batching - * - * @param txHash - Transaction Hash - * @param cert_index - Index of the certificate within the proposal transaction. - * @param allMethodOptions - Optional, Options for request batching - * @returns History of DRep votes - * - */ -export async function proposalVotesAll( - this: BlockFrostAPI, - txHash: string, - certIndex: number, - allMethodOptions?: AllMethodOptions, -): Promise { - return paginateMethod( - pagination => this.proposalVotes(txHash, certIndex, pagination), - allMethodOptions, - ); -} - -/** - * Obtains Proposal metadata information. - * @see {@link https://docs.blockfrost.io/#tag/cardano--governance/GET/governance/proposals/%tx_hash%7D/%cert_index%7D/metadata | API docs for Proposal metadata} - * - * @param txHash - Transaction Hash - * @param cert_index - Index of the certificate within the proposal transaction. - * @returns Proposal metadata information - * - */ -export async function proposalMetadata( - this: BlockFrostAPI, - txHash: string, - certIndex: number, -): Promise { - try { - const res = await this.instance( - `governance/proposals/${txHash}/${certIndex}/metadata`, - ); - return res.body; - } catch (error) { - throw handleError(error); - } -} diff --git a/test/fixtures/endpoints.ts b/test/fixtures/endpoints.ts index 2109b856..6016324c 100644 --- a/test/fixtures/endpoints.ts +++ b/test/fixtures/endpoints.ts @@ -984,7 +984,7 @@ export default [ }, }, { - command: (SDK: BlockFrostAPI) => SDK.dreps(), + command: (SDK: BlockFrostAPI) => SDK.governance.dreps(), path: mainnetUrl(`governance/dreps`), endpointMock: [ { @@ -1009,7 +1009,9 @@ export default [ }, { command: (SDK: BlockFrostAPI) => - SDK.drepsById('drep1mvdu8slennngja7w4un6knwezufra70887zuxpprd64jxfveahn'), + SDK.governance.drepsById( + 'drep1mvdu8slennngja7w4un6knwezufra70887zuxpprd64jxfveahn', + ), path: mainnetUrl( `governance/dreps/drep1mvdu8slennngja7w4un6knwezufra70887zuxpprd64jxfveahn`, ), @@ -1032,7 +1034,7 @@ export default [ }, { command: (SDK: BlockFrostAPI) => - SDK.drepsByIdMetadata( + SDK.governance.drepsByIdMetadata( 'drep1mvdu8slennngja7w4un6knwezufra70887zuxpprd64jxfveahn', ), path: mainnetUrl( @@ -1183,7 +1185,7 @@ export default [ }, { command: (SDK: BlockFrostAPI) => - SDK.drepsByIdDelegators( + SDK.governance.drepsByIdDelegators( 'drep1mvdu8slennngja7w4un6knwezufra70887zuxpprd64jxfveahn', ), path: mainnetUrl( @@ -1212,7 +1214,7 @@ export default [ }, { command: (SDK: BlockFrostAPI) => - SDK.drepsByIdUpdates( + SDK.governance.drepsByIdUpdates( 'drep1mvdu8slennngja7w4un6knwezufra70887zuxpprd64jxfveahn', ), path: mainnetUrl( @@ -1249,7 +1251,7 @@ export default [ }, { command: (SDK: BlockFrostAPI) => - SDK.drepsByIdVotes( + SDK.governance.drepsByIdVotes( 'drep1mvdu8slennngja7w4un6knwezufra70887zuxpprd64jxfveahn', ), path: mainnetUrl( @@ -1280,4 +1282,214 @@ export default [ }, ], }, + { + command: (SDK: BlockFrostAPI) => SDK.governance.proposals(), + path: mainnetUrl(`governance/proposals`), + endpointMock: [ + { + tx_hash: + '2dd15e0ef6e6a17841cb9541c27724072ce4d4b79b91e58432fbaa32d9572531', + cert_index: 1, + governance_type: 'treasury_withdrawals', + }, + { + tx_hash: '71317e951b20aa46e9fbf45a46a6e950d5723a481225519655bf6c60', + cert_index: 4, + governance_type: 'no_confidence', + }, + ], + response: [ + { + tx_hash: + '2dd15e0ef6e6a17841cb9541c27724072ce4d4b79b91e58432fbaa32d9572531', + cert_index: 1, + governance_type: 'treasury_withdrawals', + }, + { + tx_hash: '71317e951b20aa46e9fbf45a46a6e950d5723a481225519655bf6c60', + cert_index: 4, + governance_type: 'no_confidence', + }, + ], + }, + { + command: (SDK: BlockFrostAPI) => + SDK.governance.proposal( + '2dd15e0ef6e6a17841cb9541c27724072ce4d4b79b91e58432fbaa32d9572531', + 1, + ), + path: mainnetUrl( + `governance/proposals/2dd15e0ef6e6a17841cb9541c27724072ce4d4b79b91e58432fbaa32d9572531/1`, + ), + endpointMock: { + tx_hash: + '2dd15e0ef6e6a17841cb9541c27724072ce4d4b79b91e58432fbaa32d9572531', + cert_index: 1, + governance_type: 'treasury_withdrawals', + deposit: 12000, + return_address: + 'stake_test1urd3hs7rlxwwdzthe6hj026dmyt3y0heuulctscyydh2kgck6nkmz', + governance_description: + 'TreasuryWithdrawals (fromList [(RewardAcnt {getRwdNetwork = Testnet, getRwdCred = KeyHashObj (KeyHash "71317e951b20aa46e9fbf45a46a6e950d5723a481225519655bf6c60")},Coin 20000000)])', + ratified_epoch: null, + enacted_epoch: 123, + dropped_epoch: null, + expired_epoch: null, + expiration: 120, + }, + response: { + tx_hash: + '2dd15e0ef6e6a17841cb9541c27724072ce4d4b79b91e58432fbaa32d9572531', + cert_index: 1, + governance_type: 'treasury_withdrawals', + deposit: 12000, + return_address: + 'stake_test1urd3hs7rlxwwdzthe6hj026dmyt3y0heuulctscyydh2kgck6nkmz', + governance_description: + 'TreasuryWithdrawals (fromList [(RewardAcnt {getRwdNetwork = Testnet, getRwdCred = KeyHashObj (KeyHash "71317e951b20aa46e9fbf45a46a6e950d5723a481225519655bf6c60")},Coin 20000000)])', + ratified_epoch: null, + enacted_epoch: 123, + dropped_epoch: null, + expired_epoch: null, + expiration: 120, + }, + }, + { + command: (SDK: BlockFrostAPI) => + SDK.governance.proposalParameters( + '2dd15e0ef6e6a17841cb9541c27724072ce4d4b79b91e58432fbaa32d9572531', + 1, + ), + path: mainnetUrl( + `governance/proposals/2dd15e0ef6e6a17841cb9541c27724072ce4d4b79b91e58432fbaa32d9572531/1/parameters`, + ), + endpointMock: { + tx_hash: '…', + cert_index: 1, + parameters: { + epoch: 225, + min_fee_a: 44, + min_fee_b: 155381, + }, + }, + response: { + tx_hash: '…', + cert_index: 1, + parameters: { + epoch: 225, + min_fee_a: 44, + min_fee_b: 155381, + }, + }, + }, + { + command: (SDK: BlockFrostAPI) => + SDK.governance.proposalWithdrawals( + '2dd15e0ef6e6a17841cb9541c27724072ce4d4b79b91e58432fbaa32d9572531', + 1, + ), + path: mainnetUrl( + `governance/proposals/2dd15e0ef6e6a17841cb9541c27724072ce4d4b79b91e58432fbaa32d9572531/1/withdrawals`, + ), + endpointMock: [ + { + stake_address: + 'stake1ux3g2c9dx2nhhehyrezyxpkstartcqmu9hk63qgfkccw5rqttygt7', + amount: '454541212442', + }, + { + stake_address: + 'stake1xx2g2c9dx2nhhehyrezyxpkstoppcqmu9hk63qgfkccw5rqttygt2', + amount: '97846969', + }, + ], + response: [ + { + stake_address: + 'stake1ux3g2c9dx2nhhehyrezyxpkstartcqmu9hk63qgfkccw5rqttygt7', + amount: '454541212442', + }, + { + stake_address: + 'stake1xx2g2c9dx2nhhehyrezyxpkstoppcqmu9hk63qgfkccw5rqttygt2', + amount: '97846969', + }, + ], + }, + { + command: (SDK: BlockFrostAPI) => + SDK.governance.proposalVotes( + '2dd15e0ef6e6a17841cb9541c27724072ce4d4b79b91e58432fbaa32d9572531', + 1, + ), + path: mainnetUrl( + `governance/proposals/2dd15e0ef6e6a17841cb9541c27724072ce4d4b79b91e58432fbaa32d9572531/1/votes`, + ), + endpointMock: [ + { + tx_hash: 'b302de601defdf11a5261ed31a263804dac4a582a888c998ce24dec5', + cert_index: 2, + voter_role: 'drep', + voter: 'drep1mvdu8slennngja7w4un6knwezufra70887zuxpprd64jxfveahn', + vote: 'yes', + }, + { + tx_hash: 'b302de601defdf11a5261ed31a263804dac4a582a888c998ce24dec5', + cert_index: 3, + voter_role: 'constitutional_committee', + voter: '53a42debdc7ffd90085ab7fd9800b63e6d1c9ac481ba6eb7b6a844e4', + vote: 'abstain', + }, + ], + response: [ + { + tx_hash: 'b302de601defdf11a5261ed31a263804dac4a582a888c998ce24dec5', + cert_index: 2, + voter_role: 'drep', + voter: 'drep1mvdu8slennngja7w4un6knwezufra70887zuxpprd64jxfveahn', + vote: 'yes', + }, + { + tx_hash: 'b302de601defdf11a5261ed31a263804dac4a582a888c998ce24dec5', + cert_index: 3, + voter_role: 'constitutional_committee', + voter: '53a42debdc7ffd90085ab7fd9800b63e6d1c9ac481ba6eb7b6a844e4', + vote: 'abstain', + }, + ], + }, + { + command: (SDK: BlockFrostAPI) => + SDK.governance.proposalMetadata( + '257d75c8ddb0434e9b63e29ebb6241add2b835a307aa33aedba2effe09ed4ec8', + 2, + ), + path: mainnetUrl( + `governance/proposals/257d75c8ddb0434e9b63e29ebb6241add2b835a307aa33aedba2effe09ed4ec8/2/metadata`, + ), + endpointMock: { + tx_hash: + '257d75c8ddb0434e9b63e29ebb6241add2b835a307aa33aedba2effe09ed4ec8', + cert_index: 2, + url: 'https://raw.githubusercontent.com/carloslodelar/proposals/main/pv10.json', + hash: 'ffa226f3863aca006172d559cf46bb8b883a47233962ae2fc94c158d7de6fa81', + json_metadata: { + body: { + title: 'Hardfork to Protocol version 10', + }, + }, + }, + response: { + tx_hash: + '257d75c8ddb0434e9b63e29ebb6241add2b835a307aa33aedba2effe09ed4ec8', + cert_index: 2, + url: 'https://raw.githubusercontent.com/carloslodelar/proposals/main/pv10.json', + hash: 'ffa226f3863aca006172d559cf46bb8b883a47233962ae2fc94c158d7de6fa81', + json_metadata: { + body: { + title: 'Hardfork to Protocol version 10', + }, + }, + }, + }, ] as const;