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 { MintAmount } from "./rate_limit_pb.js";
import { RateLimitTransfers } from "./rate_limit_pb.js";
import { RateLimit } from "./rate_limit_pb.js";
import { OutgoingTransferTx } from "./batch_pb.js";
import { ERC20ToDenom } from "./types_pb.js";
import { MsgSetOrchestratorAddresses } from "./msgs_pb.js";
import { Attestation } from "./attestation_pb.js";
import { MsgConfirmBatch } from "./msgs_pb.js";
import { OutgoingTxBatch } from "./batch_pb.js";
import { MsgValsetConfirm } from "./msgs_pb.js";
import { Valset } from "./types_pb.js";
import { Params } from "./params_pb.js";
class GenesisState$Type extends MessageType {
  constructor() {
    super("injective.peggy.v1.GenesisState", [
      { no: 1, name: "params", kind: "message", T: () => Params },
      {
        no: 2,
        name: "last_observed_nonce",
        kind: "scalar",
        T: 4,
        L: 0
        /*LongType.BIGINT*/
      },
      { no: 3, name: "valsets", kind: "message", repeat: 2, T: () => Valset },
      { no: 4, name: "valset_confirms", kind: "message", repeat: 2, T: () => MsgValsetConfirm },
      { no: 5, name: "batches", kind: "message", repeat: 2, T: () => OutgoingTxBatch },
      { no: 6, name: "batch_confirms", kind: "message", repeat: 2, T: () => MsgConfirmBatch },
      { no: 7, name: "attestations", kind: "message", repeat: 2, T: () => Attestation },
      { no: 8, name: "orchestrator_addresses", kind: "message", repeat: 2, T: () => MsgSetOrchestratorAddresses },
      { no: 9, name: "erc20_to_denoms", kind: "message", repeat: 2, T: () => ERC20ToDenom },
      { no: 10, name: "unbatched_transfers", kind: "message", repeat: 2, T: () => OutgoingTransferTx },
      {
        no: 11,
        name: "last_observed_ethereum_height",
        kind: "scalar",
        T: 4,
        L: 0
        /*LongType.BIGINT*/
      },
      {
        no: 12,
        name: "last_outgoing_batch_id",
        kind: "scalar",
        T: 4,
        L: 0
        /*LongType.BIGINT*/
      },
      {
        no: 13,
        name: "last_outgoing_pool_id",
        kind: "scalar",
        T: 4,
        L: 0
        /*LongType.BIGINT*/
      },
      { no: 14, name: "last_observed_valset", kind: "message", T: () => Valset, options: { "gogoproto.nullable": false } },
      {
        no: 15,
        name: "ethereum_blacklist",
        kind: "scalar",
        repeat: 2,
        T: 9
        /*ScalarType.STRING*/
      },
      { no: 16, name: "rate_limits", kind: "message", repeat: 2, T: () => RateLimit },
      { no: 17, name: "rate_limit_transfers", kind: "message", repeat: 2, T: () => RateLimitTransfers },
      { no: 18, name: "mint_amounts", kind: "message", repeat: 2, T: () => MintAmount }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.lastObservedNonce = 0n;
    message.valsets = [];
    message.valsetConfirms = [];
    message.batches = [];
    message.batchConfirms = [];
    message.attestations = [];
    message.orchestratorAddresses = [];
    message.erc20ToDenoms = [];
    message.unbatchedTransfers = [];
    message.lastObservedEthereumHeight = 0n;
    message.lastOutgoingBatchId = 0n;
    message.lastOutgoingPoolId = 0n;
    message.ethereumBlacklist = [];
    message.rateLimits = [];
    message.rateLimitTransfers = [];
    message.mintAmounts = [];
    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.peggy.v1.Params params */
        1:
          message.params = Params.internalBinaryRead(reader, reader.uint32(), options, message.params);
          break;
        case /* uint64 last_observed_nonce */
        2:
          message.lastObservedNonce = reader.uint64().toBigInt();
          break;
        case /* repeated injective.peggy.v1.Valset valsets */
        3:
          message.valsets.push(Valset.internalBinaryRead(reader, reader.uint32(), options));
          break;
        case /* repeated injective.peggy.v1.MsgValsetConfirm valset_confirms */
        4:
          message.valsetConfirms.push(MsgValsetConfirm.internalBinaryRead(reader, reader.uint32(), options));
          break;
        case /* repeated injective.peggy.v1.OutgoingTxBatch batches */
        5:
          message.batches.push(OutgoingTxBatch.internalBinaryRead(reader, reader.uint32(), options));
          break;
        case /* repeated injective.peggy.v1.MsgConfirmBatch batch_confirms */
        6:
          message.batchConfirms.push(MsgConfirmBatch.internalBinaryRead(reader, reader.uint32(), options));
          break;
        case /* repeated injective.peggy.v1.Attestation attestations */
        7:
          message.attestations.push(Attestation.internalBinaryRead(reader, reader.uint32(), options));
          break;
        case /* repeated injective.peggy.v1.MsgSetOrchestratorAddresses orchestrator_addresses */
        8:
          message.orchestratorAddresses.push(MsgSetOrchestratorAddresses.internalBinaryRead(reader, reader.uint32(), options));
          break;
        case /* repeated injective.peggy.v1.ERC20ToDenom erc20_to_denoms */
        9:
          message.erc20ToDenoms.push(ERC20ToDenom.internalBinaryRead(reader, reader.uint32(), options));
          break;
        case /* repeated injective.peggy.v1.OutgoingTransferTx unbatched_transfers */
        10:
          message.unbatchedTransfers.push(OutgoingTransferTx.internalBinaryRead(reader, reader.uint32(), options));
          break;
        case /* uint64 last_observed_ethereum_height */
        11:
          message.lastObservedEthereumHeight = reader.uint64().toBigInt();
          break;
        case /* uint64 last_outgoing_batch_id */
        12:
          message.lastOutgoingBatchId = reader.uint64().toBigInt();
          break;
        case /* uint64 last_outgoing_pool_id */
        13:
          message.lastOutgoingPoolId = reader.uint64().toBigInt();
          break;
        case /* injective.peggy.v1.Valset last_observed_valset */
        14:
          message.lastObservedValset = Valset.internalBinaryRead(reader, reader.uint32(), options, message.lastObservedValset);
          break;
        case /* repeated string ethereum_blacklist */
        15:
          message.ethereumBlacklist.push(reader.string());
          break;
        case /* repeated injective.peggy.v1.RateLimit rate_limits */
        16:
          message.rateLimits.push(RateLimit.internalBinaryRead(reader, reader.uint32(), options));
          break;
        case /* repeated injective.peggy.v1.RateLimitTransfers rate_limit_transfers */
        17:
          message.rateLimitTransfers.push(RateLimitTransfers.internalBinaryRead(reader, reader.uint32(), options));
          break;
        case /* repeated injective.peggy.v1.MintAmount mint_amounts */
        18:
          message.mintAmounts.push(MintAmount.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();
    if (message.lastObservedNonce !== 0n)
      writer.tag(2, WireType.Varint).uint64(message.lastObservedNonce);
    for (let i = 0; i < message.valsets.length; i++)
      Valset.internalBinaryWrite(message.valsets[i], writer.tag(3, WireType.LengthDelimited).fork(), options).join();
    for (let i = 0; i < message.valsetConfirms.length; i++)
      MsgValsetConfirm.internalBinaryWrite(message.valsetConfirms[i], writer.tag(4, WireType.LengthDelimited).fork(), options).join();
    for (let i = 0; i < message.batches.length; i++)
      OutgoingTxBatch.internalBinaryWrite(message.batches[i], writer.tag(5, WireType.LengthDelimited).fork(), options).join();
    for (let i = 0; i < message.batchConfirms.length; i++)
      MsgConfirmBatch.internalBinaryWrite(message.batchConfirms[i], writer.tag(6, WireType.LengthDelimited).fork(), options).join();
    for (let i = 0; i < message.attestations.length; i++)
      Attestation.internalBinaryWrite(message.attestations[i], writer.tag(7, WireType.LengthDelimited).fork(), options).join();
    for (let i = 0; i < message.orchestratorAddresses.length; i++)
      MsgSetOrchestratorAddresses.internalBinaryWrite(message.orchestratorAddresses[i], writer.tag(8, WireType.LengthDelimited).fork(), options).join();
    for (let i = 0; i < message.erc20ToDenoms.length; i++)
      ERC20ToDenom.internalBinaryWrite(message.erc20ToDenoms[i], writer.tag(9, WireType.LengthDelimited).fork(), options).join();
    for (let i = 0; i < message.unbatchedTransfers.length; i++)
      OutgoingTransferTx.internalBinaryWrite(message.unbatchedTransfers[i], writer.tag(10, WireType.LengthDelimited).fork(), options).join();
    if (message.lastObservedEthereumHeight !== 0n)
      writer.tag(11, WireType.Varint).uint64(message.lastObservedEthereumHeight);
    if (message.lastOutgoingBatchId !== 0n)
      writer.tag(12, WireType.Varint).uint64(message.lastOutgoingBatchId);
    if (message.lastOutgoingPoolId !== 0n)
      writer.tag(13, WireType.Varint).uint64(message.lastOutgoingPoolId);
    if (message.lastObservedValset)
      Valset.internalBinaryWrite(message.lastObservedValset, writer.tag(14, WireType.LengthDelimited).fork(), options).join();
    for (let i = 0; i < message.ethereumBlacklist.length; i++)
      writer.tag(15, WireType.LengthDelimited).string(message.ethereumBlacklist[i]);
    for (let i = 0; i < message.rateLimits.length; i++)
      RateLimit.internalBinaryWrite(message.rateLimits[i], writer.tag(16, WireType.LengthDelimited).fork(), options).join();
    for (let i = 0; i < message.rateLimitTransfers.length; i++)
      RateLimitTransfers.internalBinaryWrite(message.rateLimitTransfers[i], writer.tag(17, WireType.LengthDelimited).fork(), options).join();
    for (let i = 0; i < message.mintAmounts.length; i++)
      MintAmount.internalBinaryWrite(message.mintAmounts[i], writer.tag(18, 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();
export {
  GenesisState
};
