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

export const protobufPackage = "cosmostest.cosmostest";

export interface MsgNewAuction {
  creator: string;
  owner: string;
  name: string;
  description: string;
}

export interface MsgNewAuctionResponse {
  auctionId: string;
}

export interface MsgNewBid {
  creator: string;
  auctionIndex: string;
  amount: string;
}

export interface MsgNewBidResponse {}

const baseMsgNewAuction: object = {
  creator: "",
  owner: "",
  name: "",
  description: "",
};

export const MsgNewAuction = {
  encode(message: MsgNewAuction, writer: Writer = Writer.create()): Writer {
    if (message.creator !== "") {
      writer.uint32(10).string(message.creator);
    }
    if (message.owner !== "") {
      writer.uint32(18).string(message.owner);
    }
    if (message.name !== "") {
      writer.uint32(26).string(message.name);
    }
    if (message.description !== "") {
      writer.uint32(34).string(message.description);
    }
    return writer;
  },

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

  fromJSON(object: any): MsgNewAuction {
    const message = { ...baseMsgNewAuction } as MsgNewAuction;
    if (object.creator !== undefined && object.creator !== null) {
      message.creator = String(object.creator);
    } else {
      message.creator = "";
    }
    if (object.owner !== undefined && object.owner !== null) {
      message.owner = String(object.owner);
    } else {
      message.owner = "";
    }
    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 = "";
    }
    return message;
  },

  toJSON(message: MsgNewAuction): unknown {
    const obj: any = {};
    message.creator !== undefined && (obj.creator = message.creator);
    message.owner !== undefined && (obj.owner = message.owner);
    message.name !== undefined && (obj.name = message.name);
    message.description !== undefined &&
      (obj.description = message.description);
    return obj;
  },

  fromPartial(object: DeepPartial<MsgNewAuction>): MsgNewAuction {
    const message = { ...baseMsgNewAuction } as MsgNewAuction;
    if (object.creator !== undefined && object.creator !== null) {
      message.creator = object.creator;
    } else {
      message.creator = "";
    }
    if (object.owner !== undefined && object.owner !== null) {
      message.owner = object.owner;
    } else {
      message.owner = "";
    }
    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 = "";
    }
    return message;
  },
};

const baseMsgNewAuctionResponse: object = { auctionId: "" };

export const MsgNewAuctionResponse = {
  encode(
    message: MsgNewAuctionResponse,
    writer: Writer = Writer.create()
  ): Writer {
    if (message.auctionId !== "") {
      writer.uint32(10).string(message.auctionId);
    }
    return writer;
  },

  decode(input: Reader | Uint8Array, length?: number): MsgNewAuctionResponse {
    const reader = input instanceof Uint8Array ? new Reader(input) : input;
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = { ...baseMsgNewAuctionResponse } as MsgNewAuctionResponse;
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.auctionId = reader.string();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },

  fromJSON(object: any): MsgNewAuctionResponse {
    const message = { ...baseMsgNewAuctionResponse } as MsgNewAuctionResponse;
    if (object.auctionId !== undefined && object.auctionId !== null) {
      message.auctionId = String(object.auctionId);
    } else {
      message.auctionId = "";
    }
    return message;
  },

  toJSON(message: MsgNewAuctionResponse): unknown {
    const obj: any = {};
    message.auctionId !== undefined && (obj.auctionId = message.auctionId);
    return obj;
  },

  fromPartial(
    object: DeepPartial<MsgNewAuctionResponse>
  ): MsgNewAuctionResponse {
    const message = { ...baseMsgNewAuctionResponse } as MsgNewAuctionResponse;
    if (object.auctionId !== undefined && object.auctionId !== null) {
      message.auctionId = object.auctionId;
    } else {
      message.auctionId = "";
    }
    return message;
  },
};

const baseMsgNewBid: object = { creator: "", auctionIndex: "", amount: "" };

export const MsgNewBid = {
  encode(message: MsgNewBid, writer: Writer = Writer.create()): Writer {
    if (message.creator !== "") {
      writer.uint32(10).string(message.creator);
    }
    if (message.auctionIndex !== "") {
      writer.uint32(18).string(message.auctionIndex);
    }
    if (message.amount !== "") {
      writer.uint32(26).string(message.amount);
    }
    return writer;
  },

  decode(input: Reader | Uint8Array, length?: number): MsgNewBid {
    const reader = input instanceof Uint8Array ? new Reader(input) : input;
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = { ...baseMsgNewBid } as MsgNewBid;
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.creator = reader.string();
          break;
        case 2:
          message.auctionIndex = reader.string();
          break;
        case 3:
          message.amount = reader.string();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },

  fromJSON(object: any): MsgNewBid {
    const message = { ...baseMsgNewBid } as MsgNewBid;
    if (object.creator !== undefined && object.creator !== null) {
      message.creator = String(object.creator);
    } else {
      message.creator = "";
    }
    if (object.auctionIndex !== undefined && object.auctionIndex !== null) {
      message.auctionIndex = String(object.auctionIndex);
    } else {
      message.auctionIndex = "";
    }
    if (object.amount !== undefined && object.amount !== null) {
      message.amount = String(object.amount);
    } else {
      message.amount = "";
    }
    return message;
  },

  toJSON(message: MsgNewBid): unknown {
    const obj: any = {};
    message.creator !== undefined && (obj.creator = message.creator);
    message.auctionIndex !== undefined &&
      (obj.auctionIndex = message.auctionIndex);
    message.amount !== undefined && (obj.amount = message.amount);
    return obj;
  },

  fromPartial(object: DeepPartial<MsgNewBid>): MsgNewBid {
    const message = { ...baseMsgNewBid } as MsgNewBid;
    if (object.creator !== undefined && object.creator !== null) {
      message.creator = object.creator;
    } else {
      message.creator = "";
    }
    if (object.auctionIndex !== undefined && object.auctionIndex !== null) {
      message.auctionIndex = object.auctionIndex;
    } else {
      message.auctionIndex = "";
    }
    if (object.amount !== undefined && object.amount !== null) {
      message.amount = object.amount;
    } else {
      message.amount = "";
    }
    return message;
  },
};

const baseMsgNewBidResponse: object = {};

export const MsgNewBidResponse = {
  encode(_: MsgNewBidResponse, writer: Writer = Writer.create()): Writer {
    return writer;
  },

  decode(input: Reader | Uint8Array, length?: number): MsgNewBidResponse {
    const reader = input instanceof Uint8Array ? new Reader(input) : input;
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = { ...baseMsgNewBidResponse } as MsgNewBidResponse;
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },

  fromJSON(_: any): MsgNewBidResponse {
    const message = { ...baseMsgNewBidResponse } as MsgNewBidResponse;
    return message;
  },

  toJSON(_: MsgNewBidResponse): unknown {
    const obj: any = {};
    return obj;
  },

  fromPartial(_: DeepPartial<MsgNewBidResponse>): MsgNewBidResponse {
    const message = { ...baseMsgNewBidResponse } as MsgNewBidResponse;
    return message;
  },
};

/** Msg defines the Msg service. */
export interface Msg {
  NewAuction(request: MsgNewAuction): Promise<MsgNewAuctionResponse>;
  /** this line is used by starport scaffolding # proto/tx/rpc */
  NewBid(request: MsgNewBid): Promise<MsgNewBidResponse>;
}

export class MsgClientImpl implements Msg {
  private readonly rpc: Rpc;
  constructor(rpc: Rpc) {
    this.rpc = rpc;
  }
  NewAuction(request: MsgNewAuction): Promise<MsgNewAuctionResponse> {
    const data = MsgNewAuction.encode(request).finish();
    const promise = this.rpc.request(
      "cosmostest.cosmostest.Msg",
      "NewAuction",
      data
    );
    return promise.then((data) =>
      MsgNewAuctionResponse.decode(new Reader(data))
    );
  }

  NewBid(request: MsgNewBid): Promise<MsgNewBidResponse> {
    const data = MsgNewBid.encode(request).finish();
    const promise = this.rpc.request(
      "cosmostest.cosmostest.Msg",
      "NewBid",
      data
    );
    return promise.then((data) => MsgNewBidResponse.decode(new Reader(data)));
  }
}

interface Rpc {
  request(
    service: string,
    method: string,
    data: Uint8Array
  ): Promise<Uint8Array>;
}

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>;
