"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.GenesisState = void 0;
var _rewards = require("./rewards");
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; }
/** GenesisState defines the rewards module's genesis state. */

/** GenesisState defines the rewards module's genesis state. */

/** GenesisState defines the rewards module's genesis state. */

function createBaseGenesisState() {
  return {
    rewardsList: [],
    params: _params.Params.fromPartial({})
  };
}
var GenesisState = exports.GenesisState = {
  typeUrl: "/gitopia.gitopia.rewards.GenesisState",
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _binary.BinaryWriter.create();
    var _iterator = _createForOfIteratorHelper(message.rewardsList),
      _step;
    try {
      for (_iterator.s(); !(_step = _iterator.n()).done;) {
        var v = _step.value;
        _rewards.Reward.encode(v, writer.uint32(18).fork()).ldelim();
      }
    } catch (err) {
      _iterator.e(err);
    } finally {
      _iterator.f();
    }
    if (message.params !== undefined) {
      _params.Params.encode(message.params, writer.uint32(10).fork()).ldelim();
    }
    return writer;
  },
  fromJSON: function fromJSON(object) {
    return {
      rewardsList: Array.isArray(object === null || object === void 0 ? void 0 : object.rewardsList) ? object.rewardsList.map(function (e) {
        return _rewards.Reward.fromJSON(e);
      }) : [],
      params: (0, _helpers.isSet)(object.params) ? _params.Params.fromJSON(object.params) : undefined
    };
  },
  fromPartial: function fromPartial(object) {
    var _object$rewardsList;
    var message = createBaseGenesisState();
    message.rewardsList = ((_object$rewardsList = object.rewardsList) === null || _object$rewardsList === void 0 ? void 0 : _object$rewardsList.map(function (e) {
      return _rewards.Reward.fromPartial(e);
    })) || [];
    message.params = object.params !== undefined && object.params !== null ? _params.Params.fromPartial(object.params) : undefined;
    return message;
  },
  fromAmino: function fromAmino(object) {
    var _object$rewardsList2;
    var message = createBaseGenesisState();
    message.rewardsList = ((_object$rewardsList2 = object.rewardsList) === null || _object$rewardsList2 === void 0 ? void 0 : _object$rewardsList2.map(function (e) {
      return _rewards.Reward.fromAmino(e);
    })) || [];
    if (object.params !== undefined && object.params !== null) {
      message.params = _params.Params.fromAmino(object.params);
    }
    return message;
  },
  toAmino: function toAmino(message) {
    var obj = {};
    if (message.rewardsList) {
      obj.rewardsList = message.rewardsList.map(function (e) {
        return e ? _rewards.Reward.toAmino(e) : undefined;
      });
    } else {
      obj.rewardsList = message.rewardsList;
    }
    obj.params = message.params ? _params.Params.toAmino(message.params) : undefined;
    return obj;
  },
  fromAminoMsg: function fromAminoMsg(object) {
    return GenesisState.fromAmino(object.value);
  },
  fromProtoMsg: function fromProtoMsg(message) {
    return GenesisState.decode(message.value);
  },
  toProto: function toProto(message) {
    return GenesisState.encode(message).finish();
  },
  toProtoMsg: function toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.rewards.GenesisState",
      value: GenesisState.encode(message).finish()
    };
  }
};