{- This file was auto-generated from types/transaction.proto by the proto-lens-protoc program. -}
{-# LANGUAGE ScopedTypeVariables, DataKinds, TypeFamilies,
  UndecidableInstances, GeneralizedNewtypeDeriving,
  MultiParamTypeClasses, FlexibleContexts, FlexibleInstances,
  PatternSynonyms, MagicHash, NoImplicitPrelude, DataKinds,
  BangPatterns, TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-unused-imports#-}
{-# OPTIONS_GHC -fno-warn-duplicate-exports#-}
module Proto.Types.Transaction (RawTransaction(), TypedMessage())
       where
import qualified Data.ProtoLens.Runtime.Control.DeepSeq
       as Control.DeepSeq
import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Prism
       as Data.ProtoLens.Prism
import qualified Data.ProtoLens.Runtime.Prelude as Prelude
import qualified Data.ProtoLens.Runtime.Data.Int as Data.Int
import qualified Data.ProtoLens.Runtime.Data.Monoid as Data.Monoid
import qualified Data.ProtoLens.Runtime.Data.Word as Data.Word
import qualified Data.ProtoLens.Runtime.Data.ProtoLens
       as Data.ProtoLens
import qualified
       Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Bytes
       as Data.ProtoLens.Encoding.Bytes
import qualified
       Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Growing
       as Data.ProtoLens.Encoding.Growing
import qualified
       Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Parser.Unsafe
       as Data.ProtoLens.Encoding.Parser.Unsafe
import qualified
       Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Wire
       as Data.ProtoLens.Encoding.Wire
import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Field
       as Data.ProtoLens.Field
import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Message.Enum
       as Data.ProtoLens.Message.Enum
import qualified
       Data.ProtoLens.Runtime.Data.ProtoLens.Service.Types
       as Data.ProtoLens.Service.Types
import qualified Data.ProtoLens.Runtime.Lens.Family2
       as Lens.Family2
import qualified Data.ProtoLens.Runtime.Lens.Family2.Unchecked
       as Lens.Family2.Unchecked
import qualified Data.ProtoLens.Runtime.Data.Text as Data.Text
import qualified Data.ProtoLens.Runtime.Data.Map as Data.Map
import qualified Data.ProtoLens.Runtime.Data.ByteString
       as Data.ByteString
import qualified Data.ProtoLens.Runtime.Data.ByteString.Char8
       as Data.ByteString.Char8
import qualified Data.ProtoLens.Runtime.Data.Text.Encoding
       as Data.Text.Encoding
import qualified Data.ProtoLens.Runtime.Data.Vector as Data.Vector
import qualified Data.ProtoLens.Runtime.Data.Vector.Generic
       as Data.Vector.Generic
import qualified Data.ProtoLens.Runtime.Data.Vector.Unboxed
       as Data.Vector.Unboxed
import qualified Data.ProtoLens.Runtime.Text.Read as Text.Read

{- | Fields :

    * 'Proto.Types.Transaction_Fields.data'' @:: Lens' RawTransaction TypedMessage@
    * 'Proto.Types.Transaction_Fields.maybe'data'' @:: Lens' RawTransaction (Prelude.Maybe TypedMessage)@
    * 'Proto.Types.Transaction_Fields.gas' @:: Lens' RawTransaction Data.Int.Int64@
    * 'Proto.Types.Transaction_Fields.signature' @:: Lens' RawTransaction Data.ByteString.ByteString@
    * 'Proto.Types.Transaction_Fields.route' @:: Lens' RawTransaction Data.Text.Text@
    * 'Proto.Types.Transaction_Fields.nonce' @:: Lens' RawTransaction Data.Word.Word64@
 -}
data RawTransaction = RawTransaction{_RawTransaction'data' ::
                                     !(Prelude.Maybe TypedMessage),
                                     _RawTransaction'gas :: !Data.Int.Int64,
                                     _RawTransaction'signature :: !Data.ByteString.ByteString,
                                     _RawTransaction'route :: !Data.Text.Text,
                                     _RawTransaction'nonce :: !Data.Word.Word64,
                                     _RawTransaction'_unknownFields :: !Data.ProtoLens.FieldSet}
                        deriving (Prelude.Eq, Prelude.Ord)
instance Prelude.Show RawTransaction where
        showsPrec _ __x __s
          = Prelude.showChar '{'
              (Prelude.showString (Data.ProtoLens.showMessageShort __x)
                 (Prelude.showChar '}' __s))
instance Data.ProtoLens.Field.HasField RawTransaction "data'"
           (TypedMessage)
         where
        fieldOf _
          = (Lens.Family2.Unchecked.lens _RawTransaction'data'
               (\ x__ y__ -> x__{_RawTransaction'data' = y__}))
              Prelude.. Data.ProtoLens.maybeLens Data.ProtoLens.defMessage
instance Data.ProtoLens.Field.HasField RawTransaction "maybe'data'"
           (Prelude.Maybe TypedMessage)
         where
        fieldOf _
          = (Lens.Family2.Unchecked.lens _RawTransaction'data'
               (\ x__ y__ -> x__{_RawTransaction'data' = y__}))
              Prelude.. Prelude.id
instance Data.ProtoLens.Field.HasField RawTransaction "gas"
           (Data.Int.Int64)
         where
        fieldOf _
          = (Lens.Family2.Unchecked.lens _RawTransaction'gas
               (\ x__ y__ -> x__{_RawTransaction'gas = y__}))
              Prelude.. Prelude.id
instance Data.ProtoLens.Field.HasField RawTransaction "signature"
           (Data.ByteString.ByteString)
         where
        fieldOf _
          = (Lens.Family2.Unchecked.lens _RawTransaction'signature
               (\ x__ y__ -> x__{_RawTransaction'signature = y__}))
              Prelude.. Prelude.id
instance Data.ProtoLens.Field.HasField RawTransaction "route"
           (Data.Text.Text)
         where
        fieldOf _
          = (Lens.Family2.Unchecked.lens _RawTransaction'route
               (\ x__ y__ -> x__{_RawTransaction'route = y__}))
              Prelude.. Prelude.id
instance Data.ProtoLens.Field.HasField RawTransaction "nonce"
           (Data.Word.Word64)
         where
        fieldOf _
          = (Lens.Family2.Unchecked.lens _RawTransaction'nonce
               (\ x__ y__ -> x__{_RawTransaction'nonce = y__}))
              Prelude.. Prelude.id
instance Data.ProtoLens.Message RawTransaction where
        messageName _ = Data.Text.pack "Transaction.RawTransaction"
        fieldsByTag
          = let data'__field_descriptor
                  = Data.ProtoLens.FieldDescriptor "data"
                      (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::
                         Data.ProtoLens.FieldTypeDescriptor TypedMessage)
                      (Data.ProtoLens.OptionalField
                         (Data.ProtoLens.Field.field @"maybe'data'"))
                      :: Data.ProtoLens.FieldDescriptor RawTransaction
                gas__field_descriptor
                  = Data.ProtoLens.FieldDescriptor "gas"
                      (Data.ProtoLens.ScalarField Data.ProtoLens.Int64Field ::
                         Data.ProtoLens.FieldTypeDescriptor Data.Int.Int64)
                      (Data.ProtoLens.PlainField Data.ProtoLens.Optional
                         (Data.ProtoLens.Field.field @"gas"))
                      :: Data.ProtoLens.FieldDescriptor RawTransaction
                signature__field_descriptor
                  = Data.ProtoLens.FieldDescriptor "signature"
                      (Data.ProtoLens.ScalarField Data.ProtoLens.BytesField ::
                         Data.ProtoLens.FieldTypeDescriptor Data.ByteString.ByteString)
                      (Data.ProtoLens.PlainField Data.ProtoLens.Optional
                         (Data.ProtoLens.Field.field @"signature"))
                      :: Data.ProtoLens.FieldDescriptor RawTransaction
                route__field_descriptor
                  = Data.ProtoLens.FieldDescriptor "route"
                      (Data.ProtoLens.ScalarField Data.ProtoLens.StringField ::
                         Data.ProtoLens.FieldTypeDescriptor Data.Text.Text)
                      (Data.ProtoLens.PlainField Data.ProtoLens.Optional
                         (Data.ProtoLens.Field.field @"route"))
                      :: Data.ProtoLens.FieldDescriptor RawTransaction
                nonce__field_descriptor
                  = Data.ProtoLens.FieldDescriptor "nonce"
                      (Data.ProtoLens.ScalarField Data.ProtoLens.UInt64Field ::
                         Data.ProtoLens.FieldTypeDescriptor Data.Word.Word64)
                      (Data.ProtoLens.PlainField Data.ProtoLens.Optional
                         (Data.ProtoLens.Field.field @"nonce"))
                      :: Data.ProtoLens.FieldDescriptor RawTransaction
              in
              Data.Map.fromList
                [(Data.ProtoLens.Tag 1, data'__field_descriptor),
                 (Data.ProtoLens.Tag 2, gas__field_descriptor),
                 (Data.ProtoLens.Tag 3, signature__field_descriptor),
                 (Data.ProtoLens.Tag 4, route__field_descriptor),
                 (Data.ProtoLens.Tag 5, nonce__field_descriptor)]
        unknownFields
          = Lens.Family2.Unchecked.lens _RawTransaction'_unknownFields
              (\ x__ y__ -> x__{_RawTransaction'_unknownFields = y__})
        defMessage
          = RawTransaction{_RawTransaction'data' = Prelude.Nothing,
                           _RawTransaction'gas = Data.ProtoLens.fieldDefault,
                           _RawTransaction'signature = Data.ProtoLens.fieldDefault,
                           _RawTransaction'route = Data.ProtoLens.fieldDefault,
                           _RawTransaction'nonce = Data.ProtoLens.fieldDefault,
                           _RawTransaction'_unknownFields = ([])}
        parseMessage
          = let loop ::
                     RawTransaction ->
                       Data.ProtoLens.Encoding.Bytes.Parser RawTransaction
                loop x
                  = do end <- Data.ProtoLens.Encoding.Bytes.atEnd
                       if end then
                         do let missing = [] in
                              if Prelude.null missing then Prelude.return () else
                                Prelude.fail
                                  (("Missing required fields: ") Prelude.++
                                     Prelude.show (missing :: ([Prelude.String])))
                            Prelude.return
                              (Lens.Family2.over Data.ProtoLens.unknownFields
                                 (\ !t -> Prelude.reverse t)
                                 x)
                         else
                         do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt
                            case tag of
                                10 -> do y <- (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt
                                                  Data.ProtoLens.Encoding.Bytes.isolate
                                                    (Prelude.fromIntegral len)
                                                    Data.ProtoLens.parseMessage)
                                                Data.ProtoLens.Encoding.Bytes.<?> "data"
                                         loop
                                           (Lens.Family2.set (Data.ProtoLens.Field.field @"data'") y
                                              x)
                                16 -> do y <- (Prelude.fmap Prelude.fromIntegral
                                                 Data.ProtoLens.Encoding.Bytes.getVarInt)
                                                Data.ProtoLens.Encoding.Bytes.<?> "gas"
                                         loop
                                           (Lens.Family2.set (Data.ProtoLens.Field.field @"gas") y
                                              x)
                                26 -> do y <- (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt
                                                  Data.ProtoLens.Encoding.Bytes.getBytes
                                                    (Prelude.fromIntegral len))
                                                Data.ProtoLens.Encoding.Bytes.<?> "signature"
                                         loop
                                           (Lens.Family2.set
                                              (Data.ProtoLens.Field.field @"signature")
                                              y
                                              x)
                                34 -> do y <- (do value <- do len <- Data.ProtoLens.Encoding.Bytes.getVarInt
                                                              Data.ProtoLens.Encoding.Bytes.getBytes
                                                                (Prelude.fromIntegral len)
                                                  Data.ProtoLens.Encoding.Bytes.runEither
                                                    (case Data.Text.Encoding.decodeUtf8' value of
                                                         Prelude.Left err -> Prelude.Left
                                                                               (Prelude.show err)
                                                         Prelude.Right r -> Prelude.Right r))
                                                Data.ProtoLens.Encoding.Bytes.<?> "route"
                                         loop
                                           (Lens.Family2.set (Data.ProtoLens.Field.field @"route") y
                                              x)
                                40 -> do y <- (Data.ProtoLens.Encoding.Bytes.getVarInt)
                                                Data.ProtoLens.Encoding.Bytes.<?> "nonce"
                                         loop
                                           (Lens.Family2.set (Data.ProtoLens.Field.field @"nonce") y
                                              x)
                                wire -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire
                                                   wire
                                           loop
                                             (Lens.Family2.over Data.ProtoLens.unknownFields
                                                (\ !t -> (:) y t)
                                                x)
              in
              (do loop Data.ProtoLens.defMessage)
                Data.ProtoLens.Encoding.Bytes.<?> "RawTransaction"
        buildMessage
          = (\ _x ->
               (case
                  Lens.Family2.view (Data.ProtoLens.Field.field @"maybe'data'") _x of
                    (Prelude.Nothing) -> Data.Monoid.mempty
                    Prelude.Just _v -> (Data.ProtoLens.Encoding.Bytes.putVarInt 10)
                                         Data.Monoid.<>
                                         (((\ bs ->
                                              (Data.ProtoLens.Encoding.Bytes.putVarInt
                                                 (Prelude.fromIntegral (Data.ByteString.length bs)))
                                                Data.Monoid.<>
                                                Data.ProtoLens.Encoding.Bytes.putBytes bs))
                                            Prelude.. Data.ProtoLens.encodeMessage)
                                           _v)
                 Data.Monoid.<>
                 (let _v = Lens.Family2.view (Data.ProtoLens.Field.field @"gas") _x
                    in
                    if (_v) Prelude.== Data.ProtoLens.fieldDefault then
                      Data.Monoid.mempty else
                      (Data.ProtoLens.Encoding.Bytes.putVarInt 16) Data.Monoid.<>
                        ((Data.ProtoLens.Encoding.Bytes.putVarInt) Prelude..
                           Prelude.fromIntegral)
                          _v)
                   Data.Monoid.<>
                   (let _v
                          = Lens.Family2.view (Data.ProtoLens.Field.field @"signature") _x
                      in
                      if (_v) Prelude.== Data.ProtoLens.fieldDefault then
                        Data.Monoid.mempty else
                        (Data.ProtoLens.Encoding.Bytes.putVarInt 26) Data.Monoid.<>
                          (\ bs ->
                             (Data.ProtoLens.Encoding.Bytes.putVarInt
                                (Prelude.fromIntegral (Data.ByteString.length bs)))
                               Data.Monoid.<> Data.ProtoLens.Encoding.Bytes.putBytes bs)
                            _v)
                     Data.Monoid.<>
                     (let _v
                            = Lens.Family2.view (Data.ProtoLens.Field.field @"route") _x
                        in
                        if (_v) Prelude.== Data.ProtoLens.fieldDefault then
                          Data.Monoid.mempty else
                          (Data.ProtoLens.Encoding.Bytes.putVarInt 34) Data.Monoid.<>
                            (((\ bs ->
                                 (Data.ProtoLens.Encoding.Bytes.putVarInt
                                    (Prelude.fromIntegral (Data.ByteString.length bs)))
                                   Data.Monoid.<> Data.ProtoLens.Encoding.Bytes.putBytes bs))
                               Prelude.. Data.Text.Encoding.encodeUtf8)
                              _v)
                       Data.Monoid.<>
                       (let _v
                              = Lens.Family2.view (Data.ProtoLens.Field.field @"nonce") _x
                          in
                          if (_v) Prelude.== Data.ProtoLens.fieldDefault then
                            Data.Monoid.mempty else
                            (Data.ProtoLens.Encoding.Bytes.putVarInt 40) Data.Monoid.<>
                              Data.ProtoLens.Encoding.Bytes.putVarInt _v)
                         Data.Monoid.<>
                         Data.ProtoLens.Encoding.Wire.buildFieldSet
                           (Lens.Family2.view Data.ProtoLens.unknownFields _x))
instance Control.DeepSeq.NFData RawTransaction where
        rnf
          = (\ x__ ->
               Control.DeepSeq.deepseq (_RawTransaction'_unknownFields x__)
                 (Control.DeepSeq.deepseq (_RawTransaction'data' x__)
                    (Control.DeepSeq.deepseq (_RawTransaction'gas x__)
                       (Control.DeepSeq.deepseq (_RawTransaction'signature x__)
                          (Control.DeepSeq.deepseq (_RawTransaction'route x__)
                             (Control.DeepSeq.deepseq (_RawTransaction'nonce x__) (())))))))
{- | Fields :

    * 'Proto.Types.Transaction_Fields.type'' @:: Lens' TypedMessage Data.Text.Text@
    * 'Proto.Types.Transaction_Fields.data'' @:: Lens' TypedMessage Data.ByteString.ByteString@
 -}
data TypedMessage = TypedMessage{_TypedMessage'type' ::
                                 !Data.Text.Text,
                                 _TypedMessage'data' :: !Data.ByteString.ByteString,
                                 _TypedMessage'_unknownFields :: !Data.ProtoLens.FieldSet}
                      deriving (Prelude.Eq, Prelude.Ord)
instance Prelude.Show TypedMessage where
        showsPrec _ __x __s
          = Prelude.showChar '{'
              (Prelude.showString (Data.ProtoLens.showMessageShort __x)
                 (Prelude.showChar '}' __s))
instance Data.ProtoLens.Field.HasField TypedMessage "type'"
           (Data.Text.Text)
         where
        fieldOf _
          = (Lens.Family2.Unchecked.lens _TypedMessage'type'
               (\ x__ y__ -> x__{_TypedMessage'type' = y__}))
              Prelude.. Prelude.id
instance Data.ProtoLens.Field.HasField TypedMessage "data'"
           (Data.ByteString.ByteString)
         where
        fieldOf _
          = (Lens.Family2.Unchecked.lens _TypedMessage'data'
               (\ x__ y__ -> x__{_TypedMessage'data' = y__}))
              Prelude.. Prelude.id
instance Data.ProtoLens.Message TypedMessage where
        messageName _ = Data.Text.pack "Transaction.TypedMessage"
        fieldsByTag
          = let type'__field_descriptor
                  = Data.ProtoLens.FieldDescriptor "type"
                      (Data.ProtoLens.ScalarField Data.ProtoLens.StringField ::
                         Data.ProtoLens.FieldTypeDescriptor Data.Text.Text)
                      (Data.ProtoLens.PlainField Data.ProtoLens.Optional
                         (Data.ProtoLens.Field.field @"type'"))
                      :: Data.ProtoLens.FieldDescriptor TypedMessage
                data'__field_descriptor
                  = Data.ProtoLens.FieldDescriptor "data"
                      (Data.ProtoLens.ScalarField Data.ProtoLens.BytesField ::
                         Data.ProtoLens.FieldTypeDescriptor Data.ByteString.ByteString)
                      (Data.ProtoLens.PlainField Data.ProtoLens.Optional
                         (Data.ProtoLens.Field.field @"data'"))
                      :: Data.ProtoLens.FieldDescriptor TypedMessage
              in
              Data.Map.fromList
                [(Data.ProtoLens.Tag 1, type'__field_descriptor),
                 (Data.ProtoLens.Tag 2, data'__field_descriptor)]
        unknownFields
          = Lens.Family2.Unchecked.lens _TypedMessage'_unknownFields
              (\ x__ y__ -> x__{_TypedMessage'_unknownFields = y__})
        defMessage
          = TypedMessage{_TypedMessage'type' = Data.ProtoLens.fieldDefault,
                         _TypedMessage'data' = Data.ProtoLens.fieldDefault,
                         _TypedMessage'_unknownFields = ([])}
        parseMessage
          = let loop ::
                     TypedMessage -> Data.ProtoLens.Encoding.Bytes.Parser TypedMessage
                loop x
                  = do end <- Data.ProtoLens.Encoding.Bytes.atEnd
                       if end then
                         do let missing = [] in
                              if Prelude.null missing then Prelude.return () else
                                Prelude.fail
                                  (("Missing required fields: ") Prelude.++
                                     Prelude.show (missing :: ([Prelude.String])))
                            Prelude.return
                              (Lens.Family2.over Data.ProtoLens.unknownFields
                                 (\ !t -> Prelude.reverse t)
                                 x)
                         else
                         do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt
                            case tag of
                                10 -> do y <- (do value <- do len <- Data.ProtoLens.Encoding.Bytes.getVarInt
                                                              Data.ProtoLens.Encoding.Bytes.getBytes
                                                                (Prelude.fromIntegral len)
                                                  Data.ProtoLens.Encoding.Bytes.runEither
                                                    (case Data.Text.Encoding.decodeUtf8' value of
                                                         Prelude.Left err -> Prelude.Left
                                                                               (Prelude.show err)
                                                         Prelude.Right r -> Prelude.Right r))
                                                Data.ProtoLens.Encoding.Bytes.<?> "type"
                                         loop
                                           (Lens.Family2.set (Data.ProtoLens.Field.field @"type'") y
                                              x)
                                18 -> do y <- (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt
                                                  Data.ProtoLens.Encoding.Bytes.getBytes
                                                    (Prelude.fromIntegral len))
                                                Data.ProtoLens.Encoding.Bytes.<?> "data"
                                         loop
                                           (Lens.Family2.set (Data.ProtoLens.Field.field @"data'") y
                                              x)
                                wire -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire
                                                   wire
                                           loop
                                             (Lens.Family2.over Data.ProtoLens.unknownFields
                                                (\ !t -> (:) y t)
                                                x)
              in
              (do loop Data.ProtoLens.defMessage)
                Data.ProtoLens.Encoding.Bytes.<?> "TypedMessage"
        buildMessage
          = (\ _x ->
               (let _v
                      = Lens.Family2.view (Data.ProtoLens.Field.field @"type'") _x
                  in
                  if (_v) Prelude.== Data.ProtoLens.fieldDefault then
                    Data.Monoid.mempty else
                    (Data.ProtoLens.Encoding.Bytes.putVarInt 10) Data.Monoid.<>
                      (((\ bs ->
                           (Data.ProtoLens.Encoding.Bytes.putVarInt
                              (Prelude.fromIntegral (Data.ByteString.length bs)))
                             Data.Monoid.<> Data.ProtoLens.Encoding.Bytes.putBytes bs))
                         Prelude.. Data.Text.Encoding.encodeUtf8)
                        _v)
                 Data.Monoid.<>
                 (let _v
                        = Lens.Family2.view (Data.ProtoLens.Field.field @"data'") _x
                    in
                    if (_v) Prelude.== Data.ProtoLens.fieldDefault then
                      Data.Monoid.mempty else
                      (Data.ProtoLens.Encoding.Bytes.putVarInt 18) Data.Monoid.<>
                        (\ bs ->
                           (Data.ProtoLens.Encoding.Bytes.putVarInt
                              (Prelude.fromIntegral (Data.ByteString.length bs)))
                             Data.Monoid.<> Data.ProtoLens.Encoding.Bytes.putBytes bs)
                          _v)
                   Data.Monoid.<>
                   Data.ProtoLens.Encoding.Wire.buildFieldSet
                     (Lens.Family2.view Data.ProtoLens.unknownFields _x))
instance Control.DeepSeq.NFData TypedMessage where
        rnf
          = (\ x__ ->
               Control.DeepSeq.deepseq (_TypedMessage'_unknownFields x__)
                 (Control.DeepSeq.deepseq (_TypedMessage'type' x__)
                    (Control.DeepSeq.deepseq (_TypedMessage'data' x__) (()))))