diff --git a/common/sdk/src/clients/lcd-client/client.ts b/common/sdk/src/clients/lcd-client/client.ts index eb63586e..240c752a 100644 --- a/common/sdk/src/clients/lcd-client/client.ts +++ b/common/sdk/src/clients/lcd-client/client.ts @@ -1,3 +1,4 @@ +import { V1BundlesLCDClient } from "./v1/bundles/query"; import { BundlesModuleLCDClient } from "./bundles/v1beta1/query"; import { DelegationModuleLCDClient } from "./delegation/v1beta1/query"; import { FundersModuleLCDClient } from "./funders/v1beta1/query"; @@ -7,6 +8,9 @@ import { QueryModuleLCDClient } from "./query/v1beta1/query"; import { StakersModuleLCDClient } from "./stakers/v1beta1/query"; import { TeamModuleLCDClient } from "./team/v1beta1/query"; class KyveLCDClient { + public v1: { + bundles: V1BundlesLCDClient; + }; public bundles: { v1beta1: BundlesModuleLCDClient; }; @@ -33,6 +37,9 @@ class KyveLCDClient { }; constructor(restEndpoint: string) { + this.v1 = { + bundles: new V1BundlesLCDClient(restEndpoint), + }; this.bundles = { v1beta1: new BundlesModuleLCDClient(restEndpoint), }; diff --git a/common/sdk/src/clients/lcd-client/query/v1beta1/query.ts b/common/sdk/src/clients/lcd-client/query/v1beta1/query.ts index f0887133..c1fc9cd2 100644 --- a/common/sdk/src/clients/lcd-client/query/v1beta1/query.ts +++ b/common/sdk/src/clients/lcd-client/query/v1beta1/query.ts @@ -127,32 +127,6 @@ export class QueryModuleLCDClient extends AbstractKyveLCDClient { } /** end stakers **/ /** Bundles **/ - async finalizedBundles( - params: PaginationPartialRequestUtilType - ): Promise< - PaginationResponseTypeUtil - > { - const parameters: Record = {}; - - if (typeof params?.pagination !== "undefined") { - parameters.pagination = params.pagination; - } - - if (typeof params.index !== "undefined") { - parameters.index = params.index; - } - - const endpoint = `/kyve/v1/bundles/${params.pool_id}`; - return await this.request(endpoint, parameters); - } - - async finalizedBundle( - params: kyveQueryBundles.QueryFinalizedBundleRequest - ): Promise { - const endpoint = `/kyve/v1/bundles/${params.pool_id}/${params.id}`; - return await this.request(endpoint); - } - async currentVoteStatus( params: kyveQueryBundles.QueryCurrentVoteStatusRequest ): Promise { diff --git a/common/sdk/src/clients/lcd-client/v1/bundles/query.ts b/common/sdk/src/clients/lcd-client/v1/bundles/query.ts new file mode 100644 index 00000000..44e042c2 --- /dev/null +++ b/common/sdk/src/clients/lcd-client/v1/bundles/query.ts @@ -0,0 +1,54 @@ +import paginationQuery from "@kyvejs/types/client/cosmos/base/query/v1beta1/pagination"; +import kyveQueryBundles from "@kyvejs/types/client/kyve/query/v1beta1/bundles"; +import kyveQueryBundlesRes from "@kyvejs/types/lcd/kyve/query/v1beta1/bundles"; + +import { AbstractKyveLCDClient } from "../../lcd-client.abstract"; + +type Overwrite = Pick> & U; +type PaginationRequestType = { + offset: string; + limit: string; + count_total: boolean; + reverse: boolean; + key: string; +}; +type PaginationPartialRequestUtilType< + T extends { pagination?: paginationQuery.PageRequest } +> = Overwrite }>; + +type PaginationResponseTypeUtil = Overwrite< + T, + { pagination?: { next_key: string; total: string } } +>; + +export class V1BundlesLCDClient extends AbstractKyveLCDClient { + constructor(restEndpoint: string) { + super(restEndpoint); + } + + async finalizedBundles( + params: PaginationPartialRequestUtilType + ): Promise< + PaginationResponseTypeUtil + > { + const parameters: Record = {}; + + if (typeof params?.pagination !== "undefined") { + parameters.pagination = params.pagination; + } + + if (typeof params.index !== "undefined") { + parameters.index = params.index; + } + + const endpoint = `/kyve/v1/bundles/${params.pool_id}`; + return await this.request(endpoint, parameters); + } + + async finalizedBundle( + params: kyveQueryBundles.QueryFinalizedBundleRequest + ): Promise { + const endpoint = `/kyve/v1/bundles/${params.pool_id}/${params.id}`; + return await this.request(endpoint); + } +}