import { Schedule } from "./store";
import { Long } from "../../../helpers";
import * as _m0 from "protobufjs/minimal";
/** GenesisState defines the incentives module's genesis state */

function createBaseGenesisState() {
  return {
    nextScheduleId: Long.UZERO,
    schedules: []
  };
}
export const GenesisState = {
  encode(message, writer = _m0.Writer.create()) {
    if (!message.nextScheduleId.isZero()) {
      writer.uint32(8).uint64(message.nextScheduleId);
    }
    for (const v of message.schedules) {
      Schedule.encode(v, writer.uint32(18).fork()).ldelim();
    }
    return writer;
  },
  decode(input, length) {
    const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseGenesisState();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.nextScheduleId = reader.uint64();
          break;
        case 2:
          message.schedules.push(Schedule.decode(reader, reader.uint32()));
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$schedules;
    const message = createBaseGenesisState();
    message.nextScheduleId = object.nextScheduleId !== undefined && object.nextScheduleId !== null ? Long.fromValue(object.nextScheduleId) : Long.UZERO;
    message.schedules = ((_object$schedules = object.schedules) === null || _object$schedules === void 0 ? void 0 : _object$schedules.map(e => Schedule.fromPartial(e))) || [];
    return message;
  }
};