"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.createRpcQueryExtension = exports.QueryClientImpl = void 0;
const _m0 = __importStar(require("protobufjs/minimal"));
const stargate_1 = require("@cosmjs/stargate");
const query_1 = require("./query");
class QueryClientImpl {
    constructor(rpc) {
        this.rpc = rpc;
        this.downtimeParams = this.downtimeParams.bind(this);
        this.previousBlockInfo = this.previousBlockInfo.bind(this);
        this.allDowntimeInfo = this.allDowntimeInfo.bind(this);
        this.synchronyParams = this.synchronyParams.bind(this);
    }
    downtimeParams(request = {}) {
        const data = query_1.QueryDowntimeParamsRequest.encode(request).finish();
        const promise = this.rpc.request("ritbit.blocktime.Query", "DowntimeParams", data);
        return promise.then(data => query_1.QueryDowntimeParamsResponse.decode(new _m0.Reader(data)));
    }
    previousBlockInfo(request = {}) {
        const data = query_1.QueryPreviousBlockInfoRequest.encode(request).finish();
        const promise = this.rpc.request("ritbit.blocktime.Query", "PreviousBlockInfo", data);
        return promise.then(data => query_1.QueryPreviousBlockInfoResponse.decode(new _m0.Reader(data)));
    }
    allDowntimeInfo(request = {}) {
        const data = query_1.QueryAllDowntimeInfoRequest.encode(request).finish();
        const promise = this.rpc.request("ritbit.blocktime.Query", "AllDowntimeInfo", data);
        return promise.then(data => query_1.QueryAllDowntimeInfoResponse.decode(new _m0.Reader(data)));
    }
    synchronyParams(request = {}) {
        const data = query_1.QuerySynchronyParamsRequest.encode(request).finish();
        const promise = this.rpc.request("ritbit.blocktime.Query", "SynchronyParams", data);
        return promise.then(data => query_1.QuerySynchronyParamsResponse.decode(new _m0.Reader(data)));
    }
}
exports.QueryClientImpl = QueryClientImpl;
const createRpcQueryExtension = (base) => {
    const rpc = (0, stargate_1.createProtobufRpcClient)(base);
    const queryService = new QueryClientImpl(rpc);
    return {
        downtimeParams(request) {
            return queryService.downtimeParams(request);
        },
        previousBlockInfo(request) {
            return queryService.previousBlockInfo(request);
        },
        allDowntimeInfo(request) {
            return queryService.allDowntimeInfo(request);
        },
        synchronyParams(request) {
            return queryService.synchronyParams(request);
        }
    };
};
exports.createRpcQueryExtension = createRpcQueryExtension;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicXVlcnkucnBjLlF1ZXJ5LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vLi4vLi4vbm9kZV9tb2R1bGVzL0ByaXRiaXQvdjQtcHJvdG8vc3JjL2NvZGVnZW4vcml0Yml0L2Jsb2NrdGltZS9xdWVyeS5ycGMuUXVlcnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQ0Esd0RBQTBDO0FBQzFDLCtDQUF3RTtBQUN4RSxtQ0FBdVE7Q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