"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.createRpcQueryExtension = exports.ServiceClientImpl = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _binary = require("../../../../binary");
var _stargate = require("@cosmjs/stargate");
var _query = require("./query");
/** Service defines the gRPC querier service for node related queries. */
var ServiceClientImpl = exports.ServiceClientImpl = /*#__PURE__*/function () {
  function ServiceClientImpl(rpc) {
    (0, _classCallCheck2["default"])(this, ServiceClientImpl);
    (0, _defineProperty2["default"])(this, "rpc", void 0);
    this.rpc = rpc;
    this.config = this.config.bind(this);
  }
  return (0, _createClass2["default"])(ServiceClientImpl, [{
    key: "config",
    value: function config() {
      var request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var data = _query.ConfigRequest.encode(request).finish();
      var promise = this.rpc.request("cosmos.base.node.v1beta1.Service", "Config", data);
      return promise.then(function (data) {
        return _query.ConfigResponse.decode(new _binary.BinaryReader(data));
      });
    }
  }]);
}();
var createRpcQueryExtension = exports.createRpcQueryExtension = function createRpcQueryExtension(base) {
  var rpc = (0, _stargate.createProtobufRpcClient)(base);
  var queryService = new ServiceClientImpl(rpc);
  return {
    config: function config(request) {
      return queryService.config(request);
    }
  };
};