"use strict";

var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.RedemptionSchedule = exports.Params = exports.InsuranceFund = exports.EventWithdrawRedemption = exports.EventUnderwrite = exports.EventRequestRedemption = exports.EventInsuranceFundUpdate = void 0;
var _duration = require("../../../google/protobuf/duration");
var _timestamp = require("../../../google/protobuf/timestamp");
var _coin = require("../../../cosmos/base/v1beta1/coin");
var _m0 = _interopRequireWildcard(require("protobufjs/minimal"));
var _helpers = require("../../../helpers");
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; }
function createBaseParams() {
  return {
    defaultRedemptionNoticePeriodDuration: undefined
  };
}
var Params = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.defaultRedemptionNoticePeriodDuration !== undefined) {
      _duration.Duration.encode(message.defaultRedemptionNoticePeriodDuration, writer.uint32(10).fork()).ldelim();
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseParams();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.defaultRedemptionNoticePeriodDuration = _duration.Duration.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial: function fromPartial(object) {
    var message = createBaseParams();
    message.defaultRedemptionNoticePeriodDuration = object.defaultRedemptionNoticePeriodDuration !== undefined && object.defaultRedemptionNoticePeriodDuration !== null ? _duration.Duration.fromPartial(object.defaultRedemptionNoticePeriodDuration) : undefined;
    return message;
  }
};
exports.Params = Params;
function createBaseInsuranceFund() {
  return {
    depositDenom: "",
    insurancePoolTokenDenom: "",
    redemptionNoticePeriodDuration: undefined,
    balance: "",
    totalShare: "",
    marketId: "",
    marketTicker: "",
    oracleBase: "",
    oracleQuote: "",
    oracleType: 0,
    expiry: _helpers.Long.ZERO
  };
}
var InsuranceFund = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.depositDenom !== "") {
      writer.uint32(10).string(message.depositDenom);
    }
    if (message.insurancePoolTokenDenom !== "") {
      writer.uint32(18).string(message.insurancePoolTokenDenom);
    }
    if (message.redemptionNoticePeriodDuration !== undefined) {
      _duration.Duration.encode(message.redemptionNoticePeriodDuration, writer.uint32(26).fork()).ldelim();
    }
    if (message.balance !== "") {
      writer.uint32(34).string(message.balance);
    }
    if (message.totalShare !== "") {
      writer.uint32(42).string(message.totalShare);
    }
    if (message.marketId !== "") {
      writer.uint32(50).string(message.marketId);
    }
    if (message.marketTicker !== "") {
      writer.uint32(58).string(message.marketTicker);
    }
    if (message.oracleBase !== "") {
      writer.uint32(66).string(message.oracleBase);
    }
    if (message.oracleQuote !== "") {
      writer.uint32(74).string(message.oracleQuote);
    }
    if (message.oracleType !== 0) {
      writer.uint32(80).int32(message.oracleType);
    }
    if (!message.expiry.isZero()) {
      writer.uint32(88).int64(message.expiry);
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseInsuranceFund();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.depositDenom = reader.string();
          break;
        case 2:
          message.insurancePoolTokenDenom = reader.string();
          break;
        case 3:
          message.redemptionNoticePeriodDuration = _duration.Duration.decode(reader, reader.uint32());
          break;
        case 4:
          message.balance = reader.string();
          break;
        case 5:
          message.totalShare = reader.string();
          break;
        case 6:
          message.marketId = reader.string();
          break;
        case 7:
          message.marketTicker = reader.string();
          break;
        case 8:
          message.oracleBase = reader.string();
          break;
        case 9:
          message.oracleQuote = reader.string();
          break;
        case 10:
          message.oracleType = reader.int32();
          break;
        case 11:
          message.expiry = reader.int64();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial: function fromPartial(object) {
    var _object$depositDenom, _object$insurancePool, _object$balance, _object$totalShare, _object$marketId, _object$marketTicker, _object$oracleBase, _object$oracleQuote, _object$oracleType;
    var message = createBaseInsuranceFund();
    message.depositDenom = (_object$depositDenom = object.depositDenom) !== null && _object$depositDenom !== void 0 ? _object$depositDenom : "";
    message.insurancePoolTokenDenom = (_object$insurancePool = object.insurancePoolTokenDenom) !== null && _object$insurancePool !== void 0 ? _object$insurancePool : "";
    message.redemptionNoticePeriodDuration = object.redemptionNoticePeriodDuration !== undefined && object.redemptionNoticePeriodDuration !== null ? _duration.Duration.fromPartial(object.redemptionNoticePeriodDuration) : undefined;
    message.balance = (_object$balance = object.balance) !== null && _object$balance !== void 0 ? _object$balance : "";
    message.totalShare = (_object$totalShare = object.totalShare) !== null && _object$totalShare !== void 0 ? _object$totalShare : "";
    message.marketId = (_object$marketId = object.marketId) !== null && _object$marketId !== void 0 ? _object$marketId : "";
    message.marketTicker = (_object$marketTicker = object.marketTicker) !== null && _object$marketTicker !== void 0 ? _object$marketTicker : "";
    message.oracleBase = (_object$oracleBase = object.oracleBase) !== null && _object$oracleBase !== void 0 ? _object$oracleBase : "";
    message.oracleQuote = (_object$oracleQuote = object.oracleQuote) !== null && _object$oracleQuote !== void 0 ? _object$oracleQuote : "";
    message.oracleType = (_object$oracleType = object.oracleType) !== null && _object$oracleType !== void 0 ? _object$oracleType : 0;
    message.expiry = object.expiry !== undefined && object.expiry !== null ? _helpers.Long.fromValue(object.expiry) : _helpers.Long.ZERO;
    return message;
  }
};
exports.InsuranceFund = InsuranceFund;
function createBaseRedemptionSchedule() {
  return {
    id: _helpers.Long.UZERO,
    marketId: "",
    redeemer: "",
    claimableRedemptionTime: undefined,
    redemptionAmount: undefined
  };
}
var RedemptionSchedule = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (!message.id.isZero()) {
      writer.uint32(8).uint64(message.id);
    }
    if (message.marketId !== "") {
      writer.uint32(18).string(message.marketId);
    }
    if (message.redeemer !== "") {
      writer.uint32(26).string(message.redeemer);
    }
    if (message.claimableRedemptionTime !== undefined) {
      _timestamp.Timestamp.encode((0, _helpers.toTimestamp)(message.claimableRedemptionTime), writer.uint32(34).fork()).ldelim();
    }
    if (message.redemptionAmount !== undefined) {
      _coin.Coin.encode(message.redemptionAmount, writer.uint32(42).fork()).ldelim();
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseRedemptionSchedule();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.id = reader.uint64();
          break;
        case 2:
          message.marketId = reader.string();
          break;
        case 3:
          message.redeemer = reader.string();
          break;
        case 4:
          message.claimableRedemptionTime = (0, _helpers.fromTimestamp)(_timestamp.Timestamp.decode(reader, reader.uint32()));
          break;
        case 5:
          message.redemptionAmount = _coin.Coin.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial: function fromPartial(object) {
    var _object$marketId2, _object$redeemer, _object$claimableRede;
    var message = createBaseRedemptionSchedule();
    message.id = object.id !== undefined && object.id !== null ? _helpers.Long.fromValue(object.id) : _helpers.Long.UZERO;
    message.marketId = (_object$marketId2 = object.marketId) !== null && _object$marketId2 !== void 0 ? _object$marketId2 : "";
    message.redeemer = (_object$redeemer = object.redeemer) !== null && _object$redeemer !== void 0 ? _object$redeemer : "";
    message.claimableRedemptionTime = (_object$claimableRede = object.claimableRedemptionTime) !== null && _object$claimableRede !== void 0 ? _object$claimableRede : undefined;
    message.redemptionAmount = object.redemptionAmount !== undefined && object.redemptionAmount !== null ? _coin.Coin.fromPartial(object.redemptionAmount) : undefined;
    return message;
  }
};
exports.RedemptionSchedule = RedemptionSchedule;
function createBaseEventInsuranceFundUpdate() {
  return {
    fund: undefined
  };
}
var EventInsuranceFundUpdate = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.fund !== undefined) {
      InsuranceFund.encode(message.fund, writer.uint32(10).fork()).ldelim();
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseEventInsuranceFundUpdate();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.fund = InsuranceFund.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial: function fromPartial(object) {
    var message = createBaseEventInsuranceFundUpdate();
    message.fund = object.fund !== undefined && object.fund !== null ? InsuranceFund.fromPartial(object.fund) : undefined;
    return message;
  }
};
exports.EventInsuranceFundUpdate = EventInsuranceFundUpdate;
function createBaseEventRequestRedemption() {
  return {
    schedule: undefined
  };
}
var EventRequestRedemption = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.schedule !== undefined) {
      RedemptionSchedule.encode(message.schedule, writer.uint32(10).fork()).ldelim();
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseEventRequestRedemption();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.schedule = RedemptionSchedule.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial: function fromPartial(object) {
    var message = createBaseEventRequestRedemption();
    message.schedule = object.schedule !== undefined && object.schedule !== null ? RedemptionSchedule.fromPartial(object.schedule) : undefined;
    return message;
  }
};
exports.EventRequestRedemption = EventRequestRedemption;
function createBaseEventWithdrawRedemption() {
  return {
    schedule: undefined,
    redeemCoin: undefined
  };
}
var EventWithdrawRedemption = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.schedule !== undefined) {
      RedemptionSchedule.encode(message.schedule, writer.uint32(10).fork()).ldelim();
    }
    if (message.redeemCoin !== undefined) {
      _coin.Coin.encode(message.redeemCoin, writer.uint32(18).fork()).ldelim();
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseEventWithdrawRedemption();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.schedule = RedemptionSchedule.decode(reader, reader.uint32());
          break;
        case 2:
          message.redeemCoin = _coin.Coin.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial: function fromPartial(object) {
    var message = createBaseEventWithdrawRedemption();
    message.schedule = object.schedule !== undefined && object.schedule !== null ? RedemptionSchedule.fromPartial(object.schedule) : undefined;
    message.redeemCoin = object.redeemCoin !== undefined && object.redeemCoin !== null ? _coin.Coin.fromPartial(object.redeemCoin) : undefined;
    return message;
  }
};
exports.EventWithdrawRedemption = EventWithdrawRedemption;
function createBaseEventUnderwrite() {
  return {
    underwriter: "",
    marketId: "",
    deposit: undefined,
    shares: undefined
  };
}
var EventUnderwrite = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.underwriter !== "") {
      writer.uint32(10).string(message.underwriter);
    }
    if (message.marketId !== "") {
      writer.uint32(18).string(message.marketId);
    }
    if (message.deposit !== undefined) {
      _coin.Coin.encode(message.deposit, writer.uint32(26).fork()).ldelim();
    }
    if (message.shares !== undefined) {
      _coin.Coin.encode(message.shares, writer.uint32(34).fork()).ldelim();
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseEventUnderwrite();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.underwriter = reader.string();
          break;
        case 2:
          message.marketId = reader.string();
          break;
        case 3:
          message.deposit = _coin.Coin.decode(reader, reader.uint32());
          break;
        case 4:
          message.shares = _coin.Coin.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial: function fromPartial(object) {
    var _object$underwriter, _object$marketId3;
    var message = createBaseEventUnderwrite();
    message.underwriter = (_object$underwriter = object.underwriter) !== null && _object$underwriter !== void 0 ? _object$underwriter : "";
    message.marketId = (_object$marketId3 = object.marketId) !== null && _object$marketId3 !== void 0 ? _object$marketId3 : "";
    message.deposit = object.deposit !== undefined && object.deposit !== null ? _coin.Coin.fromPartial(object.deposit) : undefined;
    message.shares = object.shares !== undefined && object.shares !== null ? _coin.Coin.fromPartial(object.shares) : undefined;
    return message;
  }
};
exports.EventUnderwrite = EventUnderwrite;