import { Coin } from "../../../cosmos/base/v1beta1/coin";
import { Long } from "../../../helpers";
import * as _m0 from "protobufjs/minimal";
function createBaseParams() {
  return {
    auctionPeriod: Long.ZERO,
    minNextBidIncrementRate: ""
  };
}
export const Params = {
  encode(message, writer = _m0.Writer.create()) {
    if (!message.auctionPeriod.isZero()) {
      writer.uint32(8).int64(message.auctionPeriod);
    }
    if (message.minNextBidIncrementRate !== "") {
      writer.uint32(18).string(message.minNextBidIncrementRate);
    }
    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 = createBaseParams();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.auctionPeriod = reader.int64();
          break;
        case 2:
          message.minNextBidIncrementRate = reader.string();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$minNextBidInc;
    const message = createBaseParams();
    message.auctionPeriod = object.auctionPeriod !== undefined && object.auctionPeriod !== null ? Long.fromValue(object.auctionPeriod) : Long.ZERO;
    message.minNextBidIncrementRate = (_object$minNextBidInc = object.minNextBidIncrementRate) !== null && _object$minNextBidInc !== void 0 ? _object$minNextBidInc : "";
    return message;
  }
};
function createBaseBid() {
  return {
    bidder: "",
    amount: ""
  };
}
export const Bid = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.bidder !== "") {
      writer.uint32(10).string(message.bidder);
    }
    if (message.amount !== "") {
      writer.uint32(18).string(message.amount);
    }
    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 = createBaseBid();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.bidder = reader.string();
          break;
        case 2:
          message.amount = reader.string();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$bidder, _object$amount;
    const message = createBaseBid();
    message.bidder = (_object$bidder = object.bidder) !== null && _object$bidder !== void 0 ? _object$bidder : "";
    message.amount = (_object$amount = object.amount) !== null && _object$amount !== void 0 ? _object$amount : "";
    return message;
  }
};
function createBaseEventBid() {
  return {
    bidder: "",
    amount: "",
    round: Long.UZERO
  };
}
export const EventBid = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.bidder !== "") {
      writer.uint32(10).string(message.bidder);
    }
    if (message.amount !== "") {
      writer.uint32(18).string(message.amount);
    }
    if (!message.round.isZero()) {
      writer.uint32(24).uint64(message.round);
    }
    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 = createBaseEventBid();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.bidder = reader.string();
          break;
        case 2:
          message.amount = reader.string();
          break;
        case 3:
          message.round = reader.uint64();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$bidder2, _object$amount2;
    const message = createBaseEventBid();
    message.bidder = (_object$bidder2 = object.bidder) !== null && _object$bidder2 !== void 0 ? _object$bidder2 : "";
    message.amount = (_object$amount2 = object.amount) !== null && _object$amount2 !== void 0 ? _object$amount2 : "";
    message.round = object.round !== undefined && object.round !== null ? Long.fromValue(object.round) : Long.UZERO;
    return message;
  }
};
function createBaseEventAuctionResult() {
  return {
    winner: "",
    amount: "",
    round: Long.UZERO
  };
}
export const EventAuctionResult = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.winner !== "") {
      writer.uint32(10).string(message.winner);
    }
    if (message.amount !== "") {
      writer.uint32(18).string(message.amount);
    }
    if (!message.round.isZero()) {
      writer.uint32(24).uint64(message.round);
    }
    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 = createBaseEventAuctionResult();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.winner = reader.string();
          break;
        case 2:
          message.amount = reader.string();
          break;
        case 3:
          message.round = reader.uint64();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$winner, _object$amount3;
    const message = createBaseEventAuctionResult();
    message.winner = (_object$winner = object.winner) !== null && _object$winner !== void 0 ? _object$winner : "";
    message.amount = (_object$amount3 = object.amount) !== null && _object$amount3 !== void 0 ? _object$amount3 : "";
    message.round = object.round !== undefined && object.round !== null ? Long.fromValue(object.round) : Long.UZERO;
    return message;
  }
};
function createBaseEventAuctionStart() {
  return {
    round: Long.UZERO,
    endingTimestamp: Long.ZERO,
    newBasket: []
  };
}
export const EventAuctionStart = {
  encode(message, writer = _m0.Writer.create()) {
    if (!message.round.isZero()) {
      writer.uint32(8).uint64(message.round);
    }
    if (!message.endingTimestamp.isZero()) {
      writer.uint32(16).int64(message.endingTimestamp);
    }
    for (const v of message.newBasket) {
      Coin.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 = createBaseEventAuctionStart();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.round = reader.uint64();
          break;
        case 2:
          message.endingTimestamp = reader.int64();
          break;
        case 3:
          message.newBasket.push(Coin.decode(reader, reader.uint32()));
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$newBasket;
    const message = createBaseEventAuctionStart();
    message.round = object.round !== undefined && object.round !== null ? Long.fromValue(object.round) : Long.UZERO;
    message.endingTimestamp = object.endingTimestamp !== undefined && object.endingTimestamp !== null ? Long.fromValue(object.endingTimestamp) : Long.ZERO;
    message.newBasket = ((_object$newBasket = object.newBasket) === null || _object$newBasket === void 0 ? void 0 : _object$newBasket.map(e => Coin.fromPartial(e))) || [];
    return message;
  }
};