//@ts-nocheck import { Rpc } from "../../../helpers"; import { BinaryReader } from "../../../binary"; import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; import { QueryEpochInfosRequest, QueryEpochInfosResponse, QueryCurrentEpochRequest, QueryCurrentEpochResponse } from "./query"; /** Query defines the gRPC querier service. */ export interface Query { /** EpochInfos provide running epochInfos */ epochInfos(request?: QueryEpochInfosRequest): Promise; /** CurrentEpoch provide current epoch of specified identifier */ currentEpoch(request: QueryCurrentEpochRequest): Promise; } export class QueryClientImpl implements Query { private readonly rpc: Rpc; constructor(rpc: Rpc) { this.rpc = rpc; this.epochInfos = this.epochInfos.bind(this); this.currentEpoch = this.currentEpoch.bind(this); } epochInfos(request: QueryEpochInfosRequest = {}): Promise { const data = QueryEpochInfosRequest.encode(request).finish(); const promise = this.rpc.request("cosmos.epochs.v1beta1.Query", "EpochInfos", data); return promise.then(data => QueryEpochInfosResponse.decode(new BinaryReader(data))); } currentEpoch(request: QueryCurrentEpochRequest): Promise { const data = QueryCurrentEpochRequest.encode(request).finish(); const promise = this.rpc.request("cosmos.epochs.v1beta1.Query", "CurrentEpoch", data); return promise.then(data => QueryCurrentEpochResponse.decode(new BinaryReader(data))); } } export const createRpcQueryExtension = (base: QueryClient) => { const rpc = createProtobufRpcClient(base); const queryService = new QueryClientImpl(rpc); return { epochInfos(request?: QueryEpochInfosRequest): Promise { return queryService.epochInfos(request); }, currentEpoch(request: QueryCurrentEpochRequest): Promise { return queryService.currentEpoch(request); } }; };