"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.MsgUpdateParamsResponse = exports.MsgUpdateParams = exports.MsgCreateRewardResponse = exports.MsgCreateReward = exports.MsgClaimResponse = exports.MsgClaim = exports.ClaimResponseReward = void 0;
var _coin = require("../cosmos/base/v1beta1/coin");
var _pool = require("./pool");
var _params = require("./params");
var _binary = require("../binary");
var _helpers = require("../helpers");
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
/** this line is used by starport scaffolding # proto/tx/message */

/** this line is used by starport scaffolding # proto/tx/message */

/** this line is used by starport scaffolding # proto/tx/message */

function createBaseMsgCreateReward() {
  return {
    creator: "",
    recipient: "",
    amount: _coin.Coin.fromPartial({}),
    series: 0
  };
}
var MsgCreateReward = exports.MsgCreateReward = {
  typeUrl: "/gitopia.gitopia.rewards.MsgCreateReward",
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _binary.BinaryWriter.create();
    if (message.creator !== "") {
      writer.uint32(10).string(message.creator);
    }
    if (message.recipient !== "") {
      writer.uint32(18).string(message.recipient);
    }
    if (message.amount !== undefined) {
      _coin.Coin.encode(message.amount, writer.uint32(26).fork()).ldelim();
    }
    if (message.series !== 0) {
      writer.uint32(32).int32(message.series);
    }
    return writer;
  },
  fromJSON: function fromJSON(object) {
    return {
      creator: (0, _helpers.isSet)(object.creator) ? String(object.creator) : "",
      recipient: (0, _helpers.isSet)(object.recipient) ? String(object.recipient) : "",
      amount: (0, _helpers.isSet)(object.amount) ? _coin.Coin.fromJSON(object.amount) : undefined,
      series: (0, _helpers.isSet)(object.series) ? (0, _pool.seriesFromJSON)(object.series) : -1
    };
  },
  fromPartial: function fromPartial(object) {
    var _object$creator, _object$recipient, _object$series;
    var message = createBaseMsgCreateReward();
    message.creator = (_object$creator = object.creator) !== null && _object$creator !== void 0 ? _object$creator : "";
    message.recipient = (_object$recipient = object.recipient) !== null && _object$recipient !== void 0 ? _object$recipient : "";
    message.amount = object.amount !== undefined && object.amount !== null ? _coin.Coin.fromPartial(object.amount) : undefined;
    message.series = (_object$series = object.series) !== null && _object$series !== void 0 ? _object$series : 0;
    return message;
  },
  fromAmino: function fromAmino(object) {
    var message = createBaseMsgCreateReward();
    if (object.creator !== undefined && object.creator !== null) {
      message.creator = object.creator;
    }
    if (object.recipient !== undefined && object.recipient !== null) {
      message.recipient = object.recipient;
    }
    if (object.amount !== undefined && object.amount !== null) {
      message.amount = _coin.Coin.fromAmino(object.amount);
    }
    if (object.series !== undefined && object.series !== null) {
      message.series = object.series;
    }
    return message;
  },
  toAmino: function toAmino(message) {
    var obj = {};
    obj.creator = message.creator === "" ? undefined : message.creator;
    obj.recipient = message.recipient === "" ? undefined : message.recipient;
    obj.amount = message.amount ? _coin.Coin.toAmino(message.amount) : undefined;
    obj.series = message.series === 0 ? undefined : message.series;
    return obj;
  },
  fromAminoMsg: function fromAminoMsg(object) {
    return MsgCreateReward.fromAmino(object.value);
  },
  fromProtoMsg: function fromProtoMsg(message) {
    return MsgCreateReward.decode(message.value);
  },
  toProto: function toProto(message) {
    return MsgCreateReward.encode(message).finish();
  },
  toProtoMsg: function toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.rewards.MsgCreateReward",
      value: MsgCreateReward.encode(message).finish()
    };
  }
};
function createBaseMsgCreateRewardResponse() {
  return {
    amount: _coin.Coin.fromPartial({})
  };
}
var MsgCreateRewardResponse = exports.MsgCreateRewardResponse = {
  typeUrl: "/gitopia.gitopia.rewards.MsgCreateRewardResponse",
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _binary.BinaryWriter.create();
    if (message.amount !== undefined) {
      _coin.Coin.encode(message.amount, writer.uint32(10).fork()).ldelim();
    }
    return writer;
  },
  fromJSON: function fromJSON(object) {
    return {
      amount: (0, _helpers.isSet)(object.amount) ? _coin.Coin.fromJSON(object.amount) : undefined
    };
  },
  fromPartial: function fromPartial(object) {
    var message = createBaseMsgCreateRewardResponse();
    message.amount = object.amount !== undefined && object.amount !== null ? _coin.Coin.fromPartial(object.amount) : undefined;
    return message;
  },
  fromAmino: function fromAmino(object) {
    var message = createBaseMsgCreateRewardResponse();
    if (object.amount !== undefined && object.amount !== null) {
      message.amount = _coin.Coin.fromAmino(object.amount);
    }
    return message;
  },
  toAmino: function toAmino(message) {
    var obj = {};
    obj.amount = message.amount ? _coin.Coin.toAmino(message.amount) : undefined;
    return obj;
  },
  fromAminoMsg: function fromAminoMsg(object) {
    return MsgCreateRewardResponse.fromAmino(object.value);
  },
  fromProtoMsg: function fromProtoMsg(message) {
    return MsgCreateRewardResponse.decode(message.value);
  },
  toProto: function toProto(message) {
    return MsgCreateRewardResponse.encode(message).finish();
  },
  toProtoMsg: function toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.rewards.MsgCreateRewardResponse",
      value: MsgCreateRewardResponse.encode(message).finish()
    };
  }
};
function createBaseMsgClaim() {
  return {
    creator: ""
  };
}
var MsgClaim = exports.MsgClaim = {
  typeUrl: "/gitopia.gitopia.rewards.MsgClaim",
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _binary.BinaryWriter.create();
    if (message.creator !== "") {
      writer.uint32(10).string(message.creator);
    }
    return writer;
  },
  fromJSON: function fromJSON(object) {
    return {
      creator: (0, _helpers.isSet)(object.creator) ? String(object.creator) : ""
    };
  },
  fromPartial: function fromPartial(object) {
    var _object$creator2;
    var message = createBaseMsgClaim();
    message.creator = (_object$creator2 = object.creator) !== null && _object$creator2 !== void 0 ? _object$creator2 : "";
    return message;
  },
  fromAmino: function fromAmino(object) {
    var message = createBaseMsgClaim();
    if (object.creator !== undefined && object.creator !== null) {
      message.creator = object.creator;
    }
    return message;
  },
  toAmino: function toAmino(message) {
    var obj = {};
    obj.creator = message.creator === "" ? undefined : message.creator;
    return obj;
  },
  fromAminoMsg: function fromAminoMsg(object) {
    return MsgClaim.fromAmino(object.value);
  },
  fromProtoMsg: function fromProtoMsg(message) {
    return MsgClaim.decode(message.value);
  },
  toProto: function toProto(message) {
    return MsgClaim.encode(message).finish();
  },
  toProtoMsg: function toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.rewards.MsgClaim",
      value: MsgClaim.encode(message).finish()
    };
  }
};
function createBaseClaimResponseReward() {
  return {
    series: 0,
    amount: _coin.Coin.fromPartial({})
  };
}
var ClaimResponseReward = exports.ClaimResponseReward = {
  typeUrl: "/gitopia.gitopia.rewards.ClaimResponseReward",
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _binary.BinaryWriter.create();
    if (message.series !== 0) {
      writer.uint32(8).int32(message.series);
    }
    if (message.amount !== undefined) {
      _coin.Coin.encode(message.amount, writer.uint32(18).fork()).ldelim();
    }
    return writer;
  },
  fromJSON: function fromJSON(object) {
    return {
      series: (0, _helpers.isSet)(object.series) ? (0, _pool.seriesFromJSON)(object.series) : -1,
      amount: (0, _helpers.isSet)(object.amount) ? _coin.Coin.fromJSON(object.amount) : undefined
    };
  },
  fromPartial: function fromPartial(object) {
    var _object$series2;
    var message = createBaseClaimResponseReward();
    message.series = (_object$series2 = object.series) !== null && _object$series2 !== void 0 ? _object$series2 : 0;
    message.amount = object.amount !== undefined && object.amount !== null ? _coin.Coin.fromPartial(object.amount) : undefined;
    return message;
  },
  fromAmino: function fromAmino(object) {
    var message = createBaseClaimResponseReward();
    if (object.series !== undefined && object.series !== null) {
      message.series = object.series;
    }
    if (object.amount !== undefined && object.amount !== null) {
      message.amount = _coin.Coin.fromAmino(object.amount);
    }
    return message;
  },
  toAmino: function toAmino(message) {
    var obj = {};
    obj.series = message.series === 0 ? undefined : message.series;
    obj.amount = message.amount ? _coin.Coin.toAmino(message.amount) : undefined;
    return obj;
  },
  fromAminoMsg: function fromAminoMsg(object) {
    return ClaimResponseReward.fromAmino(object.value);
  },
  fromProtoMsg: function fromProtoMsg(message) {
    return ClaimResponseReward.decode(message.value);
  },
  toProto: function toProto(message) {
    return ClaimResponseReward.encode(message).finish();
  },
  toProtoMsg: function toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.rewards.ClaimResponseReward",
      value: ClaimResponseReward.encode(message).finish()
    };
  }
};
function createBaseMsgClaimResponse() {
  return {
    claimedRewards: [],
    expiredRewards: [],
    allClaimedRewards: []
  };
}
var MsgClaimResponse = exports.MsgClaimResponse = {
  typeUrl: "/gitopia.gitopia.rewards.MsgClaimResponse",
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _binary.BinaryWriter.create();
    var _iterator = _createForOfIteratorHelper(message.claimedRewards),
      _step;
    try {
      for (_iterator.s(); !(_step = _iterator.n()).done;) {
        var v = _step.value;
        ClaimResponseReward.encode(v, writer.uint32(10).fork()).ldelim();
      }
    } catch (err) {
      _iterator.e(err);
    } finally {
      _iterator.f();
    }
    var _iterator2 = _createForOfIteratorHelper(message.expiredRewards),
      _step2;
    try {
      for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
        var _v = _step2.value;
        ClaimResponseReward.encode(_v, writer.uint32(18).fork()).ldelim();
      }
    } catch (err) {
      _iterator2.e(err);
    } finally {
      _iterator2.f();
    }
    var _iterator3 = _createForOfIteratorHelper(message.allClaimedRewards),
      _step3;
    try {
      for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
        var _v2 = _step3.value;
        ClaimResponseReward.encode(_v2, writer.uint32(26).fork()).ldelim();
      }
    } catch (err) {
      _iterator3.e(err);
    } finally {
      _iterator3.f();
    }
    return writer;
  },
  fromJSON: function fromJSON(object) {
    return {
      claimedRewards: Array.isArray(object === null || object === void 0 ? void 0 : object.claimedRewards) ? object.claimedRewards.map(function (e) {
        return ClaimResponseReward.fromJSON(e);
      }) : [],
      expiredRewards: Array.isArray(object === null || object === void 0 ? void 0 : object.expiredRewards) ? object.expiredRewards.map(function (e) {
        return ClaimResponseReward.fromJSON(e);
      }) : [],
      allClaimedRewards: Array.isArray(object === null || object === void 0 ? void 0 : object.allClaimedRewards) ? object.allClaimedRewards.map(function (e) {
        return ClaimResponseReward.fromJSON(e);
      }) : []
    };
  },
  fromPartial: function fromPartial(object) {
    var _object$claimedReward, _object$expiredReward, _object$allClaimedRew;
    var message = createBaseMsgClaimResponse();
    message.claimedRewards = ((_object$claimedReward = object.claimedRewards) === null || _object$claimedReward === void 0 ? void 0 : _object$claimedReward.map(function (e) {
      return ClaimResponseReward.fromPartial(e);
    })) || [];
    message.expiredRewards = ((_object$expiredReward = object.expiredRewards) === null || _object$expiredReward === void 0 ? void 0 : _object$expiredReward.map(function (e) {
      return ClaimResponseReward.fromPartial(e);
    })) || [];
    message.allClaimedRewards = ((_object$allClaimedRew = object.allClaimedRewards) === null || _object$allClaimedRew === void 0 ? void 0 : _object$allClaimedRew.map(function (e) {
      return ClaimResponseReward.fromPartial(e);
    })) || [];
    return message;
  },
  fromAmino: function fromAmino(object) {
    var _object$claimed_rewar, _object$expired_rewar, _object$all_claimed_r;
    var message = createBaseMsgClaimResponse();
    message.claimedRewards = ((_object$claimed_rewar = object.claimed_rewards) === null || _object$claimed_rewar === void 0 ? void 0 : _object$claimed_rewar.map(function (e) {
      return ClaimResponseReward.fromAmino(e);
    })) || [];
    message.expiredRewards = ((_object$expired_rewar = object.expired_rewards) === null || _object$expired_rewar === void 0 ? void 0 : _object$expired_rewar.map(function (e) {
      return ClaimResponseReward.fromAmino(e);
    })) || [];
    message.allClaimedRewards = ((_object$all_claimed_r = object.all_claimed_rewards) === null || _object$all_claimed_r === void 0 ? void 0 : _object$all_claimed_r.map(function (e) {
      return ClaimResponseReward.fromAmino(e);
    })) || [];
    return message;
  },
  toAmino: function toAmino(message) {
    var obj = {};
    if (message.claimedRewards) {
      obj.claimed_rewards = message.claimedRewards.map(function (e) {
        return e ? ClaimResponseReward.toAmino(e) : undefined;
      });
    } else {
      obj.claimed_rewards = message.claimedRewards;
    }
    if (message.expiredRewards) {
      obj.expired_rewards = message.expiredRewards.map(function (e) {
        return e ? ClaimResponseReward.toAmino(e) : undefined;
      });
    } else {
      obj.expired_rewards = message.expiredRewards;
    }
    if (message.allClaimedRewards) {
      obj.all_claimed_rewards = message.allClaimedRewards.map(function (e) {
        return e ? ClaimResponseReward.toAmino(e) : undefined;
      });
    } else {
      obj.all_claimed_rewards = message.allClaimedRewards;
    }
    return obj;
  },
  fromAminoMsg: function fromAminoMsg(object) {
    return MsgClaimResponse.fromAmino(object.value);
  },
  fromProtoMsg: function fromProtoMsg(message) {
    return MsgClaimResponse.decode(message.value);
  },
  toProto: function toProto(message) {
    return MsgClaimResponse.encode(message).finish();
  },
  toProtoMsg: function toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.rewards.MsgClaimResponse",
      value: MsgClaimResponse.encode(message).finish()
    };
  }
};
function createBaseMsgUpdateParams() {
  return {
    authority: "",
    params: _params.Params.fromPartial({})
  };
}
var MsgUpdateParams = exports.MsgUpdateParams = {
  typeUrl: "/gitopia.gitopia.rewards.MsgUpdateParams",
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _binary.BinaryWriter.create();
    if (message.authority !== "") {
      writer.uint32(10).string(message.authority);
    }
    if (message.params !== undefined) {
      _params.Params.encode(message.params, writer.uint32(18).fork()).ldelim();
    }
    return writer;
  },
  fromJSON: function fromJSON(object) {
    return {
      authority: (0, _helpers.isSet)(object.authority) ? String(object.authority) : "",
      params: (0, _helpers.isSet)(object.params) ? _params.Params.fromJSON(object.params) : undefined
    };
  },
  fromPartial: function fromPartial(object) {
    var _object$authority;
    var message = createBaseMsgUpdateParams();
    message.authority = (_object$authority = object.authority) !== null && _object$authority !== void 0 ? _object$authority : "";
    message.params = object.params !== undefined && object.params !== null ? _params.Params.fromPartial(object.params) : undefined;
    return message;
  },
  fromAmino: function fromAmino(object) {
    var message = createBaseMsgUpdateParams();
    if (object.authority !== undefined && object.authority !== null) {
      message.authority = object.authority;
    }
    if (object.params !== undefined && object.params !== null) {
      message.params = _params.Params.fromAmino(object.params);
    }
    return message;
  },
  toAmino: function toAmino(message) {
    var obj = {};
    obj.authority = message.authority === "" ? undefined : message.authority;
    obj.params = message.params ? _params.Params.toAmino(message.params) : undefined;
    return obj;
  },
  fromAminoMsg: function fromAminoMsg(object) {
    return MsgUpdateParams.fromAmino(object.value);
  },
  fromProtoMsg: function fromProtoMsg(message) {
    return MsgUpdateParams.decode(message.value);
  },
  toProto: function toProto(message) {
    return MsgUpdateParams.encode(message).finish();
  },
  toProtoMsg: function toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.rewards.MsgUpdateParams",
      value: MsgUpdateParams.encode(message).finish()
    };
  }
};
function createBaseMsgUpdateParamsResponse() {
  return {};
}
var MsgUpdateParamsResponse = exports.MsgUpdateParamsResponse = {
  typeUrl: "/gitopia.gitopia.rewards.MsgUpdateParamsResponse",
  encode: function encode(_) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _binary.BinaryWriter.create();
    return writer;
  },
  fromJSON: function fromJSON(_) {
    return {};
  },
  fromPartial: function fromPartial(_) {
    var message = createBaseMsgUpdateParamsResponse();
    return message;
  },
  fromAmino: function fromAmino(_) {
    var message = createBaseMsgUpdateParamsResponse();
    return message;
  },
  toAmino: function toAmino(_) {
    var obj = {};
    return obj;
  },
  fromAminoMsg: function fromAminoMsg(object) {
    return MsgUpdateParamsResponse.fromAmino(object.value);
  },
  fromProtoMsg: function fromProtoMsg(message) {
    return MsgUpdateParamsResponse.decode(message.value);
  },
  toProto: function toProto(message) {
    return MsgUpdateParamsResponse.encode(message).finish();
  },
  toProtoMsg: function toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.rewards.MsgUpdateParamsResponse",
      value: MsgUpdateParamsResponse.encode(message).finish()
    };
  }
};