Skip to content

Commit

Permalink
chore: moved v1 endpoints to correct path
Browse files Browse the repository at this point in the history
  • Loading branch information
troykessler committed Jun 12, 2024
1 parent 52fb22e commit f2a420c
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 26 deletions.
7 changes: 7 additions & 0 deletions common/sdk/src/clients/lcd-client/client.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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;
};
Expand All @@ -33,6 +37,9 @@ class KyveLCDClient {
};

constructor(restEndpoint: string) {
this.v1 = {
bundles: new V1BundlesLCDClient(restEndpoint),
};
this.bundles = {
v1beta1: new BundlesModuleLCDClient(restEndpoint),
};
Expand Down
26 changes: 0 additions & 26 deletions common/sdk/src/clients/lcd-client/query/v1beta1/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,32 +127,6 @@ export class QueryModuleLCDClient extends AbstractKyveLCDClient {
}
/** end stakers **/
/** Bundles **/
async finalizedBundles(
params: PaginationPartialRequestUtilType<kyveQueryBundles.QueryFinalizedBundlesRequest>
): Promise<
PaginationResponseTypeUtil<kyveQueryBundlesRes.QueryFinalizedBundlesResponse>
> {
const parameters: Record<string, any> = {};

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<kyveQueryBundles.QueryFinalizedBundleResponse> {
const endpoint = `/kyve/v1/bundles/${params.pool_id}/${params.id}`;
return await this.request(endpoint);
}

async currentVoteStatus(
params: kyveQueryBundles.QueryCurrentVoteStatusRequest
): Promise<kyveQueryBundlesRes.QueryCurrentVoteStatusResponse> {
Expand Down
54 changes: 54 additions & 0 deletions common/sdk/src/clients/lcd-client/v1/bundles/query.ts
Original file line number Diff line number Diff line change
@@ -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<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;
type PaginationRequestType = {
offset: string;
limit: string;
count_total: boolean;
reverse: boolean;
key: string;
};
type PaginationPartialRequestUtilType<
T extends { pagination?: paginationQuery.PageRequest }
> = Overwrite<T, { pagination?: Partial<PaginationRequestType> }>;

type PaginationResponseTypeUtil<T> = Overwrite<
T,
{ pagination?: { next_key: string; total: string } }
>;

export class V1BundlesLCDClient extends AbstractKyveLCDClient {
constructor(restEndpoint: string) {
super(restEndpoint);
}

async finalizedBundles(
params: PaginationPartialRequestUtilType<kyveQueryBundles.QueryFinalizedBundlesRequest>
): Promise<
PaginationResponseTypeUtil<kyveQueryBundlesRes.QueryFinalizedBundlesResponse>
> {
const parameters: Record<string, any> = {};

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<kyveQueryBundles.QueryFinalizedBundleResponse> {
const endpoint = `/kyve/v1/bundles/${params.pool_id}/${params.id}`;
return await this.request(endpoint);
}
}

0 comments on commit f2a420c

Please sign in to comment.