"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.createRpcQueryExtension = exports.QueryClientImpl = 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 _m0 = _interopRequireWildcard(require("protobufjs/minimal"));
var _stargate = require("@cosmjs/stargate");
var _query = require("./query");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var QueryClientImpl = /*#__PURE__*/function () {
  function QueryClientImpl(rpc) {
    (0, _classCallCheck2["default"])(this, QueryClientImpl);
    (0, _defineProperty2["default"])(this, "rpc", void 0);
    this.rpc = rpc;
    this.insuranceParams = this.insuranceParams.bind(this);
    this.insuranceFund = this.insuranceFund.bind(this);
    this.insuranceFunds = this.insuranceFunds.bind(this);
    this.estimatedRedemptions = this.estimatedRedemptions.bind(this);
    this.pendingRedemptions = this.pendingRedemptions.bind(this);
    this.insuranceModuleState = this.insuranceModuleState.bind(this);
  }
  (0, _createClass2["default"])(QueryClientImpl, [{
    key: "insuranceParams",
    value: function insuranceParams() {
      var request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var data = _query.QueryInsuranceParamsRequest.encode(request).finish();
      var promise = this.rpc.request("injective.insurance.v1beta1.Query", "InsuranceParams", data);
      return promise.then(function (data) {
        return _query.QueryInsuranceParamsResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "insuranceFund",
    value: function insuranceFund(request) {
      var data = _query.QueryInsuranceFundRequest.encode(request).finish();
      var promise = this.rpc.request("injective.insurance.v1beta1.Query", "InsuranceFund", data);
      return promise.then(function (data) {
        return _query.QueryInsuranceFundResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "insuranceFunds",
    value: function insuranceFunds() {
      var request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var data = _query.QueryInsuranceFundsRequest.encode(request).finish();
      var promise = this.rpc.request("injective.insurance.v1beta1.Query", "InsuranceFunds", data);
      return promise.then(function (data) {
        return _query.QueryInsuranceFundsResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "estimatedRedemptions",
    value: function estimatedRedemptions(request) {
      var data = _query.QueryEstimatedRedemptionsRequest.encode(request).finish();
      var promise = this.rpc.request("injective.insurance.v1beta1.Query", "EstimatedRedemptions", data);
      return promise.then(function (data) {
        return _query.QueryEstimatedRedemptionsResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "pendingRedemptions",
    value: function pendingRedemptions(request) {
      var data = _query.QueryPendingRedemptionsRequest.encode(request).finish();
      var promise = this.rpc.request("injective.insurance.v1beta1.Query", "PendingRedemptions", data);
      return promise.then(function (data) {
        return _query.QueryPendingRedemptionsResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "insuranceModuleState",
    value: function insuranceModuleState() {
      var request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var data = _query.QueryModuleStateRequest.encode(request).finish();
      var promise = this.rpc.request("injective.insurance.v1beta1.Query", "InsuranceModuleState", data);
      return promise.then(function (data) {
        return _query.QueryModuleStateResponse.decode(new _m0.Reader(data));
      });
    }
  }]);
  return QueryClientImpl;
}();
exports.QueryClientImpl = QueryClientImpl;
var createRpcQueryExtension = function createRpcQueryExtension(base) {
  var rpc = (0, _stargate.createProtobufRpcClient)(base);
  var queryService = new QueryClientImpl(rpc);
  return {
    insuranceParams: function insuranceParams(request) {
      return queryService.insuranceParams(request);
    },
    insuranceFund: function insuranceFund(request) {
      return queryService.insuranceFund(request);
    },
    insuranceFunds: function insuranceFunds(request) {
      return queryService.insuranceFunds(request);
    },
    estimatedRedemptions: function estimatedRedemptions(request) {
      return queryService.estimatedRedemptions(request);
    },
    pendingRedemptions: function pendingRedemptions(request) {
      return queryService.pendingRedemptions(request);
    },
    insuranceModuleState: function insuranceModuleState(request) {
      return queryService.insuranceModuleState(request);
    }
  };
};
exports.createRpcQueryExtension = createRpcQueryExtension;