import { Reward } from "./rewards";
import { Params } from "./params";
import { BinaryWriter } from "../binary";
import { isSet } from "../helpers";
/** 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.fromPartial({})
  };
}
export const GenesisState = {
  typeUrl: "/gitopia.gitopia.rewards.GenesisState",
  encode(message, writer = BinaryWriter.create()) {
    for (const v of message.rewardsList) {
      Reward.encode(v, writer.uint32(18).fork()).ldelim();
    }
    if (message.params !== undefined) {
      Params.encode(message.params, writer.uint32(10).fork()).ldelim();
    }
    return writer;
  },
  fromJSON(object) {
    return {
      rewardsList: Array.isArray(object === null || object === void 0 ? void 0 : object.rewardsList) ? object.rewardsList.map(e => Reward.fromJSON(e)) : [],
      params: isSet(object.params) ? Params.fromJSON(object.params) : undefined
    };
  },
  fromPartial(object) {
    var _object$rewardsList;
    const message = createBaseGenesisState();
    message.rewardsList = ((_object$rewardsList = object.rewardsList) === null || _object$rewardsList === void 0 ? void 0 : _object$rewardsList.map(e => Reward.fromPartial(e))) || [];
    message.params = object.params !== undefined && object.params !== null ? Params.fromPartial(object.params) : undefined;
    return message;
  },
  fromAmino(object) {
    var _object$rewardsList2;
    const message = createBaseGenesisState();
    message.rewardsList = ((_object$rewardsList2 = object.rewardsList) === null || _object$rewardsList2 === void 0 ? void 0 : _object$rewardsList2.map(e => Reward.fromAmino(e))) || [];
    if (object.params !== undefined && object.params !== null) {
      message.params = Params.fromAmino(object.params);
    }
    return message;
  },
  toAmino(message) {
    const obj = {};
    if (message.rewardsList) {
      obj.rewardsList = message.rewardsList.map(e => e ? Reward.toAmino(e) : undefined);
    } else {
      obj.rewardsList = message.rewardsList;
    }
    obj.params = message.params ? Params.toAmino(message.params) : undefined;
    return obj;
  },
  fromAminoMsg(object) {
    return GenesisState.fromAmino(object.value);
  },
  fromProtoMsg(message) {
    return GenesisState.decode(message.value);
  },
  toProto(message) {
    return GenesisState.encode(message).finish();
  },
  toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.rewards.GenesisState",
      value: GenesisState.encode(message).finish()
    };
  }
};