"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.MsgClientImpl = 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 _tx = require("./tx");
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 MsgClientImpl = /*#__PURE__*/function () {
  function MsgClientImpl(rpc) {
    (0, _classCallCheck2["default"])(this, MsgClientImpl);
    (0, _defineProperty2["default"])(this, "rpc", void 0);
    this.rpc = rpc;
    this.createInsuranceFund = this.createInsuranceFund.bind(this);
    this.underwrite = this.underwrite.bind(this);
    this.requestRedemption = this.requestRedemption.bind(this);
  }
  (0, _createClass2["default"])(MsgClientImpl, [{
    key: "createInsuranceFund",
    value: function createInsuranceFund(request) {
      var data = _tx.MsgCreateInsuranceFund.encode(request).finish();
      var promise = this.rpc.request("injective.insurance.v1beta1.Msg", "CreateInsuranceFund", data);
      return promise.then(function (data) {
        return _tx.MsgCreateInsuranceFundResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "underwrite",
    value: function underwrite(request) {
      var data = _tx.MsgUnderwrite.encode(request).finish();
      var promise = this.rpc.request("injective.insurance.v1beta1.Msg", "Underwrite", data);
      return promise.then(function (data) {
        return _tx.MsgUnderwriteResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "requestRedemption",
    value: function requestRedemption(request) {
      var data = _tx.MsgRequestRedemption.encode(request).finish();
      var promise = this.rpc.request("injective.insurance.v1beta1.Msg", "RequestRedemption", data);
      return promise.then(function (data) {
        return _tx.MsgRequestRedemptionResponse.decode(new _m0.Reader(data));
      });
    }
  }]);
  return MsgClientImpl;
}();
exports.MsgClientImpl = MsgClientImpl;