/* 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;
}

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

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

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

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