import { WireType } from "@protobuf-ts/runtime";
import { UnknownFieldHandler } from "@protobuf-ts/runtime";
import { reflectionMergePartial } from "@protobuf-ts/runtime";
import { MessageType } from "@protobuf-ts/runtime";
import { SedaFastPriceState } from "./oracle_pb.js";
import { PythProPriceState } from "./oracle_pb.js";
import { ChainlinkDataStreamsPriceState } from "./oracle_pb.js";
import { StorkPriceState } from "./oracle_pb.js";
import { PythPriceState } from "./oracle_pb.js";
import { ProviderState } from "./oracle_pb.js";
import { PriceRecords } from "./oracle_pb.js";
import { ChainlinkPriceState } from "./oracle_pb.js";
import { BandIBCParams } from "./oracle_pb.js";
import { BandOracleRequest } from "./oracle_pb.js";
import { CoinbasePriceState } from "./oracle_pb.js";
import { PriceFeedState } from "./oracle_pb.js";
import { BandPriceState } from "./oracle_pb.js";
import { Params } from "./oracle_pb.js";
class GenesisState$Type extends MessageType {
  constructor() {
    super("injective.oracle.v1beta1.GenesisState", [
      { no: 1, name: "params", kind: "message", T: () => Params, options: { "gogoproto.nullable": false } },
      {
        no: 2,
        name: "band_relayers",
        kind: "scalar",
        repeat: 2,
        T: 9
        /*ScalarType.STRING*/
      },
      { no: 3, name: "band_price_states", kind: "message", repeat: 2, T: () => BandPriceState },
      { no: 4, name: "price_feed_price_states", kind: "message", repeat: 2, T: () => PriceFeedState },
      { no: 5, name: "coinbase_price_states", kind: "message", repeat: 2, T: () => CoinbasePriceState },
      { no: 6, name: "band_ibc_price_states", kind: "message", repeat: 2, T: () => BandPriceState },
      { no: 7, name: "band_ibc_oracle_requests", kind: "message", repeat: 2, T: () => BandOracleRequest },
      { no: 8, name: "band_ibc_params", kind: "message", T: () => BandIBCParams, options: { "gogoproto.nullable": false } },
      {
        no: 9,
        name: "band_ibc_latest_client_id",
        kind: "scalar",
        T: 4,
        L: 0
        /*LongType.BIGINT*/
      },
      { no: 10, name: "calldata_records", kind: "message", repeat: 2, T: () => CalldataRecord },
      {
        no: 11,
        name: "band_ibc_latest_request_id",
        kind: "scalar",
        T: 4,
        L: 0
        /*LongType.BIGINT*/
      },
      { no: 12, name: "chainlink_price_states", kind: "message", repeat: 2, T: () => ChainlinkPriceState },
      { no: 13, name: "historical_price_records", kind: "message", repeat: 2, T: () => PriceRecords },
      { no: 14, name: "provider_states", kind: "message", repeat: 2, T: () => ProviderState },
      { no: 15, name: "pyth_price_states", kind: "message", repeat: 2, T: () => PythPriceState },
      { no: 16, name: "stork_price_states", kind: "message", repeat: 2, T: () => StorkPriceState },
      {
        no: 17,
        name: "stork_publishers",
        kind: "scalar",
        repeat: 2,
        T: 9
        /*ScalarType.STRING*/
      },
      { no: 18, name: "chainlink_data_streams_price_states", kind: "message", repeat: 2, T: () => ChainlinkDataStreamsPriceState },
      { no: 19, name: "pyth_pro_price_states", kind: "message", repeat: 2, T: () => PythProPriceState },
      { no: 20, name: "seda_fast_price_states", kind: "message", repeat: 2, T: () => SedaFastPriceState }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.bandRelayers = [];
    message.bandPriceStates = [];
    message.priceFeedPriceStates = [];
    message.coinbasePriceStates = [];
    message.bandIbcPriceStates = [];
    message.bandIbcOracleRequests = [];
    message.bandIbcLatestClientId = 0n;
    message.calldataRecords = [];
    message.bandIbcLatestRequestId = 0n;
    message.chainlinkPriceStates = [];
    message.historicalPriceRecords = [];
    message.providerStates = [];
    message.pythPriceStates = [];
    message.storkPriceStates = [];
    message.storkPublishers = [];
    message.chainlinkDataStreamsPriceStates = [];
    message.pythProPriceStates = [];
    message.sedaFastPriceStates = [];
    if (value !== void 0)
      reflectionMergePartial(this, message, value);
    return message;
  }
  internalBinaryRead(reader, length, options, target) {
    let message = target ?? this.create(), end = reader.pos + length;
    while (reader.pos < end) {
      let [fieldNo, wireType] = reader.tag();
      switch (fieldNo) {
        case /* injective.oracle.v1beta1.Params params */
        1:
          message.params = Params.internalBinaryRead(reader, reader.uint32(), options, message.params);
          break;
        case /* repeated string band_relayers = 2 [deprecated = true] */
        2:
          message.bandRelayers.push(reader.string());
          break;
        case /* repeated injective.oracle.v1beta1.BandPriceState band_price_states = 3 [deprecated = true] */
        3:
          message.bandPriceStates.push(BandPriceState.internalBinaryRead(reader, reader.uint32(), options));
          break;
        case /* repeated injective.oracle.v1beta1.PriceFeedState price_feed_price_states */
        4:
          message.priceFeedPriceStates.push(PriceFeedState.internalBinaryRead(reader, reader.uint32(), options));
          break;
        case /* repeated injective.oracle.v1beta1.CoinbasePriceState coinbase_price_states */
        5:
          message.coinbasePriceStates.push(CoinbasePriceState.internalBinaryRead(reader, reader.uint32(), options));
          break;
        case /* repeated injective.oracle.v1beta1.BandPriceState band_ibc_price_states = 6 [deprecated = true] */
        6:
          message.bandIbcPriceStates.push(BandPriceState.internalBinaryRead(reader, reader.uint32(), options));
          break;
        case /* repeated injective.oracle.v1beta1.BandOracleRequest band_ibc_oracle_requests = 7 [deprecated = true] */
        7:
          message.bandIbcOracleRequests.push(BandOracleRequest.internalBinaryRead(reader, reader.uint32(), options));
          break;
        case /* injective.oracle.v1beta1.BandIBCParams band_ibc_params = 8 [deprecated = true] */
        8:
          message.bandIbcParams = BandIBCParams.internalBinaryRead(reader, reader.uint32(), options, message.bandIbcParams);
          break;
        case /* uint64 band_ibc_latest_client_id = 9 [deprecated = true] */
        9:
          message.bandIbcLatestClientId = reader.uint64().toBigInt();
          break;
        case /* repeated injective.oracle.v1beta1.CalldataRecord calldata_records = 10 [deprecated = true] */
        10:
          message.calldataRecords.push(CalldataRecord.internalBinaryRead(reader, reader.uint32(), options));
          break;
        case /* uint64 band_ibc_latest_request_id = 11 [deprecated = true] */
        11:
          message.bandIbcLatestRequestId = reader.uint64().toBigInt();
          break;
        case /* repeated injective.oracle.v1beta1.ChainlinkPriceState chainlink_price_states = 12 [deprecated = true] */
        12:
          message.chainlinkPriceStates.push(ChainlinkPriceState.internalBinaryRead(reader, reader.uint32(), options));
          break;
        case /* repeated injective.oracle.v1beta1.PriceRecords historical_price_records */
        13:
          message.historicalPriceRecords.push(PriceRecords.internalBinaryRead(reader, reader.uint32(), options));
          break;
        case /* repeated injective.oracle.v1beta1.ProviderState provider_states */
        14:
          message.providerStates.push(ProviderState.internalBinaryRead(reader, reader.uint32(), options));
          break;
        case /* repeated injective.oracle.v1beta1.PythPriceState pyth_price_states */
        15:
          message.pythPriceStates.push(PythPriceState.internalBinaryRead(reader, reader.uint32(), options));
          break;
        case /* repeated injective.oracle.v1beta1.StorkPriceState stork_price_states */
        16:
          message.storkPriceStates.push(StorkPriceState.internalBinaryRead(reader, reader.uint32(), options));
          break;
        case /* repeated string stork_publishers */
        17:
          message.storkPublishers.push(reader.string());
          break;
        case /* repeated injective.oracle.v1beta1.ChainlinkDataStreamsPriceState chainlink_data_streams_price_states */
        18:
          message.chainlinkDataStreamsPriceStates.push(ChainlinkDataStreamsPriceState.internalBinaryRead(reader, reader.uint32(), options));
          break;
        case /* repeated injective.oracle.v1beta1.PythProPriceState pyth_pro_price_states */
        19:
          message.pythProPriceStates.push(PythProPriceState.internalBinaryRead(reader, reader.uint32(), options));
          break;
        case /* repeated injective.oracle.v1beta1.SedaFastPriceState seda_fast_price_states */
        20:
          message.sedaFastPriceStates.push(SedaFastPriceState.internalBinaryRead(reader, reader.uint32(), options));
          break;
        default:
          let u = options.readUnknownField;
          if (u === "throw")
            throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
          let d = reader.skip(wireType);
          if (u !== false)
            (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.params)
      Params.internalBinaryWrite(message.params, writer.tag(1, WireType.LengthDelimited).fork(), options).join();
    for (let i = 0; i < message.bandRelayers.length; i++)
      writer.tag(2, WireType.LengthDelimited).string(message.bandRelayers[i]);
    for (let i = 0; i < message.bandPriceStates.length; i++)
      BandPriceState.internalBinaryWrite(message.bandPriceStates[i], writer.tag(3, WireType.LengthDelimited).fork(), options).join();
    for (let i = 0; i < message.priceFeedPriceStates.length; i++)
      PriceFeedState.internalBinaryWrite(message.priceFeedPriceStates[i], writer.tag(4, WireType.LengthDelimited).fork(), options).join();
    for (let i = 0; i < message.coinbasePriceStates.length; i++)
      CoinbasePriceState.internalBinaryWrite(message.coinbasePriceStates[i], writer.tag(5, WireType.LengthDelimited).fork(), options).join();
    for (let i = 0; i < message.bandIbcPriceStates.length; i++)
      BandPriceState.internalBinaryWrite(message.bandIbcPriceStates[i], writer.tag(6, WireType.LengthDelimited).fork(), options).join();
    for (let i = 0; i < message.bandIbcOracleRequests.length; i++)
      BandOracleRequest.internalBinaryWrite(message.bandIbcOracleRequests[i], writer.tag(7, WireType.LengthDelimited).fork(), options).join();
    if (message.bandIbcParams)
      BandIBCParams.internalBinaryWrite(message.bandIbcParams, writer.tag(8, WireType.LengthDelimited).fork(), options).join();
    if (message.bandIbcLatestClientId !== 0n)
      writer.tag(9, WireType.Varint).uint64(message.bandIbcLatestClientId);
    for (let i = 0; i < message.calldataRecords.length; i++)
      CalldataRecord.internalBinaryWrite(message.calldataRecords[i], writer.tag(10, WireType.LengthDelimited).fork(), options).join();
    if (message.bandIbcLatestRequestId !== 0n)
      writer.tag(11, WireType.Varint).uint64(message.bandIbcLatestRequestId);
    for (let i = 0; i < message.chainlinkPriceStates.length; i++)
      ChainlinkPriceState.internalBinaryWrite(message.chainlinkPriceStates[i], writer.tag(12, WireType.LengthDelimited).fork(), options).join();
    for (let i = 0; i < message.historicalPriceRecords.length; i++)
      PriceRecords.internalBinaryWrite(message.historicalPriceRecords[i], writer.tag(13, WireType.LengthDelimited).fork(), options).join();
    for (let i = 0; i < message.providerStates.length; i++)
      ProviderState.internalBinaryWrite(message.providerStates[i], writer.tag(14, WireType.LengthDelimited).fork(), options).join();
    for (let i = 0; i < message.pythPriceStates.length; i++)
      PythPriceState.internalBinaryWrite(message.pythPriceStates[i], writer.tag(15, WireType.LengthDelimited).fork(), options).join();
    for (let i = 0; i < message.storkPriceStates.length; i++)
      StorkPriceState.internalBinaryWrite(message.storkPriceStates[i], writer.tag(16, WireType.LengthDelimited).fork(), options).join();
    for (let i = 0; i < message.storkPublishers.length; i++)
      writer.tag(17, WireType.LengthDelimited).string(message.storkPublishers[i]);
    for (let i = 0; i < message.chainlinkDataStreamsPriceStates.length; i++)
      ChainlinkDataStreamsPriceState.internalBinaryWrite(message.chainlinkDataStreamsPriceStates[i], writer.tag(18, WireType.LengthDelimited).fork(), options).join();
    for (let i = 0; i < message.pythProPriceStates.length; i++)
      PythProPriceState.internalBinaryWrite(message.pythProPriceStates[i], writer.tag(19, WireType.LengthDelimited).fork(), options).join();
    for (let i = 0; i < message.sedaFastPriceStates.length; i++)
      SedaFastPriceState.internalBinaryWrite(message.sedaFastPriceStates[i], writer.tag(20, WireType.LengthDelimited).fork(), options).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
    return writer;
  }
}
const GenesisState = new GenesisState$Type();
class CalldataRecord$Type extends MessageType {
  constructor() {
    super("injective.oracle.v1beta1.CalldataRecord", [
      {
        no: 1,
        name: "client_id",
        kind: "scalar",
        T: 4,
        L: 0
        /*LongType.BIGINT*/
      },
      {
        no: 2,
        name: "calldata",
        kind: "scalar",
        T: 12
        /*ScalarType.BYTES*/
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.clientId = 0n;
    message.calldata = new Uint8Array(0);
    if (value !== void 0)
      reflectionMergePartial(this, message, value);
    return message;
  }
  internalBinaryRead(reader, length, options, target) {
    let message = target ?? this.create(), end = reader.pos + length;
    while (reader.pos < end) {
      let [fieldNo, wireType] = reader.tag();
      switch (fieldNo) {
        case /* uint64 client_id */
        1:
          message.clientId = reader.uint64().toBigInt();
          break;
        case /* bytes calldata */
        2:
          message.calldata = reader.bytes();
          break;
        default:
          let u = options.readUnknownField;
          if (u === "throw")
            throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
          let d = reader.skip(wireType);
          if (u !== false)
            (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.clientId !== 0n)
      writer.tag(1, WireType.Varint).uint64(message.clientId);
    if (message.calldata.length)
      writer.tag(2, WireType.LengthDelimited).bytes(message.calldata);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
    return writer;
  }
}
const CalldataRecord = new CalldataRecord$Type();
export {
  CalldataRecord,
  GenesisState
};
