{- This file was auto-generated from modules/bank.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.Modules.Bank (Burn(), Transfer()) 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.Modules.Bank_Fields.address' @:: Lens' Burn Data.ByteString.ByteString@
    * 'Proto.Modules.Bank_Fields.cid' @:: Lens' Burn Data.Text.Text@
    * 'Proto.Modules.Bank_Fields.amount' @:: Lens' Burn Data.Word.Word64@
 -}
data Burn = Burn{_Burn'address :: !Data.ByteString.ByteString,
                 _Burn'cid :: !Data.Text.Text, _Burn'amount :: !Data.Word.Word64,
                 _Burn'_unknownFields :: !Data.ProtoLens.FieldSet}
              deriving (Prelude.Eq, Prelude.Ord)
instance Prelude.Show Burn where
        showsPrec _ __x __s
          = Prelude.showChar '{'
              (Prelude.showString (Data.ProtoLens.showMessageShort __x)
                 (Prelude.showChar '}' __s))
instance Data.ProtoLens.Field.HasField Burn "address"
           (Data.ByteString.ByteString)
         where
        fieldOf _
          = (Lens.Family2.Unchecked.lens _Burn'address
               (\ x__ y__ -> x__{_Burn'address = y__}))
              Prelude.. Prelude.id
instance Data.ProtoLens.Field.HasField Burn "cid" (Data.Text.Text)
         where
        fieldOf _
          = (Lens.Family2.Unchecked.lens _Burn'cid
               (\ x__ y__ -> x__{_Burn'cid = y__}))
              Prelude.. Prelude.id
instance Data.ProtoLens.Field.HasField Burn "amount"
           (Data.Word.Word64)
         where
        fieldOf _
          = (Lens.Family2.Unchecked.lens _Burn'amount
               (\ x__ y__ -> x__{_Burn'amount = y__}))
              Prelude.. Prelude.id
instance Data.ProtoLens.Message Burn where
        messageName _ = Data.Text.pack "Bank.Burn"
        fieldsByTag
          = let address__field_descriptor
                  = Data.ProtoLens.FieldDescriptor "address"
                      (Data.ProtoLens.ScalarField Data.ProtoLens.BytesField ::
                         Data.ProtoLens.FieldTypeDescriptor Data.ByteString.ByteString)
                      (Data.ProtoLens.PlainField Data.ProtoLens.Optional
                         (Data.ProtoLens.Field.field @"address"))
                      :: Data.ProtoLens.FieldDescriptor Burn
                cid__field_descriptor
                  = Data.ProtoLens.FieldDescriptor "cid"
                      (Data.ProtoLens.ScalarField Data.ProtoLens.StringField ::
                         Data.ProtoLens.FieldTypeDescriptor Data.Text.Text)
                      (Data.ProtoLens.PlainField Data.ProtoLens.Optional
                         (Data.ProtoLens.Field.field @"cid"))
                      :: Data.ProtoLens.FieldDescriptor Burn
                amount__field_descriptor
                  = Data.ProtoLens.FieldDescriptor "amount"
                      (Data.ProtoLens.ScalarField Data.ProtoLens.UInt64Field ::
                         Data.ProtoLens.FieldTypeDescriptor Data.Word.Word64)
                      (Data.ProtoLens.PlainField Data.ProtoLens.Optional
                         (Data.ProtoLens.Field.field @"amount"))
                      :: Data.ProtoLens.FieldDescriptor Burn
              in
              Data.Map.fromList
                [(Data.ProtoLens.Tag 1, address__field_descriptor),
                 (Data.ProtoLens.Tag 2, cid__field_descriptor),
                 (Data.ProtoLens.Tag 3, amount__field_descriptor)]
        unknownFields
          = Lens.Family2.Unchecked.lens _Burn'_unknownFields
              (\ x__ y__ -> x__{_Burn'_unknownFields = y__})
        defMessage
          = Burn{_Burn'address = Data.ProtoLens.fieldDefault,
                 _Burn'cid = Data.ProtoLens.fieldDefault,
                 _Burn'amount = Data.ProtoLens.fieldDefault,
                 _Burn'_unknownFields = ([])}
        parseMessage
          = let loop :: Burn -> Data.ProtoLens.Encoding.Bytes.Parser Burn
                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.getBytes
                                                    (Prelude.fromIntegral len))
                                                Data.ProtoLens.Encoding.Bytes.<?> "address"
                                         loop
                                           (Lens.Family2.set (Data.ProtoLens.Field.field @"address")
                                              y
                                              x)
                                18 -> 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.<?> "cid"
                                         loop
                                           (Lens.Family2.set (Data.ProtoLens.Field.field @"cid") y
                                              x)
                                24 -> do y <- (Data.ProtoLens.Encoding.Bytes.getVarInt)
                                                Data.ProtoLens.Encoding.Bytes.<?> "amount"
                                         loop
                                           (Lens.Family2.set (Data.ProtoLens.Field.field @"amount")
                                              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.<?> "Burn"
        buildMessage
          = (\ _x ->
               (let _v
                      = Lens.Family2.view (Data.ProtoLens.Field.field @"address") _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)
                        _v)
                 Data.Monoid.<>
                 (let _v = Lens.Family2.view (Data.ProtoLens.Field.field @"cid") _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))
                           Prelude.. Data.Text.Encoding.encodeUtf8)
                          _v)
                   Data.Monoid.<>
                   (let _v
                          = Lens.Family2.view (Data.ProtoLens.Field.field @"amount") _x
                      in
                      if (_v) Prelude.== Data.ProtoLens.fieldDefault then
                        Data.Monoid.mempty else
                        (Data.ProtoLens.Encoding.Bytes.putVarInt 24) 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 Burn where
        rnf
          = (\ x__ ->
               Control.DeepSeq.deepseq (_Burn'_unknownFields x__)
                 (Control.DeepSeq.deepseq (_Burn'address x__)
                    (Control.DeepSeq.deepseq (_Burn'cid x__)
                       (Control.DeepSeq.deepseq (_Burn'amount x__) (())))))
{- | Fields :

    * 'Proto.Modules.Bank_Fields.to' @:: Lens' Transfer Data.ByteString.ByteString@
    * 'Proto.Modules.Bank_Fields.from' @:: Lens' Transfer Data.ByteString.ByteString@
    * 'Proto.Modules.Bank_Fields.cid' @:: Lens' Transfer Data.Text.Text@
    * 'Proto.Modules.Bank_Fields.amount' @:: Lens' Transfer Data.Word.Word64@
 -}
data Transfer = Transfer{_Transfer'to ::
                         !Data.ByteString.ByteString,
                         _Transfer'from :: !Data.ByteString.ByteString,
                         _Transfer'cid :: !Data.Text.Text,
                         _Transfer'amount :: !Data.Word.Word64,
                         _Transfer'_unknownFields :: !Data.ProtoLens.FieldSet}
                  deriving (Prelude.Eq, Prelude.Ord)
instance Prelude.Show Transfer where
        showsPrec _ __x __s
          = Prelude.showChar '{'
              (Prelude.showString (Data.ProtoLens.showMessageShort __x)
                 (Prelude.showChar '}' __s))
instance Data.ProtoLens.Field.HasField Transfer "to"
           (Data.ByteString.ByteString)
         where
        fieldOf _
          = (Lens.Family2.Unchecked.lens _Transfer'to
               (\ x__ y__ -> x__{_Transfer'to = y__}))
              Prelude.. Prelude.id
instance Data.ProtoLens.Field.HasField Transfer "from"
           (Data.ByteString.ByteString)
         where
        fieldOf _
          = (Lens.Family2.Unchecked.lens _Transfer'from
               (\ x__ y__ -> x__{_Transfer'from = y__}))
              Prelude.. Prelude.id
instance Data.ProtoLens.Field.HasField Transfer "cid"
           (Data.Text.Text)
         where
        fieldOf _
          = (Lens.Family2.Unchecked.lens _Transfer'cid
               (\ x__ y__ -> x__{_Transfer'cid = y__}))
              Prelude.. Prelude.id
instance Data.ProtoLens.Field.HasField Transfer "amount"
           (Data.Word.Word64)
         where
        fieldOf _
          = (Lens.Family2.Unchecked.lens _Transfer'amount
               (\ x__ y__ -> x__{_Transfer'amount = y__}))
              Prelude.. Prelude.id
instance Data.ProtoLens.Message Transfer where
        messageName _ = Data.Text.pack "Bank.Transfer"
        fieldsByTag
          = let to__field_descriptor
                  = Data.ProtoLens.FieldDescriptor "to"
                      (Data.ProtoLens.ScalarField Data.ProtoLens.BytesField ::
                         Data.ProtoLens.FieldTypeDescriptor Data.ByteString.ByteString)
                      (Data.ProtoLens.PlainField Data.ProtoLens.Optional
                         (Data.ProtoLens.Field.field @"to"))
                      :: Data.ProtoLens.FieldDescriptor Transfer
                from__field_descriptor
                  = Data.ProtoLens.FieldDescriptor "from"
                      (Data.ProtoLens.ScalarField Data.ProtoLens.BytesField ::
                         Data.ProtoLens.FieldTypeDescriptor Data.ByteString.ByteString)
                      (Data.ProtoLens.PlainField Data.ProtoLens.Optional
                         (Data.ProtoLens.Field.field @"from"))
                      :: Data.ProtoLens.FieldDescriptor Transfer
                cid__field_descriptor
                  = Data.ProtoLens.FieldDescriptor "cid"
                      (Data.ProtoLens.ScalarField Data.ProtoLens.StringField ::
                         Data.ProtoLens.FieldTypeDescriptor Data.Text.Text)
                      (Data.ProtoLens.PlainField Data.ProtoLens.Optional
                         (Data.ProtoLens.Field.field @"cid"))
                      :: Data.ProtoLens.FieldDescriptor Transfer
                amount__field_descriptor
                  = Data.ProtoLens.FieldDescriptor "amount"
                      (Data.ProtoLens.ScalarField Data.ProtoLens.UInt64Field ::
                         Data.ProtoLens.FieldTypeDescriptor Data.Word.Word64)
                      (Data.ProtoLens.PlainField Data.ProtoLens.Optional
                         (Data.ProtoLens.Field.field @"amount"))
                      :: Data.ProtoLens.FieldDescriptor Transfer
              in
              Data.Map.fromList
                [(Data.ProtoLens.Tag 1, to__field_descriptor),
                 (Data.ProtoLens.Tag 2, from__field_descriptor),
                 (Data.ProtoLens.Tag 3, cid__field_descriptor),
                 (Data.ProtoLens.Tag 4, amount__field_descriptor)]
        unknownFields
          = Lens.Family2.Unchecked.lens _Transfer'_unknownFields
              (\ x__ y__ -> x__{_Transfer'_unknownFields = y__})
        defMessage
          = Transfer{_Transfer'to = Data.ProtoLens.fieldDefault,
                     _Transfer'from = Data.ProtoLens.fieldDefault,
                     _Transfer'cid = Data.ProtoLens.fieldDefault,
                     _Transfer'amount = Data.ProtoLens.fieldDefault,
                     _Transfer'_unknownFields = ([])}
        parseMessage
          = let loop ::
                     Transfer -> Data.ProtoLens.Encoding.Bytes.Parser Transfer
                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.getBytes
                                                    (Prelude.fromIntegral len))
                                                Data.ProtoLens.Encoding.Bytes.<?> "to"
                                         loop
                                           (Lens.Family2.set (Data.ProtoLens.Field.field @"to") y x)
                                18 -> do y <- (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt
                                                  Data.ProtoLens.Encoding.Bytes.getBytes
                                                    (Prelude.fromIntegral len))
                                                Data.ProtoLens.Encoding.Bytes.<?> "from"
                                         loop
                                           (Lens.Family2.set (Data.ProtoLens.Field.field @"from") y
                                              x)
                                26 -> 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.<?> "cid"
                                         loop
                                           (Lens.Family2.set (Data.ProtoLens.Field.field @"cid") y
                                              x)
                                32 -> do y <- (Data.ProtoLens.Encoding.Bytes.getVarInt)
                                                Data.ProtoLens.Encoding.Bytes.<?> "amount"
                                         loop
                                           (Lens.Family2.set (Data.ProtoLens.Field.field @"amount")
                                              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.<?> "Transfer"
        buildMessage
          = (\ _x ->
               (let _v = Lens.Family2.view (Data.ProtoLens.Field.field @"to") _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)
                        _v)
                 Data.Monoid.<>
                 (let _v = Lens.Family2.view (Data.ProtoLens.Field.field @"from") _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.<>
                   (let _v = Lens.Family2.view (Data.ProtoLens.Field.field @"cid") _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))
                             Prelude.. Data.Text.Encoding.encodeUtf8)
                            _v)
                     Data.Monoid.<>
                     (let _v
                            = Lens.Family2.view (Data.ProtoLens.Field.field @"amount") _x
                        in
                        if (_v) Prelude.== Data.ProtoLens.fieldDefault then
                          Data.Monoid.mempty else
                          (Data.ProtoLens.Encoding.Bytes.putVarInt 32) 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 Transfer where
        rnf
          = (\ x__ ->
               Control.DeepSeq.deepseq (_Transfer'_unknownFields x__)
                 (Control.DeepSeq.deepseq (_Transfer'to x__)
                    (Control.DeepSeq.deepseq (_Transfer'from x__)
                       (Control.DeepSeq.deepseq (_Transfer'cid x__)
                          (Control.DeepSeq.deepseq (_Transfer'amount x__) (()))))))