"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.LCDQueryClient = void 0;
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
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 LCDQueryClient = /*#__PURE__*/function () {
  function LCDQueryClient(_ref) {
    var requestClient = _ref.requestClient;
    (0, _classCallCheck2["default"])(this, LCDQueryClient);
    (0, _defineProperty2["default"])(this, "req", void 0);
    this.req = requestClient;
    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);
  }
  /* Retrieves insurance params */
  (0, _createClass2["default"])(LCDQueryClient, [{
    key: "insuranceParams",
    value: function () {
      var _insuranceParams = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
        var _params,
          endpoint,
          _args = arguments;
        return _regenerator["default"].wrap(function _callee$(_context) {
          while (1) switch (_context.prev = _context.next) {
            case 0:
              _params = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
              endpoint = "injective/insurance/v1beta1/params";
              _context.next = 4;
              return this.req.get(endpoint);
            case 4:
              return _context.abrupt("return", _context.sent);
            case 5:
            case "end":
              return _context.stop();
          }
        }, _callee, this);
      }));
      function insuranceParams() {
        return _insuranceParams.apply(this, arguments);
      }
      return insuranceParams;
    }() /* Retrieves individual insurance fund information from market id */
  }, {
    key: "insuranceFund",
    value: function () {
      var _insuranceFund = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(params) {
        var endpoint;
        return _regenerator["default"].wrap(function _callee2$(_context2) {
          while (1) switch (_context2.prev = _context2.next) {
            case 0:
              endpoint = "injective/insurance/v1beta1/insurance_fund/".concat(params.marketId);
              _context2.next = 3;
              return this.req.get(endpoint);
            case 3:
              return _context2.abrupt("return", _context2.sent);
            case 4:
            case "end":
              return _context2.stop();
          }
        }, _callee2, this);
      }));
      function insuranceFund(_x) {
        return _insuranceFund.apply(this, arguments);
      }
      return insuranceFund;
    }() /* Retrieves all insurance funds */
  }, {
    key: "insuranceFunds",
    value: function () {
      var _insuranceFunds = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
        var _params,
          endpoint,
          _args3 = arguments;
        return _regenerator["default"].wrap(function _callee3$(_context3) {
          while (1) switch (_context3.prev = _context3.next) {
            case 0:
              _params = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {};
              endpoint = "injective/insurance/v1beta1/insurance_funds";
              _context3.next = 4;
              return this.req.get(endpoint);
            case 4:
              return _context3.abrupt("return", _context3.sent);
            case 5:
            case "end":
              return _context3.stop();
          }
        }, _callee3, this);
      }));
      function insuranceFunds() {
        return _insuranceFunds.apply(this, arguments);
      }
      return insuranceFunds;
    }() /* Retrives the value of insurance fund share token at current price (not pending redemption) */
  }, {
    key: "estimatedRedemptions",
    value: function () {
      var _estimatedRedemptions = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(params) {
        var options, endpoint;
        return _regenerator["default"].wrap(function _callee4$(_context4) {
          while (1) switch (_context4.prev = _context4.next) {
            case 0:
              options = {
                params: {}
              };
              if (typeof (params === null || params === void 0 ? void 0 : params.marketId) !== "undefined") {
                options.params.marketId = params.marketId;
              }
              if (typeof (params === null || params === void 0 ? void 0 : params.address) !== "undefined") {
                options.params.address = params.address;
              }
              endpoint = "injective/insurance/v1beta1/estimated_redemptions";
              _context4.next = 6;
              return this.req.get(endpoint, options);
            case 6:
              return _context4.abrupt("return", _context4.sent);
            case 7:
            case "end":
              return _context4.stop();
          }
        }, _callee4, this);
      }));
      function estimatedRedemptions(_x2) {
        return _estimatedRedemptions.apply(this, arguments);
      }
      return estimatedRedemptions;
    }() /* Retrieves pending redemptions' share token at current price */
  }, {
    key: "pendingRedemptions",
    value: function () {
      var _pendingRedemptions = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(params) {
        var options, endpoint;
        return _regenerator["default"].wrap(function _callee5$(_context5) {
          while (1) switch (_context5.prev = _context5.next) {
            case 0:
              options = {
                params: {}
              };
              if (typeof (params === null || params === void 0 ? void 0 : params.marketId) !== "undefined") {
                options.params.marketId = params.marketId;
              }
              if (typeof (params === null || params === void 0 ? void 0 : params.address) !== "undefined") {
                options.params.address = params.address;
              }
              endpoint = "injective/insurance/v1beta1/pending_redemptions";
              _context5.next = 6;
              return this.req.get(endpoint, options);
            case 6:
              return _context5.abrupt("return", _context5.sent);
            case 7:
            case "end":
              return _context5.stop();
          }
        }, _callee5, this);
      }));
      function pendingRedemptions(_x3) {
        return _pendingRedemptions.apply(this, arguments);
      }
      return pendingRedemptions;
    }() /* Retrieves the entire insurance module's state */
  }, {
    key: "insuranceModuleState",
    value: function () {
      var _insuranceModuleState = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
        var _params,
          endpoint,
          _args6 = arguments;
        return _regenerator["default"].wrap(function _callee6$(_context6) {
          while (1) switch (_context6.prev = _context6.next) {
            case 0:
              _params = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {};
              endpoint = "injective/insurance/v1beta1/module_state";
              _context6.next = 4;
              return this.req.get(endpoint);
            case 4:
              return _context6.abrupt("return", _context6.sent);
            case 5:
            case "end":
              return _context6.stop();
          }
        }, _callee6, this);
      }));
      function insuranceModuleState() {
        return _insuranceModuleState.apply(this, arguments);
      }
      return insuranceModuleState;
    }()
  }]);
  return LCDQueryClient;
}();
exports.LCDQueryClient = LCDQueryClient;