{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}

-- |
-- Copyright: © 2018-2020 IOHK
-- License: Apache-2.0
--
-- This module provides a half-typed Servant client for the cardano-wallet V2 API.
--
-- The functions in this module can be run with "Servant.Client.runClientM".

module Cardano.Wallet.Api.Client
    ( -- * API Clients
      WalletClient (..)
    , walletClient
    , byronWalletClient

    , TransactionClient (..)
    , transactionClient
    , byronTransactionClient

    , AddressClient (..)
    , addressClient
    , byronAddressClient

    , StakePoolClient (..)
    , stakePoolClient

    , NetworkClient (..)
    , networkClient
    ) where

import Prelude

import Cardano.Wallet.Api
    ( Addresses
    , ByronAddresses
    , ByronTransactions
    , ByronWallets
    , Network
    , PostData
    , Proxy_
    , ShelleyTransactions
    , StakePools
    , Wallets
    )
import Cardano.Wallet.Api.Types
    ( ApiAddressIdT
    , ApiAddressInspect (..)
    , ApiAddressInspectData (..)
    , ApiAddressT
    , ApiBalanceTransactionPostDataT
    , ApiByronWallet
    , ApiBytesT (..)
    , ApiCoinSelectionT
    , ApiConstructTransactionDataT
    , ApiConstructTransactionT
    , ApiDecodedTransactionT
    , ApiFee
    , ApiNetworkClock
    , ApiNetworkInformation (..)
    , ApiNetworkParameters
    , ApiPoolId
    , ApiPostRandomAddressData
    , ApiPutAddressesDataT
    , ApiSelectCoinsDataT
    , ApiSerialisedTransaction (..)
    , ApiSignTransactionPostData
    , ApiStakeKeysT
    , ApiT (..)
    , ApiTransactionT
    , ApiTxId (..)
    , ApiUtxoStatistics
    , ApiWallet (..)
    , ApiWalletPassphrase
    , ApiWalletUtxoSnapshot (..)
    , Base (Base64)
    , ByronWalletPutPassphraseData (..)
    , Iso8601Time (..)
    , PostTransactionFeeOldDataT
    , PostTransactionOldDataT
    , WalletPutData (..)
    , WalletPutPassphraseData (..)
    )
import Cardano.Wallet.Api.Types.SchemaMetadata
    ( TxMetadataSchema, toSimpleMetadataFlag )
import Cardano.Wallet.Primitive.Types
    ( SortOrder, WalletId )
import Cardano.Wallet.Primitive.Types.Address
    ( AddressState )
import Cardano.Wallet.Primitive.Types.Coin
    ( Coin (..) )
import Cardano.Wallet.Primitive.Types.Tx
    ( SealedTx, SerialisedTx (..), unsafeSealedTxFromBytes )
import Control.Monad
    ( void )
import Data.Generics.Internal.VL.Lens
    ( view )
import Data.Generics.Labels
    ()
import Data.Proxy
    ( Proxy (..) )
import Data.Text
    ( Text )
import Servant
    ( (:<|>) (..), (:>), NoContent )
import Servant.Client
    ( ClientM, client )
import UnliftIO.Exception
    ( throwString )

import qualified Data.Aeson as Aeson

{-------------------------------------------------------------------------------
                              Server Interaction
-------------------------------------------------------------------------------}
type family  WalletPutPassphraseFormat wallet where
    WalletPutPassphraseFormat ApiWallet = WalletPutPassphraseData
    WalletPutPassphraseFormat ApiByronWallet = ByronWalletPutPassphraseData

-- | This data type encapsulates the client functions for all endpoints of the
-- cardano-wallet V2 API.
data WalletClient wallet = WalletClient
    { WalletClient wallet -> ApiT WalletId -> ClientM ()
deleteWallet
        :: ApiT WalletId
        -> ClientM ()
    , WalletClient wallet -> ApiT WalletId -> ClientM wallet
getWallet
        :: ApiT WalletId
        -> ClientM wallet
    , WalletClient wallet -> ApiT WalletId -> ClientM ApiUtxoStatistics
getWalletUtxoStatistics
        :: ApiT WalletId
        -> ClientM ApiUtxoStatistics
    , WalletClient wallet
-> ApiT WalletId -> ClientM ApiWalletUtxoSnapshot
getWalletUtxoSnapshot
        :: ApiT WalletId
        -> ClientM ApiWalletUtxoSnapshot
    , WalletClient wallet -> ClientM [wallet]
listWallets
        :: ClientM [wallet]
    , WalletClient wallet -> PostData wallet -> ClientM wallet
postWallet
        :: PostData wallet
        -> ClientM wallet
    , WalletClient wallet
-> ApiT WalletId -> WalletPutData -> ClientM wallet
putWallet
        :: ApiT WalletId
        -> WalletPutData
        -> ClientM wallet
    , WalletClient wallet
-> ApiT WalletId
-> WalletPutPassphraseFormat wallet
-> ClientM NoContent
putWalletPassphrase
        :: ApiT WalletId
        -> WalletPutPassphraseFormat wallet
        -> ClientM NoContent
    }

data TransactionClient = TransactionClient
    { TransactionClient
-> ApiT WalletId
-> Maybe Iso8601Time
-> Maybe Iso8601Time
-> Maybe (ApiT SortOrder)
-> Bool
-> ClientM [ApiTransactionT Value]
listTransactions
        :: ApiT WalletId
        -> Maybe Iso8601Time
        -> Maybe Iso8601Time
        -> Maybe (ApiT SortOrder)
        -> Bool
        -> ClientM [ApiTransactionT Aeson.Value]
    , TransactionClient
-> ApiT WalletId
-> ApiSignTransactionPostData
-> ClientM ApiSerialisedTransaction
signTransaction
        :: ApiT WalletId
        -> ApiSignTransactionPostData
        -> ClientM ApiSerialisedTransaction
    , TransactionClient
-> ApiT WalletId
-> PostTransactionOldDataT Value
-> ClientM (ApiTransactionT Value)
postTransaction
        :: ApiT WalletId
        -> PostTransactionOldDataT Aeson.Value
        -> ClientM (ApiTransactionT Aeson.Value)
    , TransactionClient
-> ApiT WalletId
-> PostTransactionFeeOldDataT Value
-> ClientM ApiFee
postTransactionFee
        :: ApiT WalletId
        -> PostTransactionFeeOldDataT Aeson.Value
        -> ClientM ApiFee
    , TransactionClient
-> ApiBytesT 'Base64 SerialisedTx -> ClientM ApiTxId
postExternalTransaction
        :: ApiBytesT 'Base64 SerialisedTx
        -> ClientM ApiTxId
    , TransactionClient -> ApiT WalletId -> ApiTxId -> ClientM NoContent
deleteTransaction
        :: ApiT WalletId
        -> ApiTxId
        -> ClientM NoContent
    , TransactionClient
-> ApiT WalletId
-> ApiTxId
-> TxMetadataSchema
-> ClientM (ApiTransactionT Value)
getTransaction
        :: ApiT WalletId
        -> ApiTxId
        -> TxMetadataSchema
        -> ClientM (ApiTransactionT Aeson.Value)
    , TransactionClient
-> ApiT WalletId
-> ApiConstructTransactionDataT Value
-> ClientM (ApiConstructTransactionT Value)
constructTransaction
        :: ApiT WalletId
        -> ApiConstructTransactionDataT Aeson.Value
        -> ClientM (ApiConstructTransactionT Aeson.Value)
    , TransactionClient
-> ApiT WalletId
-> ApiBalanceTransactionPostDataT Value
-> ClientM ApiSerialisedTransaction
balanceTransaction
        :: ApiT WalletId
        -> ApiBalanceTransactionPostDataT Aeson.Value
        -> ClientM ApiSerialisedTransaction
    , TransactionClient
-> ApiT WalletId
-> ApiSerialisedTransaction
-> ClientM (ApiDecodedTransactionT Value)
decodeTransaction
        :: ApiT WalletId
        -> ApiSerialisedTransaction
        -> ClientM (ApiDecodedTransactionT Aeson.Value)
    , TransactionClient
-> ApiT WalletId -> ApiSerialisedTransaction -> ClientM ApiTxId
submitTransaction
        :: ApiT WalletId
        -> ApiSerialisedTransaction
        -> ClientM ApiTxId
    }

data AddressClient = AddressClient
    { AddressClient
-> ApiT WalletId -> Maybe (ApiT AddressState) -> ClientM [Value]
listAddresses
        :: ApiT WalletId
        -> Maybe (ApiT AddressState)
        -> ClientM [Aeson.Value]
    , AddressClient -> Text -> ClientM Value
inspectAddress
        :: Text
        -> ClientM Aeson.Value
    , AddressClient
-> ApiT WalletId
-> ApiPostRandomAddressData
-> ClientM (ApiAddressT Value)
postRandomAddress
        :: ApiT WalletId
        -> ApiPostRandomAddressData
        -> ClientM (ApiAddressT Aeson.Value)
    , AddressClient
-> ApiT WalletId -> ApiAddressIdT Value -> ClientM NoContent
putRandomAddress
        :: ApiT WalletId
        -> ApiAddressIdT Aeson.Value
        -> ClientM NoContent
    , AddressClient
-> ApiT WalletId -> ApiPutAddressesDataT Value -> ClientM NoContent
putRandomAddresses
        :: ApiT WalletId
        -> ApiPutAddressesDataT Aeson.Value
        -> ClientM NoContent
    }

data StakePoolClient apiPool = StakePoolClient
    { StakePoolClient apiPool -> Maybe (ApiT Coin) -> ClientM [apiPool]
listPools
        :: Maybe (ApiT Coin) -> ClientM [apiPool]
    , StakePoolClient apiPool
-> ApiPoolId
-> ApiT WalletId
-> ApiWalletPassphrase
-> ClientM (ApiTransactionT Value)
joinStakePool
        :: ApiPoolId
        -> ApiT WalletId
        -> ApiWalletPassphrase
        -> ClientM (ApiTransactionT Aeson.Value)
    , StakePoolClient apiPool
-> ApiT WalletId
-> ApiWalletPassphrase
-> ClientM (ApiTransactionT Value)
quitStakePool
        :: ApiT WalletId
        -> ApiWalletPassphrase
        -> ClientM (ApiTransactionT Aeson.Value)
    }


data NetworkClient = NetworkClient
    { NetworkClient -> ClientM ApiNetworkInformation
networkInformation
        :: ClientM ApiNetworkInformation
    , NetworkClient -> ClientM ApiNetworkParameters
networkParameters
        :: ClientM ApiNetworkParameters
    , NetworkClient -> Bool -> ClientM ApiNetworkClock
networkClock
        :: Bool -- When 'True', block and force NTP check
        -> ClientM ApiNetworkClock
    }

-- | Produces a 'WalletClient' working against the /wallets API.
walletClient :: WalletClient ApiWallet
walletClient :: WalletClient ApiWallet
walletClient =
    let
        ApiT WalletId -> ClientM NoContent
_deleteWallet
            :<|> ApiT WalletId -> ClientM ApiWallet
_getWallet
            :<|> ClientM [ApiWallet]
_listWallets
            :<|> WalletOrAccountPostData -> ClientM ApiWallet
_postWallet
            :<|> ApiT WalletId -> WalletPutData -> ClientM ApiWallet
_putWallet
            :<|> ApiT WalletId -> WalletPutPassphraseData -> ClientM NoContent
_putWalletPassphrase
            :<|> ApiT WalletId -> ClientM ApiWalletUtxoSnapshot
_getWalletUtxoSnapshot
            :<|> ApiT WalletId -> ClientM ApiUtxoStatistics
_getWalletUtxoStatistics
            = Proxy
  ("v2"
   :> (DeleteWallet
       :<|> (GetWallet
             :<|> (ListWallets
                   :<|> (("wallets"
                          :> (ReqBody '[JSON] WalletOrAccountPostData
                              :> PostCreated '[JSON] ApiWallet))
                         :<|> (PutWallet
                               :<|> (PutWalletPassphrase
                                     :<|> (GetWalletUtxoSnapshot :<|> GetUTxOsStatistics))))))))
-> Client
     ClientM
     ("v2"
      :> (DeleteWallet
          :<|> (GetWallet
                :<|> (ListWallets
                      :<|> (("wallets"
                             :> (ReqBody '[JSON] WalletOrAccountPostData
                                 :> PostCreated '[JSON] ApiWallet))
                            :<|> (PutWallet
                                  :<|> (PutWalletPassphrase
                                        :<|> (GetWalletUtxoSnapshot :<|> GetUTxOsStatistics))))))))
forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client (Proxy ("v2" :> Wallets)
forall k (t :: k). Proxy t
Proxy @("v2" :> Wallets))
    in
        WalletClient :: forall wallet.
(ApiT WalletId -> ClientM ())
-> (ApiT WalletId -> ClientM wallet)
-> (ApiT WalletId -> ClientM ApiUtxoStatistics)
-> (ApiT WalletId -> ClientM ApiWalletUtxoSnapshot)
-> ClientM [wallet]
-> (PostData wallet -> ClientM wallet)
-> (ApiT WalletId -> WalletPutData -> ClientM wallet)
-> (ApiT WalletId
    -> WalletPutPassphraseFormat wallet -> ClientM NoContent)
-> WalletClient wallet
WalletClient
            { $sel:deleteWallet:WalletClient :: ApiT WalletId -> ClientM ()
deleteWallet = ClientM NoContent -> ClientM ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (ClientM NoContent -> ClientM ())
-> (ApiT WalletId -> ClientM NoContent)
-> ApiT WalletId
-> ClientM ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ApiT WalletId -> ClientM NoContent
_deleteWallet
            , $sel:getWallet:WalletClient :: ApiT WalletId -> ClientM ApiWallet
getWallet = ApiT WalletId -> ClientM ApiWallet
_getWallet
            , $sel:listWallets:WalletClient :: ClientM [ApiWallet]
listWallets = ClientM [ApiWallet]
_listWallets
            , $sel:postWallet:WalletClient :: PostData ApiWallet -> ClientM ApiWallet
postWallet = WalletOrAccountPostData -> ClientM ApiWallet
PostData ApiWallet -> ClientM ApiWallet
_postWallet
            , $sel:putWallet:WalletClient :: ApiT WalletId -> WalletPutData -> ClientM ApiWallet
putWallet = ApiT WalletId -> WalletPutData -> ClientM ApiWallet
_putWallet
            , $sel:putWalletPassphrase:WalletClient :: ApiT WalletId
-> WalletPutPassphraseFormat ApiWallet -> ClientM NoContent
putWalletPassphrase = ApiT WalletId -> WalletPutPassphraseData -> ClientM NoContent
ApiT WalletId
-> WalletPutPassphraseFormat ApiWallet -> ClientM NoContent
_putWalletPassphrase
            , $sel:getWalletUtxoSnapshot:WalletClient :: ApiT WalletId -> ClientM ApiWalletUtxoSnapshot
getWalletUtxoSnapshot = ApiT WalletId -> ClientM ApiWalletUtxoSnapshot
_getWalletUtxoSnapshot
            , $sel:getWalletUtxoStatistics:WalletClient :: ApiT WalletId -> ClientM ApiUtxoStatistics
getWalletUtxoStatistics = ApiT WalletId -> ClientM ApiUtxoStatistics
_getWalletUtxoStatistics
            }

-- | Produces a 'WalletClient' working against the /wallets API.
byronWalletClient :: WalletClient ApiByronWallet
byronWalletClient :: WalletClient ApiByronWallet
byronWalletClient =
    let
        SomeByronWalletPostData -> ClientM ApiByronWallet
_postWallet
            :<|> ApiT WalletId -> ClientM NoContent
_deleteWallet
            :<|> ApiT WalletId -> ClientM ApiByronWallet
_getWallet
            :<|> ClientM [ApiByronWallet]
_listWallets
            :<|> ApiT WalletId -> WalletPutData -> ClientM ApiByronWallet
_putWallet
            :<|> ApiT WalletId -> ClientM ApiWalletUtxoSnapshot
_getWalletUtxoSnapshot
            :<|> ApiT WalletId -> ClientM ApiUtxoStatistics
_getWalletUtxoStatistics
            :<|> ApiT WalletId -> ByronWalletPutPassphraseData -> ClientM NoContent
_putWalletPassphrase
            = Proxy
  ("v2"
   :> (("byron-wallets"
        :> (ReqBody '[JSON] SomeByronWalletPostData
            :> PostCreated '[JSON] ApiByronWallet))
       :<|> (DeleteByronWallet
             :<|> (GetByronWallet
                   :<|> (ListByronWallets
                         :<|> (PutByronWallet
                               :<|> (GetByronWalletUtxoSnapshot
                                     :<|> (GetByronUTxOsStatistics
                                           :<|> PutByronWalletPassphrase))))))))
-> Client
     ClientM
     ("v2"
      :> (("byron-wallets"
           :> (ReqBody '[JSON] SomeByronWalletPostData
               :> PostCreated '[JSON] ApiByronWallet))
          :<|> (DeleteByronWallet
                :<|> (GetByronWallet
                      :<|> (ListByronWallets
                            :<|> (PutByronWallet
                                  :<|> (GetByronWalletUtxoSnapshot
                                        :<|> (GetByronUTxOsStatistics
                                              :<|> PutByronWalletPassphrase))))))))
forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client (Proxy ("v2" :> ByronWallets)
forall k (t :: k). Proxy t
Proxy @("v2" :> ByronWallets))
    in
        WalletClient :: forall wallet.
(ApiT WalletId -> ClientM ())
-> (ApiT WalletId -> ClientM wallet)
-> (ApiT WalletId -> ClientM ApiUtxoStatistics)
-> (ApiT WalletId -> ClientM ApiWalletUtxoSnapshot)
-> ClientM [wallet]
-> (PostData wallet -> ClientM wallet)
-> (ApiT WalletId -> WalletPutData -> ClientM wallet)
-> (ApiT WalletId
    -> WalletPutPassphraseFormat wallet -> ClientM NoContent)
-> WalletClient wallet
WalletClient
            { $sel:deleteWallet:WalletClient :: ApiT WalletId -> ClientM ()
deleteWallet = ClientM NoContent -> ClientM ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (ClientM NoContent -> ClientM ())
-> (ApiT WalletId -> ClientM NoContent)
-> ApiT WalletId
-> ClientM ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ApiT WalletId -> ClientM NoContent
_deleteWallet
            , $sel:getWallet:WalletClient :: ApiT WalletId -> ClientM ApiByronWallet
getWallet = ApiT WalletId -> ClientM ApiByronWallet
_getWallet
            , $sel:listWallets:WalletClient :: ClientM [ApiByronWallet]
listWallets = ClientM [ApiByronWallet]
_listWallets
            , $sel:postWallet:WalletClient :: PostData ApiByronWallet -> ClientM ApiByronWallet
postWallet = SomeByronWalletPostData -> ClientM ApiByronWallet
PostData ApiByronWallet -> ClientM ApiByronWallet
_postWallet
            , $sel:putWallet:WalletClient :: ApiT WalletId -> WalletPutData -> ClientM ApiByronWallet
putWallet = ApiT WalletId -> WalletPutData -> ClientM ApiByronWallet
_putWallet
            , $sel:putWalletPassphrase:WalletClient :: ApiT WalletId
-> WalletPutPassphraseFormat ApiByronWallet -> ClientM NoContent
putWalletPassphrase = ApiT WalletId -> ByronWalletPutPassphraseData -> ClientM NoContent
ApiT WalletId
-> WalletPutPassphraseFormat ApiByronWallet -> ClientM NoContent
_putWalletPassphrase
            , $sel:getWalletUtxoSnapshot:WalletClient :: ApiT WalletId -> ClientM ApiWalletUtxoSnapshot
getWalletUtxoSnapshot = ApiT WalletId -> ClientM ApiWalletUtxoSnapshot
_getWalletUtxoSnapshot
            , $sel:getWalletUtxoStatistics:WalletClient :: ApiT WalletId -> ClientM ApiUtxoStatistics
getWalletUtxoStatistics = ApiT WalletId -> ClientM ApiUtxoStatistics
_getWalletUtxoStatistics
            }

-- | Produces a 'TransactionClient t' working against the /wallets API.
transactionClient
    :: TransactionClient
transactionClient :: TransactionClient
transactionClient =
    let
        ApiT WalletId -> Value -> ClientM Value
_constructTransaction
            :<|> ApiT WalletId
-> ApiSignTransactionPostData -> ClientM ApiSerialisedTransaction
_signTransaction
            :<|> ApiT WalletId
-> Maybe MinWithdrawal
-> Maybe Iso8601Time
-> Maybe Iso8601Time
-> Maybe (ApiT SortOrder)
-> Bool
-> ClientM [Value]
_listTransactions
            :<|> ApiT WalletId -> ApiTxId -> Bool -> ClientM Value
_getTransaction
            :<|> ApiT WalletId -> ApiTxId -> ClientM NoContent
_deleteTransaction
            :<|> ApiT WalletId -> Value -> ClientM Value
_postTransaction
            :<|> ApiT WalletId -> Value -> ClientM ApiFee
_postTransactionFee
            :<|> ApiT WalletId -> Value -> ClientM ApiSerialisedTransaction
_balanceTransaction
            :<|> ApiT WalletId -> ApiSerialisedTransaction -> ClientM Value
_decodeTransaction
            :<|> ApiT WalletId -> ApiSerialisedTransaction -> ClientM ApiTxId
_submitTransaction
            = Proxy
  ("v2"
   :> (("wallets"
        :> (Capture "walletId" (ApiT WalletId)
            :> ("transactions-construct"
                :> (ReqBody '[JSON] Value :> PostAccepted '[JSON] Value))))
       :<|> (SignTransaction Value
             :<|> (("wallets"
                    :> (Capture "walletId" (ApiT WalletId)
                        :> ("transactions"
                            :> (QueryParam "minWithdrawal" MinWithdrawal
                                :> (QueryParam "start" Iso8601Time
                                    :> (QueryParam "end" Iso8601Time
                                        :> (QueryParam "order" (ApiT SortOrder)
                                            :> (QueryFlag "simple-metadata"
                                                :> Get '[JSON] [Value]))))))))
                   :<|> (("wallets"
                          :> (Capture "walletId" (ApiT WalletId)
                              :> ("transactions"
                                  :> (Capture "transactionId" ApiTxId
                                      :> (QueryFlag "simple-metadata" :> Get '[JSON] Value)))))
                         :<|> (DeleteTransaction
                               :<|> (("wallets"
                                      :> (Capture "walletId" (ApiT WalletId)
                                          :> ("transactions"
                                              :> (ReqBody '[JSON] Value
                                                  :> PostAccepted '[JSON] Value))))
                                     :<|> (("wallets"
                                            :> (Capture "walletId" (ApiT WalletId)
                                                :> ("payment-fees"
                                                    :> (ReqBody '[JSON] Value
                                                        :> PostAccepted '[JSON] ApiFee))))
                                           :<|> (("wallets"
                                                  :> (Capture "walletId" (ApiT WalletId)
                                                      :> ("transactions-balance"
                                                          :> (ReqBody '[JSON] Value
                                                              :> PostAccepted
                                                                   '[JSON]
                                                                   ApiSerialisedTransaction))))
                                                 :<|> (("wallets"
                                                        :> (Capture "walletId" (ApiT WalletId)
                                                            :> ("transactions-decode"
                                                                :> (ReqBody
                                                                      '[JSON]
                                                                      ApiSerialisedTransaction
                                                                    :> PostAccepted
                                                                         '[JSON] Value))))
                                                       :<|> SubmitTransaction))))))))))
-> Client
     ClientM
     ("v2"
      :> (("wallets"
           :> (Capture "walletId" (ApiT WalletId)
               :> ("transactions-construct"
                   :> (ReqBody '[JSON] Value :> PostAccepted '[JSON] Value))))
          :<|> (SignTransaction Value
                :<|> (("wallets"
                       :> (Capture "walletId" (ApiT WalletId)
                           :> ("transactions"
                               :> (QueryParam "minWithdrawal" MinWithdrawal
                                   :> (QueryParam "start" Iso8601Time
                                       :> (QueryParam "end" Iso8601Time
                                           :> (QueryParam "order" (ApiT SortOrder)
                                               :> (QueryFlag "simple-metadata"
                                                   :> Get '[JSON] [Value]))))))))
                      :<|> (("wallets"
                             :> (Capture "walletId" (ApiT WalletId)
                                 :> ("transactions"
                                     :> (Capture "transactionId" ApiTxId
                                         :> (QueryFlag "simple-metadata" :> Get '[JSON] Value)))))
                            :<|> (DeleteTransaction
                                  :<|> (("wallets"
                                         :> (Capture "walletId" (ApiT WalletId)
                                             :> ("transactions"
                                                 :> (ReqBody '[JSON] Value
                                                     :> PostAccepted '[JSON] Value))))
                                        :<|> (("wallets"
                                               :> (Capture "walletId" (ApiT WalletId)
                                                   :> ("payment-fees"
                                                       :> (ReqBody '[JSON] Value
                                                           :> PostAccepted '[JSON] ApiFee))))
                                              :<|> (("wallets"
                                                     :> (Capture "walletId" (ApiT WalletId)
                                                         :> ("transactions-balance"
                                                             :> (ReqBody '[JSON] Value
                                                                 :> PostAccepted
                                                                      '[JSON]
                                                                      ApiSerialisedTransaction))))
                                                    :<|> (("wallets"
                                                           :> (Capture "walletId" (ApiT WalletId)
                                                               :> ("transactions-decode"
                                                                   :> (ReqBody
                                                                         '[JSON]
                                                                         ApiSerialisedTransaction
                                                                       :> PostAccepted
                                                                            '[JSON] Value))))
                                                          :<|> SubmitTransaction))))))))))
forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client (Proxy ("v2" :> ShelleyTransactions Value)
forall k (t :: k). Proxy t
Proxy @("v2" :> (ShelleyTransactions Aeson.Value)))

        _postExternalTransaction :: Client ClientM ("v2" :> Proxy_)
_postExternalTransaction
            = Proxy ("v2" :> Proxy_) -> Client ClientM ("v2" :> Proxy_)
forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client (Proxy ("v2" :> Proxy_)
forall k (t :: k). Proxy t
Proxy @("v2" :> Proxy_))
    in
        TransactionClient :: (ApiT WalletId
 -> Maybe Iso8601Time
 -> Maybe Iso8601Time
 -> Maybe (ApiT SortOrder)
 -> Bool
 -> ClientM [ApiTransactionT Value])
-> (ApiT WalletId
    -> ApiSignTransactionPostData -> ClientM ApiSerialisedTransaction)
-> (ApiT WalletId
    -> PostTransactionOldDataT Value
    -> ClientM (ApiTransactionT Value))
-> (ApiT WalletId
    -> PostTransactionFeeOldDataT Value -> ClientM ApiFee)
-> (ApiBytesT 'Base64 SerialisedTx -> ClientM ApiTxId)
-> (ApiT WalletId -> ApiTxId -> ClientM NoContent)
-> (ApiT WalletId
    -> ApiTxId -> TxMetadataSchema -> ClientM (ApiTransactionT Value))
-> (ApiT WalletId
    -> ApiConstructTransactionDataT Value
    -> ClientM (ApiConstructTransactionT Value))
-> (ApiT WalletId
    -> ApiBalanceTransactionPostDataT Value
    -> ClientM ApiSerialisedTransaction)
-> (ApiT WalletId
    -> ApiSerialisedTransaction
    -> ClientM (ApiDecodedTransactionT Value))
-> (ApiT WalletId -> ApiSerialisedTransaction -> ClientM ApiTxId)
-> TransactionClient
TransactionClient
            { $sel:listTransactions:TransactionClient :: ApiT WalletId
-> Maybe Iso8601Time
-> Maybe Iso8601Time
-> Maybe (ApiT SortOrder)
-> Bool
-> ClientM [ApiTransactionT Value]
listTransactions = (ApiT WalletId
-> Maybe MinWithdrawal
-> Maybe Iso8601Time
-> Maybe Iso8601Time
-> Maybe (ApiT SortOrder)
-> Bool
-> ClientM [Value]
`_listTransactions` Maybe MinWithdrawal
forall a. Maybe a
Nothing)
            , $sel:signTransaction:TransactionClient :: ApiT WalletId
-> ApiSignTransactionPostData -> ClientM ApiSerialisedTransaction
signTransaction = ApiT WalletId
-> ApiSignTransactionPostData -> ClientM ApiSerialisedTransaction
_signTransaction
            , $sel:postTransaction:TransactionClient :: ApiT WalletId
-> PostTransactionOldDataT Value -> ClientM (ApiTransactionT Value)
postTransaction = ApiT WalletId -> Value -> ClientM Value
ApiT WalletId
-> PostTransactionOldDataT Value -> ClientM (ApiTransactionT Value)
_postTransaction
            , $sel:postTransactionFee:TransactionClient :: ApiT WalletId -> PostTransactionFeeOldDataT Value -> ClientM ApiFee
postTransactionFee = ApiT WalletId -> Value -> ClientM ApiFee
ApiT WalletId -> PostTransactionFeeOldDataT Value -> ClientM ApiFee
_postTransactionFee
            , $sel:postExternalTransaction:TransactionClient :: ApiBytesT 'Base64 SerialisedTx -> ClientM ApiTxId
postExternalTransaction = ApiT SealedTx -> ClientM ApiTxId
_postExternalTransaction (ApiT SealedTx -> ClientM ApiTxId)
-> (ApiBytesT 'Base64 SerialisedTx -> ApiT SealedTx)
-> ApiBytesT 'Base64 SerialisedTx
-> ClientM ApiTxId
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ApiBytesT 'Base64 SerialisedTx -> ApiT SealedTx
forall (base :: Base). ApiBytesT base SerialisedTx -> ApiT SealedTx
fromSerialisedTx
            , $sel:deleteTransaction:TransactionClient :: ApiT WalletId -> ApiTxId -> ClientM NoContent
deleteTransaction = ApiT WalletId -> ApiTxId -> ClientM NoContent
_deleteTransaction
            , $sel:getTransaction:TransactionClient :: ApiT WalletId
-> ApiTxId -> TxMetadataSchema -> ClientM (ApiTransactionT Value)
getTransaction =
                \ApiT WalletId
wid ApiTxId
txid TxMetadataSchema
metadataSchema ->
                    ApiT WalletId -> ApiTxId -> Bool -> ClientM Value
_getTransaction ApiT WalletId
wid ApiTxId
txid (TxMetadataSchema -> Bool
toSimpleMetadataFlag TxMetadataSchema
metadataSchema)
            , $sel:constructTransaction:TransactionClient :: ApiT WalletId
-> ApiConstructTransactionDataT Value
-> ClientM (ApiConstructTransactionT Value)
constructTransaction = ApiT WalletId -> Value -> ClientM Value
ApiT WalletId
-> ApiConstructTransactionDataT Value
-> ClientM (ApiConstructTransactionT Value)
_constructTransaction
            , $sel:balanceTransaction:TransactionClient :: ApiT WalletId
-> ApiBalanceTransactionPostDataT Value
-> ClientM ApiSerialisedTransaction
balanceTransaction = ApiT WalletId -> Value -> ClientM ApiSerialisedTransaction
ApiT WalletId
-> ApiBalanceTransactionPostDataT Value
-> ClientM ApiSerialisedTransaction
_balanceTransaction
            , $sel:decodeTransaction:TransactionClient :: ApiT WalletId
-> ApiSerialisedTransaction
-> ClientM (ApiDecodedTransactionT Value)
decodeTransaction = ApiT WalletId -> ApiSerialisedTransaction -> ClientM Value
ApiT WalletId
-> ApiSerialisedTransaction
-> ClientM (ApiDecodedTransactionT Value)
_decodeTransaction
            , $sel:submitTransaction:TransactionClient :: ApiT WalletId -> ApiSerialisedTransaction -> ClientM ApiTxId
submitTransaction = ApiT WalletId -> ApiSerialisedTransaction -> ClientM ApiTxId
_submitTransaction
            }

fromSerialisedTx :: ApiBytesT base SerialisedTx -> ApiT SealedTx
fromSerialisedTx :: ApiBytesT base SerialisedTx -> ApiT SealedTx
fromSerialisedTx = SealedTx -> ApiT SealedTx
forall a. a -> ApiT a
ApiT (SealedTx -> ApiT SealedTx)
-> (ApiBytesT base SerialisedTx -> SealedTx)
-> ApiBytesT base SerialisedTx
-> ApiT SealedTx
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HasCallStack => ByteString -> SealedTx
ByteString -> SealedTx
unsafeSealedTxFromBytes (ByteString -> SealedTx)
-> (ApiBytesT base SerialisedTx -> ByteString)
-> ApiBytesT base SerialisedTx
-> SealedTx
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((ByteString -> Const ByteString ByteString)
 -> ApiBytesT base SerialisedTx
 -> Const ByteString (ApiBytesT base SerialisedTx))
-> ApiBytesT base SerialisedTx -> ByteString
forall a s. ((a -> Const a a) -> s -> Const a s) -> s -> a
view (IsLabel
  "getApiBytesT"
  ((SerialisedTx -> Const ByteString SerialisedTx)
   -> ApiBytesT base SerialisedTx
   -> Const ByteString (ApiBytesT base SerialisedTx))
(SerialisedTx -> Const ByteString SerialisedTx)
-> ApiBytesT base SerialisedTx
-> Const ByteString (ApiBytesT base SerialisedTx)
#getApiBytesT ((SerialisedTx -> Const ByteString SerialisedTx)
 -> ApiBytesT base SerialisedTx
 -> Const ByteString (ApiBytesT base SerialisedTx))
-> ((ByteString -> Const ByteString ByteString)
    -> SerialisedTx -> Const ByteString SerialisedTx)
-> (ByteString -> Const ByteString ByteString)
-> ApiBytesT base SerialisedTx
-> Const ByteString (ApiBytesT base SerialisedTx)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IsLabel
  "payload"
  ((ByteString -> Const ByteString ByteString)
   -> SerialisedTx -> Const ByteString SerialisedTx)
(ByteString -> Const ByteString ByteString)
-> SerialisedTx -> Const ByteString SerialisedTx
#payload)

-- | Produces a 'TransactionClient n' working against the /byron-wallets API.
byronTransactionClient
    :: TransactionClient
byronTransactionClient :: TransactionClient
byronTransactionClient =
    let
        ApiT WalletId -> Value -> ClientM Value
_constructTransaction
            :<|> ApiT WalletId
-> ApiSignTransactionPostData -> ClientM ApiSerialisedTransaction
_signTransaction
            :<|> ApiT WalletId
-> Maybe Iso8601Time
-> Maybe Iso8601Time
-> Maybe (ApiT SortOrder)
-> ClientM [Value]
_listTransactions
            :<|> ApiT WalletId -> ApiTxId -> ClientM Value
_getTransaction
            :<|> ApiT WalletId -> ApiTxId -> ClientM NoContent
_deleteTransaction
            :<|> ApiT WalletId -> Value -> ClientM Value
_postTransaction
            :<|> ApiT WalletId -> Value -> ClientM ApiFee
_postTransactionFee
            = Proxy
  ("v2"
   :> (("byron-wallets"
        :> (Capture "walletId" (ApiT WalletId)
            :> ("transactions-construct"
                :> (ReqBody '[JSON] Value :> PostAccepted '[JSON] Value))))
       :<|> (SignByronTransaction Value
             :<|> (("byron-wallets"
                    :> (Capture "walletId" (ApiT WalletId)
                        :> ("transactions"
                            :> (QueryParam "start" Iso8601Time
                                :> (QueryParam "end" Iso8601Time
                                    :> (QueryParam "order" (ApiT SortOrder)
                                        :> Get '[JSON] [Value]))))))
                   :<|> (("byron-wallets"
                          :> (Capture "walletId" (ApiT WalletId)
                              :> ("transactions"
                                  :> (Capture "transactionId" ApiTxId :> Get '[JSON] Value))))
                         :<|> (DeleteByronTransaction
                               :<|> (("byron-wallets"
                                      :> (Capture "walletId" (ApiT WalletId)
                                          :> ("transactions"
                                              :> (ReqBody '[JSON] Value
                                                  :> PostAccepted '[JSON] Value))))
                                     :<|> ("byron-wallets"
                                           :> (Capture "walletId" (ApiT WalletId)
                                               :> ("payment-fees"
                                                   :> (ReqBody '[JSON] Value
                                                       :> PostAccepted '[JSON] ApiFee)))))))))))
-> Client
     ClientM
     ("v2"
      :> (("byron-wallets"
           :> (Capture "walletId" (ApiT WalletId)
               :> ("transactions-construct"
                   :> (ReqBody '[JSON] Value :> PostAccepted '[JSON] Value))))
          :<|> (SignByronTransaction Value
                :<|> (("byron-wallets"
                       :> (Capture "walletId" (ApiT WalletId)
                           :> ("transactions"
                               :> (QueryParam "start" Iso8601Time
                                   :> (QueryParam "end" Iso8601Time
                                       :> (QueryParam "order" (ApiT SortOrder)
                                           :> Get '[JSON] [Value]))))))
                      :<|> (("byron-wallets"
                             :> (Capture "walletId" (ApiT WalletId)
                                 :> ("transactions"
                                     :> (Capture "transactionId" ApiTxId :> Get '[JSON] Value))))
                            :<|> (DeleteByronTransaction
                                  :<|> (("byron-wallets"
                                         :> (Capture "walletId" (ApiT WalletId)
                                             :> ("transactions"
                                                 :> (ReqBody '[JSON] Value
                                                     :> PostAccepted '[JSON] Value))))
                                        :<|> ("byron-wallets"
                                              :> (Capture "walletId" (ApiT WalletId)
                                                  :> ("payment-fees"
                                                      :> (ReqBody '[JSON] Value
                                                          :> PostAccepted '[JSON] ApiFee)))))))))))
forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client (Proxy ("v2" :> ByronTransactions Value)
forall k (t :: k). Proxy t
Proxy @("v2" :> (ByronTransactions Aeson.Value)))

        _postExternalTransaction :: Client ClientM ("v2" :> Proxy_)
_postExternalTransaction
            = Proxy ("v2" :> Proxy_) -> Client ClientM ("v2" :> Proxy_)
forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client (Proxy ("v2" :> Proxy_)
forall k (t :: k). Proxy t
Proxy @("v2" :> Proxy_))

    in TransactionClient :: (ApiT WalletId
 -> Maybe Iso8601Time
 -> Maybe Iso8601Time
 -> Maybe (ApiT SortOrder)
 -> Bool
 -> ClientM [ApiTransactionT Value])
-> (ApiT WalletId
    -> ApiSignTransactionPostData -> ClientM ApiSerialisedTransaction)
-> (ApiT WalletId
    -> PostTransactionOldDataT Value
    -> ClientM (ApiTransactionT Value))
-> (ApiT WalletId
    -> PostTransactionFeeOldDataT Value -> ClientM ApiFee)
-> (ApiBytesT 'Base64 SerialisedTx -> ClientM ApiTxId)
-> (ApiT WalletId -> ApiTxId -> ClientM NoContent)
-> (ApiT WalletId
    -> ApiTxId -> TxMetadataSchema -> ClientM (ApiTransactionT Value))
-> (ApiT WalletId
    -> ApiConstructTransactionDataT Value
    -> ClientM (ApiConstructTransactionT Value))
-> (ApiT WalletId
    -> ApiBalanceTransactionPostDataT Value
    -> ClientM ApiSerialisedTransaction)
-> (ApiT WalletId
    -> ApiSerialisedTransaction
    -> ClientM (ApiDecodedTransactionT Value))
-> (ApiT WalletId -> ApiSerialisedTransaction -> ClientM ApiTxId)
-> TransactionClient
TransactionClient
        { $sel:listTransactions:TransactionClient :: ApiT WalletId
-> Maybe Iso8601Time
-> Maybe Iso8601Time
-> Maybe (ApiT SortOrder)
-> Bool
-> ClientM [ApiTransactionT Value]
listTransactions = \ApiT WalletId
wid Maybe Iso8601Time
start Maybe Iso8601Time
end Maybe (ApiT SortOrder)
order Bool
_ ->
            ApiT WalletId
-> Maybe Iso8601Time
-> Maybe Iso8601Time
-> Maybe (ApiT SortOrder)
-> ClientM [Value]
_listTransactions ApiT WalletId
wid Maybe Iso8601Time
start Maybe Iso8601Time
end Maybe (ApiT SortOrder)
order
        , $sel:signTransaction:TransactionClient :: ApiT WalletId
-> ApiSignTransactionPostData -> ClientM ApiSerialisedTransaction
signTransaction = ApiT WalletId
-> ApiSignTransactionPostData -> ClientM ApiSerialisedTransaction
_signTransaction
        , $sel:postTransaction:TransactionClient :: ApiT WalletId
-> PostTransactionOldDataT Value -> ClientM (ApiTransactionT Value)
postTransaction = ApiT WalletId -> Value -> ClientM Value
ApiT WalletId
-> PostTransactionOldDataT Value -> ClientM (ApiTransactionT Value)
_postTransaction
        , $sel:postTransactionFee:TransactionClient :: ApiT WalletId -> PostTransactionFeeOldDataT Value -> ClientM ApiFee
postTransactionFee = ApiT WalletId -> Value -> ClientM ApiFee
ApiT WalletId -> PostTransactionFeeOldDataT Value -> ClientM ApiFee
_postTransactionFee
        , $sel:postExternalTransaction:TransactionClient :: ApiBytesT 'Base64 SerialisedTx -> ClientM ApiTxId
postExternalTransaction = ApiT SealedTx -> ClientM ApiTxId
_postExternalTransaction (ApiT SealedTx -> ClientM ApiTxId)
-> (ApiBytesT 'Base64 SerialisedTx -> ApiT SealedTx)
-> ApiBytesT 'Base64 SerialisedTx
-> ClientM ApiTxId
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ApiBytesT 'Base64 SerialisedTx -> ApiT SealedTx
forall (base :: Base). ApiBytesT base SerialisedTx -> ApiT SealedTx
fromSerialisedTx
        , $sel:deleteTransaction:TransactionClient :: ApiT WalletId -> ApiTxId -> ClientM NoContent
deleteTransaction = ApiT WalletId -> ApiTxId -> ClientM NoContent
_deleteTransaction
        , $sel:getTransaction:TransactionClient :: ApiT WalletId
-> ApiTxId -> TxMetadataSchema -> ClientM (ApiTransactionT Value)
getTransaction = \ApiT WalletId
wid ApiTxId
txid TxMetadataSchema
_  -> ApiT WalletId -> ApiTxId -> ClientM Value
_getTransaction ApiT WalletId
wid ApiTxId
txid
        , $sel:constructTransaction:TransactionClient :: ApiT WalletId
-> ApiConstructTransactionDataT Value
-> ClientM (ApiConstructTransactionT Value)
constructTransaction = ApiT WalletId -> Value -> ClientM Value
ApiT WalletId
-> ApiConstructTransactionDataT Value
-> ClientM (ApiConstructTransactionT Value)
_constructTransaction
        , $sel:balanceTransaction:TransactionClient :: ApiT WalletId
-> ApiBalanceTransactionPostDataT Value
-> ClientM ApiSerialisedTransaction
balanceTransaction = [Char]
-> ApiT WalletId -> Value -> ClientM ApiSerialisedTransaction
forall a. HasCallStack => [Char] -> a
error [Char]
"balance transaction endpoint not supported for byron"
        , $sel:decodeTransaction:TransactionClient :: ApiT WalletId
-> ApiSerialisedTransaction
-> ClientM (ApiDecodedTransactionT Value)
decodeTransaction = [Char]
-> ApiT WalletId -> ApiSerialisedTransaction -> ClientM Value
forall a. HasCallStack => [Char] -> a
error [Char]
"decode transaction endpoint not supported for byron"
        , $sel:submitTransaction:TransactionClient :: ApiT WalletId -> ApiSerialisedTransaction -> ClientM ApiTxId
submitTransaction = [Char]
-> ApiT WalletId -> ApiSerialisedTransaction -> ClientM ApiTxId
forall a. HasCallStack => [Char] -> a
error [Char]
"submit transaction endpoint not supported for byron"
        }

-- | Produces an 'AddressClient n' working against the /wallets API
addressClient
    :: AddressClient
addressClient :: AddressClient
addressClient =
    let
        ApiT WalletId -> Maybe (ApiT AddressState) -> ClientM [Value]
_listAddresses
            :<|> ApiAddressInspectData -> ClientM ApiAddressInspect
_inspectAddress
            :<|> ApiAddressData -> ClientM AnyAddress
_postScriptAddress
            = Proxy
  ("v2"
   :> (("wallets"
        :> (Capture "walletId" (ApiT WalletId)
            :> ("addresses"
                :> (QueryParam "state" (ApiT AddressState)
                    :> Get '[JSON] [Value]))))
       :<|> (InspectAddress :<|> PostAnyAddress Value)))
-> Client
     ClientM
     ("v2"
      :> (("wallets"
           :> (Capture "walletId" (ApiT WalletId)
               :> ("addresses"
                   :> (QueryParam "state" (ApiT AddressState)
                       :> Get '[JSON] [Value]))))
          :<|> (InspectAddress :<|> PostAnyAddress Value)))
forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client (Proxy ("v2" :> Addresses Value)
forall k (t :: k). Proxy t
Proxy @("v2" :> Addresses Aeson.Value))
    in
        AddressClient :: (ApiT WalletId -> Maybe (ApiT AddressState) -> ClientM [Value])
-> (Text -> ClientM Value)
-> (ApiT WalletId
    -> ApiPostRandomAddressData -> ClientM (ApiAddressT Value))
-> (ApiT WalletId -> ApiAddressIdT Value -> ClientM NoContent)
-> (ApiT WalletId
    -> ApiPutAddressesDataT Value -> ClientM NoContent)
-> AddressClient
AddressClient
            { $sel:listAddresses:AddressClient :: ApiT WalletId -> Maybe (ApiT AddressState) -> ClientM [Value]
listAddresses = ApiT WalletId -> Maybe (ApiT AddressState) -> ClientM [Value]
_listAddresses
            , $sel:inspectAddress:AddressClient :: Text -> ClientM Value
inspectAddress =
                (ApiAddressInspect -> Value)
-> ClientM ApiAddressInspect -> ClientM Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ApiAddressInspect -> Value
unApiAddressInspect
                (ClientM ApiAddressInspect -> ClientM Value)
-> (Text -> ClientM ApiAddressInspect) -> Text -> ClientM Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ApiAddressInspectData -> ClientM ApiAddressInspect
_inspectAddress
                (ApiAddressInspectData -> ClientM ApiAddressInspect)
-> (Text -> ApiAddressInspectData)
-> Text
-> ClientM ApiAddressInspect
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> ApiAddressInspectData
ApiAddressInspectData
            , $sel:postRandomAddress:AddressClient :: ApiT WalletId
-> ApiPostRandomAddressData -> ClientM (ApiAddressT Value)
postRandomAddress = \ApiT WalletId
_ ApiPostRandomAddressData
_ -> [Char] -> ClientM Value
forall (m :: * -> *) a. (MonadIO m, HasCallStack) => [Char] -> m a
throwString [Char]
"feature unavailable."
            , $sel:putRandomAddress:AddressClient :: ApiT WalletId -> ApiAddressIdT Value -> ClientM NoContent
putRandomAddress  = \ApiT WalletId
_ ApiAddressIdT Value
_ -> [Char] -> ClientM NoContent
forall (m :: * -> *) a. (MonadIO m, HasCallStack) => [Char] -> m a
throwString [Char]
"feature unavailable."
            , $sel:putRandomAddresses:AddressClient :: ApiT WalletId -> ApiPutAddressesDataT Value -> ClientM NoContent
putRandomAddresses = \ApiT WalletId
_ ApiPutAddressesDataT Value
_ -> [Char] -> ClientM NoContent
forall (m :: * -> *) a. (MonadIO m, HasCallStack) => [Char] -> m a
throwString [Char]
"feature unavailable."
            }

-- | Produces an 'AddressClient n' working against the /wallets API
byronAddressClient
    :: AddressClient
byronAddressClient :: AddressClient
byronAddressClient =
    let
        ApiT WalletId -> Maybe (ApiT AddressState) -> ClientM [Value]
_ :<|> ApiAddressInspectData -> ClientM ApiAddressInspect
_inspectAddress
          :<|> ApiAddressData -> ClientM AnyAddress
_postScriptAddress
            = Proxy
  ("v2"
   :> (("wallets"
        :> (Capture "walletId" (ApiT WalletId)
            :> ("addresses"
                :> (QueryParam "state" (ApiT AddressState)
                    :> Get '[JSON] [Value]))))
       :<|> (InspectAddress :<|> PostAnyAddress Value)))
-> Client
     ClientM
     ("v2"
      :> (("wallets"
           :> (Capture "walletId" (ApiT WalletId)
               :> ("addresses"
                   :> (QueryParam "state" (ApiT AddressState)
                       :> Get '[JSON] [Value]))))
          :<|> (InspectAddress :<|> PostAnyAddress Value)))
forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client (Proxy ("v2" :> Addresses Value)
forall k (t :: k). Proxy t
Proxy @("v2" :> Addresses Aeson.Value))

        ApiT WalletId -> ApiPostRandomAddressData -> ClientM Value
_postRandomAddress
            :<|> ApiT WalletId -> Text -> ClientM NoContent
_putRandomAddress
            :<|> ApiT WalletId -> Value -> ClientM NoContent
_putRandomAddresses
            :<|> ApiT WalletId -> Maybe (ApiT AddressState) -> ClientM [Value]
_listAddresses
            = Proxy
  ("v2"
   :> (("byron-wallets"
        :> (Capture "walletId" (ApiT WalletId)
            :> ("addresses"
                :> (ReqBody '[JSON] ApiPostRandomAddressData
                    :> PostCreated '[JSON] Value))))
       :<|> (("byron-wallets"
              :> (Capture "walletId" (ApiT WalletId)
                  :> ("addresses" :> (Capture "addressId" Text :> PutNoContent))))
             :<|> (("byron-wallets"
                    :> (Capture "walletId" (ApiT WalletId)
                        :> ("addresses" :> (ReqBody '[JSON] Value :> PutNoContent))))
                   :<|> ("byron-wallets"
                         :> (Capture "walletId" (ApiT WalletId)
                             :> ("addresses"
                                 :> (QueryParam "state" (ApiT AddressState)
                                     :> Get '[JSON] [Value]))))))))
-> Client
     ClientM
     ("v2"
      :> (("byron-wallets"
           :> (Capture "walletId" (ApiT WalletId)
               :> ("addresses"
                   :> (ReqBody '[JSON] ApiPostRandomAddressData
                       :> PostCreated '[JSON] Value))))
          :<|> (("byron-wallets"
                 :> (Capture "walletId" (ApiT WalletId)
                     :> ("addresses" :> (Capture "addressId" Text :> PutNoContent))))
                :<|> (("byron-wallets"
                       :> (Capture "walletId" (ApiT WalletId)
                           :> ("addresses" :> (ReqBody '[JSON] Value :> PutNoContent))))
                      :<|> ("byron-wallets"
                            :> (Capture "walletId" (ApiT WalletId)
                                :> ("addresses"
                                    :> (QueryParam "state" (ApiT AddressState)
                                        :> Get '[JSON] [Value]))))))))
forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client (Proxy ("v2" :> ByronAddresses Value)
forall k (t :: k). Proxy t
Proxy @("v2" :> ByronAddresses Aeson.Value))
    in
        AddressClient :: (ApiT WalletId -> Maybe (ApiT AddressState) -> ClientM [Value])
-> (Text -> ClientM Value)
-> (ApiT WalletId
    -> ApiPostRandomAddressData -> ClientM (ApiAddressT Value))
-> (ApiT WalletId -> ApiAddressIdT Value -> ClientM NoContent)
-> (ApiT WalletId
    -> ApiPutAddressesDataT Value -> ClientM NoContent)
-> AddressClient
AddressClient
            { $sel:listAddresses:AddressClient :: ApiT WalletId -> Maybe (ApiT AddressState) -> ClientM [Value]
listAddresses = ApiT WalletId -> Maybe (ApiT AddressState) -> ClientM [Value]
_listAddresses
            , $sel:inspectAddress:AddressClient :: Text -> ClientM Value
inspectAddress =
                (ApiAddressInspect -> Value)
-> ClientM ApiAddressInspect -> ClientM Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ApiAddressInspect -> Value
unApiAddressInspect
                (ClientM ApiAddressInspect -> ClientM Value)
-> (Text -> ClientM ApiAddressInspect) -> Text -> ClientM Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ApiAddressInspectData -> ClientM ApiAddressInspect
_inspectAddress
                (ApiAddressInspectData -> ClientM ApiAddressInspect)
-> (Text -> ApiAddressInspectData)
-> Text
-> ClientM ApiAddressInspect
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> ApiAddressInspectData
ApiAddressInspectData
            , $sel:postRandomAddress:AddressClient :: ApiT WalletId
-> ApiPostRandomAddressData -> ClientM (ApiAddressT Value)
postRandomAddress = ApiT WalletId -> ApiPostRandomAddressData -> ClientM Value
ApiT WalletId
-> ApiPostRandomAddressData -> ClientM (ApiAddressT Value)
_postRandomAddress
            , $sel:putRandomAddress:AddressClient :: ApiT WalletId -> ApiAddressIdT Value -> ClientM NoContent
putRandomAddress = ApiT WalletId -> Text -> ClientM NoContent
ApiT WalletId -> ApiAddressIdT Value -> ClientM NoContent
_putRandomAddress
            , $sel:putRandomAddresses:AddressClient :: ApiT WalletId -> ApiPutAddressesDataT Value -> ClientM NoContent
putRandomAddresses = ApiT WalletId -> Value -> ClientM NoContent
ApiT WalletId -> ApiPutAddressesDataT Value -> ClientM NoContent
_putRandomAddresses
            }

-- | Produces an 'StakePoolsClient n' working against the /stake-pools API
stakePoolClient
    :: forall apiPool. Aeson.FromJSON apiPool => StakePoolClient apiPool
stakePoolClient :: StakePoolClient apiPool
stakePoolClient =
    let
        Maybe (ApiT Coin) -> ClientM [apiPool]
_listPools
            :<|> ApiPoolId -> ApiT WalletId -> ApiWalletPassphrase -> ClientM Value
_joinStakePool
            :<|> ApiT WalletId -> ApiWalletPassphrase -> ClientM Value
_quitStakePool
            :<|> ApiT WalletId -> ClientM ApiFee
_delegationFee
            :<|> ApiT WalletId -> ClientM Value
_listStakeKeys
            :<|> ApiMaintenanceActionPostData -> ClientM NoContent
_postPoolMaintenance
            :<|> ClientM ApiMaintenanceAction
_getPoolMaintenance
            = Proxy
  ("v2"
   :> (ListStakePools apiPool
       :<|> (("stake-pools"
              :> (Capture "stakePoolId" ApiPoolId
                  :> ("wallets"
                      :> (Capture "walletId" (ApiT WalletId)
                          :> (ReqBody '[JSON] ApiWalletPassphrase
                              :> PutAccepted '[JSON] Value)))))
             :<|> (("stake-pools"
                    :> ("*"
                        :> ("wallets"
                            :> (Capture "walletId" (ApiT WalletId)
                                :> (ReqBody '[JSON] ApiWalletPassphrase
                                    :> DeleteAccepted '[JSON] Value)))))
                   :<|> (DelegationFee
                         :<|> (("wallets"
                                :> (Capture "walletId" (ApiT WalletId)
                                    :> ("stake-keys" :> Get '[JSON] Value)))
                               :<|> (PostPoolMaintenance :<|> GetPoolMaintenance)))))))
-> Client
     ClientM
     ("v2"
      :> (ListStakePools apiPool
          :<|> (("stake-pools"
                 :> (Capture "stakePoolId" ApiPoolId
                     :> ("wallets"
                         :> (Capture "walletId" (ApiT WalletId)
                             :> (ReqBody '[JSON] ApiWalletPassphrase
                                 :> PutAccepted '[JSON] Value)))))
                :<|> (("stake-pools"
                       :> ("*"
                           :> ("wallets"
                               :> (Capture "walletId" (ApiT WalletId)
                                   :> (ReqBody '[JSON] ApiWalletPassphrase
                                       :> DeleteAccepted '[JSON] Value)))))
                      :<|> (DelegationFee
                            :<|> (("wallets"
                                   :> (Capture "walletId" (ApiT WalletId)
                                       :> ("stake-keys" :> Get '[JSON] Value)))
                                  :<|> (PostPoolMaintenance :<|> GetPoolMaintenance)))))))
forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client (Proxy ("v2" :> StakePools Value apiPool)
forall k (t :: k). Proxy t
Proxy @("v2" :> StakePools Aeson.Value apiPool))
    in
        StakePoolClient :: forall apiPool.
(Maybe (ApiT Coin) -> ClientM [apiPool])
-> (ApiPoolId
    -> ApiT WalletId
    -> ApiWalletPassphrase
    -> ClientM (ApiTransactionT Value))
-> (ApiT WalletId
    -> ApiWalletPassphrase -> ClientM (ApiTransactionT Value))
-> StakePoolClient apiPool
StakePoolClient
            { $sel:listPools:StakePoolClient :: Maybe (ApiT Coin) -> ClientM [apiPool]
listPools = Maybe (ApiT Coin) -> ClientM [apiPool]
_listPools
            , $sel:joinStakePool:StakePoolClient :: ApiPoolId
-> ApiT WalletId
-> ApiWalletPassphrase
-> ClientM (ApiTransactionT Value)
joinStakePool = ApiPoolId -> ApiT WalletId -> ApiWalletPassphrase -> ClientM Value
ApiPoolId
-> ApiT WalletId
-> ApiWalletPassphrase
-> ClientM (ApiTransactionT Value)
_joinStakePool
            , $sel:quitStakePool:StakePoolClient :: ApiT WalletId
-> ApiWalletPassphrase -> ClientM (ApiTransactionT Value)
quitStakePool = ApiT WalletId -> ApiWalletPassphrase -> ClientM Value
ApiT WalletId
-> ApiWalletPassphrase -> ClientM (ApiTransactionT Value)
_quitStakePool
            }

-- | Produces a 'NetworkClient'
networkClient
    :: NetworkClient
networkClient :: NetworkClient
networkClient =
    let
        ClientM ApiNetworkInformation
_networkInformation
            :<|> ClientM ApiNetworkParameters
_networkParameters
            :<|> Bool -> ClientM ApiNetworkClock
_networkClock
            = Proxy ("v2" :> Network) -> Client ClientM ("v2" :> Network)
forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client (Proxy ("v2" :> Network)
forall k (t :: k). Proxy t
Proxy @("v2" :> Network))
    in
        NetworkClient :: ClientM ApiNetworkInformation
-> ClientM ApiNetworkParameters
-> (Bool -> ClientM ApiNetworkClock)
-> NetworkClient
NetworkClient
            { $sel:networkInformation:NetworkClient :: ClientM ApiNetworkInformation
networkInformation = ClientM ApiNetworkInformation
_networkInformation
            , $sel:networkParameters:NetworkClient :: ClientM ApiNetworkParameters
networkParameters = ClientM ApiNetworkParameters
_networkParameters
            , $sel:networkClock:NetworkClient :: Bool -> ClientM ApiNetworkClock
networkClock = Bool -> ClientM ApiNetworkClock
_networkClock
            }

--
-- Type families
--

type instance ApiAddressT Aeson.Value = Aeson.Value
type instance ApiStakeKeysT Aeson.Value = Aeson.Value
type instance ApiAddressIdT Aeson.Value = Text
type instance ApiCoinSelectionT Aeson.Value = Aeson.Value
type instance ApiSelectCoinsDataT Aeson.Value = Aeson.Value
type instance ApiTransactionT Aeson.Value = Aeson.Value
type instance ApiConstructTransactionT Aeson.Value = Aeson.Value
type instance ApiConstructTransactionDataT Aeson.Value = Aeson.Value
type instance PostTransactionOldDataT Aeson.Value = Aeson.Value
type instance PostTransactionFeeOldDataT Aeson.Value = Aeson.Value
type instance ApiPutAddressesDataT Aeson.Value = Aeson.Value
type instance ApiBalanceTransactionPostDataT Aeson.Value = Aeson.Value
type instance ApiDecodedTransactionT Aeson.Value = Aeson.Value