-- | Cardano utility endpoints

{-# OPTIONS_HADDOCK hide #-}

module Blockfrost.API.Cardano.Utils
  where

import Data.Text
import Servant.API
import Servant.API.Generic

import Blockfrost.Types.Cardano.Utils
import Blockfrost.Types.Shared.CBOR

data UtilsAPI route =
  UtilsAPI
    {
      forall route.
UtilsAPI route
-> route
   :- (Summary "Derive an address"
       :> (Description "Derive Shelley address from an xpub."
           :> ("addresses"
               :> ("xpub"
                   :> (Capture "xpub" Text
                       :> (Capture "role" Integer
                           :> (Capture "Index" Integer :> Get '[JSON] DerivedAddress)))))))
_deriveAddr
        :: route
        :- Summary "Derive an address"
        :> Description "Derive Shelley address from an xpub."
        :> "addresses"
        :> "xpub"
        :> Capture "xpub" Text
        :> Capture "role" Integer
        :> Capture "Index" Integer
        :> Get '[JSON] DerivedAddress

    , forall route.
UtilsAPI route
-> route
   :- (Summary "Submit a transaction for execution units evaluation"
       :> (Description
             "Submit an already serialized transaction to evaluate how much execution units it requires."
           :> ("txs"
               :> ("evaluate"
                   :> (ReqBody '[CBOR] CBORString :> Post '[JSON] TxEval)))))
_txEvaluate
        :: route
        :- Summary "Submit a transaction for execution units evaluation"
        :> Description "Submit an already serialized transaction to evaluate \
                       \how much execution units it requires."
        :> "txs"
        :> "evaluate"
        :> ReqBody '[CBOR] CBORString
        :> Post '[JSON] TxEval

    , forall route.
UtilsAPI route
-> route
   :- (Summary
         "Submit a transaction for execution units evaluation (additional UTXO set)"
       :> (Description
             "Submit a JSON payload with transaction CBOR and additional UTXO set to evaluate how much execution units it requires."
           :> ("txs"
               :> ("evaluate"
                   :> ("utxos"
                       :> (ReqBody '[JSON] TxEvalInput :> Post '[JSON] TxEval))))))
_txEvaluateUTXOs
        :: route
        :- Summary "Submit a transaction for execution units evaluation (additional UTXO set)"
        :> Description "Submit a JSON payload with transaction CBOR and additional UTXO set \
                       \to evaluate how much execution units it requires."
        :> "txs"
        :> "evaluate"
        :> "utxos"
        :> ReqBody '[JSON] TxEvalInput
        :> Post '[JSON] TxEval

    } deriving (forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall route x. Rep (UtilsAPI route) x -> UtilsAPI route
forall route x. UtilsAPI route -> Rep (UtilsAPI route) x
$cto :: forall route x. Rep (UtilsAPI route) x -> UtilsAPI route
$cfrom :: forall route x. UtilsAPI route -> Rep (UtilsAPI route) x
Generic)