//@ts-nocheck
import { Params, Token, TokenProperties } from "./token";
import * as _m0 from "protobufjs/minimal";
import { isSet } from "../../../helpers";
/** GenesisState defines the module's genesis state. */

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

function createBaseGenesisState() {
  return {
    params: undefined,
    tokens: [],
    tokenProperties: []
  };
}
export const GenesisState = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.params !== undefined) {
      Params.encode(message.params, writer.uint32(10).fork()).ldelim();
    }
    for (const v of message.tokens) {
      Token.encode(v, writer.uint32(18).fork()).ldelim();
    }
    for (const v of message.tokenProperties) {
      TokenProperties.encode(v, writer.uint32(26).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.params = Params.decode(reader, reader.uint32());
          break;
        case 2:
          message.tokens.push(Token.decode(reader, reader.uint32()));
          break;
        case 3:
          message.tokenProperties.push(TokenProperties.decode(reader, reader.uint32()));
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      params: isSet(object.params) ? Params.fromJSON(object.params) : undefined,
      tokens: Array.isArray(object === null || object === void 0 ? void 0 : object.tokens) ? object.tokens.map(e => Token.fromJSON(e)) : [],
      tokenProperties: Array.isArray(object === null || object === void 0 ? void 0 : object.tokenProperties) ? object.tokenProperties.map(e => TokenProperties.fromJSON(e)) : []
    };
  },
  toJSON(message) {
    const obj = {};
    message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined);
    if (message.tokens) {
      obj.tokens = message.tokens.map(e => e ? Token.toJSON(e) : undefined);
    } else {
      obj.tokens = [];
    }
    if (message.tokenProperties) {
      obj.tokenProperties = message.tokenProperties.map(e => e ? TokenProperties.toJSON(e) : undefined);
    } else {
      obj.tokenProperties = [];
    }
    return obj;
  },
  fromPartial(object) {
    var _object$tokens, _object$tokenProperti;
    const message = createBaseGenesisState();
    message.params = object.params !== undefined && object.params !== null ? Params.fromPartial(object.params) : undefined;
    message.tokens = ((_object$tokens = object.tokens) === null || _object$tokens === void 0 ? void 0 : _object$tokens.map(e => Token.fromPartial(e))) || [];
    message.tokenProperties = ((_object$tokenProperti = object.tokenProperties) === null || _object$tokenProperti === void 0 ? void 0 : _object$tokenProperti.map(e => TokenProperties.fromPartial(e))) || [];
    return message;
  }
};