// DO NOT EDIT.
// swift-format-ignore-file
//
// Generated by the Swift generator plugin for the protocol buffer compiler.
// Source: injective/peggy/v1/batch.proto
//
// For information on using the generated types, please see the documentation:
//   https://github.com/apple/swift-protobuf/

import Foundation
import SwiftProtobuf

// If the compiler emits an error on this type, it is because this file
// was generated by a version of the `protoc` Swift plug-in that is
// incompatible with the version of SwiftProtobuf to which you are linking.
// Please ensure that you are building against the same version of the API
// that was used to generate this file.
fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck {
  struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {}
  typealias Version = _2
}

/// OutgoingTxBatch represents a batch of transactions going from Peggy to ETH
struct Injective_Peggy_V1_OutgoingTxBatch {
  // SwiftProtobuf.Message conformance is added in an extension below. See the
  // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  // methods supported on all messages.

  var batchNonce: UInt64 = 0

  var batchTimeout: UInt64 = 0

  var transactions: [Injective_Peggy_V1_OutgoingTransferTx] = []

  var tokenContract: String = String()

  var block: UInt64 = 0

  var unknownFields = SwiftProtobuf.UnknownStorage()

  init() {}
}

/// OutgoingTransferTx represents an individual send from Peggy to ETH
struct Injective_Peggy_V1_OutgoingTransferTx {
  // SwiftProtobuf.Message conformance is added in an extension below. See the
  // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  // methods supported on all messages.

  var id: UInt64 = 0

  var sender: String = String()

  var destAddress: String = String()

  var erc20Token: Injective_Peggy_V1_ERC20Token {
    get {return _erc20Token ?? Injective_Peggy_V1_ERC20Token()}
    set {_erc20Token = newValue}
  }
  /// Returns true if `erc20Token` has been explicitly set.
  var hasErc20Token: Bool {return self._erc20Token != nil}
  /// Clears the value of `erc20Token`. Subsequent reads from it will return its default value.
  mutating func clearErc20Token() {self._erc20Token = nil}

  var erc20Fee: Injective_Peggy_V1_ERC20Token {
    get {return _erc20Fee ?? Injective_Peggy_V1_ERC20Token()}
    set {_erc20Fee = newValue}
  }
  /// Returns true if `erc20Fee` has been explicitly set.
  var hasErc20Fee: Bool {return self._erc20Fee != nil}
  /// Clears the value of `erc20Fee`. Subsequent reads from it will return its default value.
  mutating func clearErc20Fee() {self._erc20Fee = nil}

  var unknownFields = SwiftProtobuf.UnknownStorage()

  init() {}

  fileprivate var _erc20Token: Injective_Peggy_V1_ERC20Token? = nil
  fileprivate var _erc20Fee: Injective_Peggy_V1_ERC20Token? = nil
}

// MARK: - Code below here is support for the SwiftProtobuf runtime.

fileprivate let _protobuf_package = "injective.peggy.v1"

extension Injective_Peggy_V1_OutgoingTxBatch: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  static let protoMessageName: String = _protobuf_package + ".OutgoingTxBatch"
  static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
    1: .standard(proto: "batch_nonce"),
    2: .standard(proto: "batch_timeout"),
    3: .same(proto: "transactions"),
    4: .standard(proto: "token_contract"),
    5: .same(proto: "block"),
  ]

  mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
    while let fieldNumber = try decoder.nextFieldNumber() {
      // The use of inline closures is to circumvent an issue where the compiler
      // allocates stack space for every case branch when no optimizations are
      // enabled. https://github.com/apple/swift-protobuf/issues/1034
      switch fieldNumber {
      case 1: try { try decoder.decodeSingularUInt64Field(value: &self.batchNonce) }()
      case 2: try { try decoder.decodeSingularUInt64Field(value: &self.batchTimeout) }()
      case 3: try { try decoder.decodeRepeatedMessageField(value: &self.transactions) }()
      case 4: try { try decoder.decodeSingularStringField(value: &self.tokenContract) }()
      case 5: try { try decoder.decodeSingularUInt64Field(value: &self.block) }()
      default: break
      }
    }
  }

  func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
    if self.batchNonce != 0 {
      try visitor.visitSingularUInt64Field(value: self.batchNonce, fieldNumber: 1)
    }
    if self.batchTimeout != 0 {
      try visitor.visitSingularUInt64Field(value: self.batchTimeout, fieldNumber: 2)
    }
    if !self.transactions.isEmpty {
      try visitor.visitRepeatedMessageField(value: self.transactions, fieldNumber: 3)
    }
    if !self.tokenContract.isEmpty {
      try visitor.visitSingularStringField(value: self.tokenContract, fieldNumber: 4)
    }
    if self.block != 0 {
      try visitor.visitSingularUInt64Field(value: self.block, fieldNumber: 5)
    }
    try unknownFields.traverse(visitor: &visitor)
  }

  static func ==(lhs: Injective_Peggy_V1_OutgoingTxBatch, rhs: Injective_Peggy_V1_OutgoingTxBatch) -> Bool {
    if lhs.batchNonce != rhs.batchNonce {return false}
    if lhs.batchTimeout != rhs.batchTimeout {return false}
    if lhs.transactions != rhs.transactions {return false}
    if lhs.tokenContract != rhs.tokenContract {return false}
    if lhs.block != rhs.block {return false}
    if lhs.unknownFields != rhs.unknownFields {return false}
    return true
  }
}

extension Injective_Peggy_V1_OutgoingTransferTx: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  static let protoMessageName: String = _protobuf_package + ".OutgoingTransferTx"
  static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
    1: .same(proto: "id"),
    2: .same(proto: "sender"),
    3: .standard(proto: "dest_address"),
    4: .standard(proto: "erc20_token"),
    5: .standard(proto: "erc20_fee"),
  ]

  mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
    while let fieldNumber = try decoder.nextFieldNumber() {
      // The use of inline closures is to circumvent an issue where the compiler
      // allocates stack space for every case branch when no optimizations are
      // enabled. https://github.com/apple/swift-protobuf/issues/1034
      switch fieldNumber {
      case 1: try { try decoder.decodeSingularUInt64Field(value: &self.id) }()
      case 2: try { try decoder.decodeSingularStringField(value: &self.sender) }()
      case 3: try { try decoder.decodeSingularStringField(value: &self.destAddress) }()
      case 4: try { try decoder.decodeSingularMessageField(value: &self._erc20Token) }()
      case 5: try { try decoder.decodeSingularMessageField(value: &self._erc20Fee) }()
      default: break
      }
    }
  }

  func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
    if self.id != 0 {
      try visitor.visitSingularUInt64Field(value: self.id, fieldNumber: 1)
    }
    if !self.sender.isEmpty {
      try visitor.visitSingularStringField(value: self.sender, fieldNumber: 2)
    }
    if !self.destAddress.isEmpty {
      try visitor.visitSingularStringField(value: self.destAddress, fieldNumber: 3)
    }
    if let v = self._erc20Token {
      try visitor.visitSingularMessageField(value: v, fieldNumber: 4)
    }
    if let v = self._erc20Fee {
      try visitor.visitSingularMessageField(value: v, fieldNumber: 5)
    }
    try unknownFields.traverse(visitor: &visitor)
  }

  static func ==(lhs: Injective_Peggy_V1_OutgoingTransferTx, rhs: Injective_Peggy_V1_OutgoingTransferTx) -> Bool {
    if lhs.id != rhs.id {return false}
    if lhs.sender != rhs.sender {return false}
    if lhs.destAddress != rhs.destAddress {return false}
    if lhs._erc20Token != rhs._erc20Token {return false}
    if lhs._erc20Fee != rhs._erc20Fee {return false}
    if lhs.unknownFields != rhs.unknownFields {return false}
    return true
  }
}
