import { BinaryReader } from '@agoric/cosmic-proto/codegen/binary.js';
import { QueryClient, createProtobufRpcClient } from '@cosmjs/stargate';
import { QueryCounterpartyInfoRequest, QueryCounterpartyInfoResponse, QueryConfigRequest, QueryConfigResponse, } from '@agoric/cosmic-proto/codegen/ibc/core/client/v2/query.js';
export class QueryClientImpl {
    rpc;
    constructor(rpc) {
        this.rpc = rpc;
        this.counterpartyInfo = this.counterpartyInfo.bind(this);
        this.config = this.config.bind(this);
    }
    counterpartyInfo(request) {
        const data = QueryCounterpartyInfoRequest.encode(request).finish();
        const promise = this.rpc.request('ibc.core.client.v2.Query', 'CounterpartyInfo', data);
        return promise.then(data => QueryCounterpartyInfoResponse.decode(new BinaryReader(data)));
    }
    config(request) {
        const data = QueryConfigRequest.encode(request).finish();
        const promise = this.rpc.request('ibc.core.client.v2.Query', 'Config', data);
        return promise.then(data => QueryConfigResponse.decode(new BinaryReader(data)));
    }
}
export const createRpcQueryExtension = (base) => {
    const rpc = createProtobufRpcClient(base);
    const queryService = new QueryClientImpl(rpc);
    return {
        counterpartyInfo(request) {
            return queryService.counterpartyInfo(request);
        },
        config(request) {
            return queryService.config(request);
        },
    };
};
//# sourceMappingURL=query.rpc.Query.js.map