import { BinaryReader } from '@agoric/cosmic-proto/codegen/binary.js';
import { QueryClient, createProtobufRpcClient } from '@cosmjs/stargate';
import { QueryEpochInfosRequest, QueryEpochInfosResponse, QueryCurrentEpochRequest, QueryCurrentEpochResponse, } from '@agoric/cosmic-proto/codegen/cosmos/epochs/v1beta1/query.js';
export class QueryClientImpl {
    rpc;
    constructor(rpc) {
        this.rpc = rpc;
        this.epochInfos = this.epochInfos.bind(this);
        this.currentEpoch = this.currentEpoch.bind(this);
    }
    epochInfos(request = {}) {
        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) {
        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) => {
    const rpc = createProtobufRpcClient(base);
    const queryService = new QueryClientImpl(rpc);
    return {
        epochInfos(request) {
            return queryService.epochInfos(request);
        },
        currentEpoch(request) {
            return queryService.currentEpoch(request);
        },
    };
};
//# sourceMappingURL=query.rpc.Query.js.map