Skip to content

Commit

Permalink
Re-codegenning for indexer.
Browse files Browse the repository at this point in the history
  • Loading branch information
Crystal Lemire committed Oct 19, 2023
1 parent 58bff90 commit 8d7c7e1
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LCDClient } from "@osmonauts/lcd";
import { QueryParamsRequest, QueryParamsResponseSDKType } from "./query";
import { QueryParamsRequest, QueryParamsResponseSDKType, QueryRewardShareRequest, QueryRewardShareResponseSDKType } from "./query";
export class LCDQueryClient {
req: LCDClient;

Expand All @@ -10,6 +10,7 @@ export class LCDQueryClient {
}) {
this.req = requestClient;
this.params = this.params.bind(this);
this.rewardShare = this.rewardShare.bind(this);
}
/* Queries the Params. */

Expand All @@ -18,5 +19,12 @@ export class LCDQueryClient {
const endpoint = `dydxprotocol/v4/rewards/params`;
return await this.req.get<QueryParamsResponseSDKType>(endpoint);
}
/* Queries a reward share by address. */


async rewardShare(params: QueryRewardShareRequest): Promise<QueryRewardShareResponseSDKType> {
const endpoint = `dydxprotocol/v4/rewards/shares/${params.address}`;
return await this.req.get<QueryRewardShareResponseSDKType>(endpoint);
}

}
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import { Rpc } from "../../helpers";
import * as _m0 from "protobufjs/minimal";
import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate";
import { QueryParamsRequest, QueryParamsResponse } from "./query";
import { QueryParamsRequest, QueryParamsResponse, QueryRewardShareRequest, QueryRewardShareResponse } from "./query";
/** Query defines the gRPC querier service. */

export interface Query {
/** Queries the Params. */
params(request?: QueryParamsRequest): Promise<QueryParamsResponse>;
/** Queries a reward share by address. */

rewardShare(request: QueryRewardShareRequest): Promise<QueryRewardShareResponse>;
}
export class QueryClientImpl implements Query {
private readonly rpc: Rpc;

constructor(rpc: Rpc) {
this.rpc = rpc;
this.params = this.params.bind(this);
this.rewardShare = this.rewardShare.bind(this);
}

params(request: QueryParamsRequest = {}): Promise<QueryParamsResponse> {
Expand All @@ -22,13 +26,23 @@ export class QueryClientImpl implements Query {
return promise.then(data => QueryParamsResponse.decode(new _m0.Reader(data)));
}

rewardShare(request: QueryRewardShareRequest): Promise<QueryRewardShareResponse> {
const data = QueryRewardShareRequest.encode(request).finish();
const promise = this.rpc.request("dydxprotocol.rewards.Query", "RewardShare", data);
return promise.then(data => QueryRewardShareResponse.decode(new _m0.Reader(data)));
}

}
export const createRpcQueryExtension = (base: QueryClient) => {
const rpc = createProtobufRpcClient(base);
const queryService = new QueryClientImpl(rpc);
return {
params(request?: QueryParamsRequest): Promise<QueryParamsResponse> {
return queryService.params(request);
},

rewardShare(request: QueryRewardShareRequest): Promise<QueryRewardShareResponse> {
return queryService.rewardShare(request);
}

};
Expand Down
111 changes: 111 additions & 0 deletions indexer/packages/v4-protos/src/codegen/dydxprotocol/rewards/query.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Params, ParamsSDKType } from "./params";
import { RewardShare, RewardShareSDKType } from "./reward_share";
import * as _m0 from "protobufjs/minimal";
import { DeepPartial } from "../../helpers";
/** QueryParamsRequest is a request type for the Params RPC method. */
Expand All @@ -17,6 +18,26 @@ export interface QueryParamsResponse {
export interface QueryParamsResponseSDKType {
params?: ParamsSDKType;
}
/** QueryRewardShareRequest is a request type for the RewardShare RPC method. */

export interface QueryRewardShareRequest {
address: string;
}
/** QueryRewardShareRequest is a request type for the RewardShare RPC method. */

export interface QueryRewardShareRequestSDKType {
address: string;
}
/** QueryRewardShareResponse is a response type for the RewardsShare RPC method. */

export interface QueryRewardShareResponse {
rewardShare?: RewardShare;
}
/** QueryRewardShareResponse is a response type for the RewardsShare RPC method. */

export interface QueryRewardShareResponseSDKType {
reward_share?: RewardShareSDKType;
}

function createBaseQueryParamsRequest(): QueryParamsRequest {
return {};
Expand Down Expand Up @@ -95,4 +116,94 @@ export const QueryParamsResponse = {
return message;
}

};

function createBaseQueryRewardShareRequest(): QueryRewardShareRequest {
return {
address: ""
};
}

export const QueryRewardShareRequest = {
encode(message: QueryRewardShareRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.address !== "") {
writer.uint32(10).string(message.address);
}

return writer;
},

decode(input: _m0.Reader | Uint8Array, length?: number): QueryRewardShareRequest {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseQueryRewardShareRequest();

while (reader.pos < end) {
const tag = reader.uint32();

switch (tag >>> 3) {
case 1:
message.address = reader.string();
break;

default:
reader.skipType(tag & 7);
break;
}
}

return message;
},

fromPartial(object: DeepPartial<QueryRewardShareRequest>): QueryRewardShareRequest {
const message = createBaseQueryRewardShareRequest();
message.address = object.address ?? "";
return message;
}

};

function createBaseQueryRewardShareResponse(): QueryRewardShareResponse {
return {
rewardShare: undefined
};
}

export const QueryRewardShareResponse = {
encode(message: QueryRewardShareResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.rewardShare !== undefined) {
RewardShare.encode(message.rewardShare, writer.uint32(10).fork()).ldelim();
}

return writer;
},

decode(input: _m0.Reader | Uint8Array, length?: number): QueryRewardShareResponse {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseQueryRewardShareResponse();

while (reader.pos < end) {
const tag = reader.uint32();

switch (tag >>> 3) {
case 1:
message.rewardShare = RewardShare.decode(reader, reader.uint32());
break;

default:
reader.skipType(tag & 7);
break;
}
}

return message;
},

fromPartial(object: DeepPartial<QueryRewardShareResponse>): QueryRewardShareResponse {
const message = createBaseQueryRewardShareResponse();
message.rewardShare = object.rewardShare !== undefined && object.rewardShare !== null ? RewardShare.fromPartial(object.rewardShare) : undefined;
return message;
}

};

0 comments on commit 8d7c7e1

Please sign in to comment.