/* eslint-disable */
import { Writer, Reader } from "protobufjs/minimal";

export const protobufPackage = "cosmostest.cosmostest";

export interface Auction {
  index: string;
  name: string;
  description: string;
  bids: string;
  highestBid: string;
}

const baseAuction: object = {
  index: "",
  name: "",
  description: "",
  bids: "",
  highestBid: "",
};

export const Auction = {
  encode(message: Auction, writer: Writer = Writer.create()): Writer {
    if (message.index !== "") {
      writer.uint32(10).string(message.index);
    }
    if (message.name !== "") {
      writer.uint32(18).string(message.name);
    }
    if (message.description !== "") {
      writer.uint32(26).string(message.description);
    }
    if (message.bids !== "") {
      writer.uint32(34).string(message.bids);
    }
    if (message.highestBid !== "") {
      writer.uint32(42).string(message.highestBid);
    }
    return writer;
  },

  decode(input: Reader | Uint8Array, length?: number): Auction {
    const reader = input instanceof Uint8Array ? new Reader(input) : input;
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = { ...baseAuction } as Auction;
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.index = reader.string();
          break;
        case 2:
          message.name = reader.string();
          break;
        case 3:
          message.description = reader.string();
          break;
        case 4:
          message.bids = reader.string();
          break;
        case 5:
          message.highestBid = reader.string();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },

  fromJSON(object: any): Auction {
    const message = { ...baseAuction } as Auction;
    if (object.index !== undefined && object.index !== null) {
      message.index = String(object.index);
    } else {
      message.index = "";
    }
    if (object.name !== undefined && object.name !== null) {
      message.name = String(object.name);
    } else {
      message.name = "";
    }
    if (object.description !== undefined && object.description !== null) {
      message.description = String(object.description);
    } else {
      message.description = "";
    }
    if (object.bids !== undefined && object.bids !== null) {
      message.bids = String(object.bids);
    } else {
      message.bids = "";
    }
    if (object.highestBid !== undefined && object.highestBid !== null) {
      message.highestBid = String(object.highestBid);
    } else {
      message.highestBid = "";
    }
    return message;
  },

  toJSON(message: Auction): unknown {
    const obj: any = {};
    message.index !== undefined && (obj.index = message.index);
    message.name !== undefined && (obj.name = message.name);
    message.description !== undefined &&
      (obj.description = message.description);
    message.bids !== undefined && (obj.bids = message.bids);
    message.highestBid !== undefined && (obj.highestBid = message.highestBid);
    return obj;
  },

  fromPartial(object: DeepPartial<Auction>): Auction {
    const message = { ...baseAuction } as Auction;
    if (object.index !== undefined && object.index !== null) {
      message.index = object.index;
    } else {
      message.index = "";
    }
    if (object.name !== undefined && object.name !== null) {
      message.name = object.name;
    } else {
      message.name = "";
    }
    if (object.description !== undefined && object.description !== null) {
      message.description = object.description;
    } else {
      message.description = "";
    }
    if (object.bids !== undefined && object.bids !== null) {
      message.bids = object.bids;
    } else {
      message.bids = "";
    }
    if (object.highestBid !== undefined && object.highestBid !== null) {
      message.highestBid = object.highestBid;
    } else {
      message.highestBid = "";
    }
    return message;
  },
};

type Builtin = Date | Function | Uint8Array | string | number | undefined;
export type DeepPartial<T> = T extends Builtin
  ? T
  : T extends Array<infer U>
  ? Array<DeepPartial<U>>
  : T extends ReadonlyArray<infer U>
  ? ReadonlyArray<DeepPartial<U>>
  : T extends {}
  ? { [K in keyof T]?: DeepPartial<T[K]> }
  : Partial<T>;
