-- | Network queries

module Blockfrost.Client.Cardano.Network
  ( getNetworkInfo
  , getNetworkEras
  ) where

import Blockfrost.API
import Blockfrost.Client.Types
import Blockfrost.Types


networkClient :: MonadBlockfrost m => Project -> NetworkAPI (AsClientT m)
networkClient :: forall (m :: * -> *).
MonadBlockfrost m =>
Project -> NetworkAPI (AsClientT m)
networkClient = forall (routes :: * -> *) mode.
GenericServant routes mode =>
ToServant routes mode -> routes mode
fromServant forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall route.
CardanoAPI route
-> route
   :- ("network"
       :> (Tag "Cardano \187 Network" :> ToServantApi NetworkAPI))
_network forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
MonadBlockfrost m =>
Project -> CardanoAPI (AsClientT m)
cardanoClient

getNetworkInfo_ :: MonadBlockfrost m => Project -> m Network
getNetworkInfo_ :: forall (m :: * -> *). MonadBlockfrost m => Project -> m Network
getNetworkInfo_ = forall route.
NetworkAPI route
-> route
   :- (Summary "Network information"
       :> (Description "Return detailed network information."
           :> Get '[JSON] Network))
_networkInfo forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
MonadBlockfrost m =>
Project -> NetworkAPI (AsClientT m)
networkClient

-- | Get detailed network information.
getNetworkInfo :: MonadBlockfrost m => m Network
getNetworkInfo :: forall (m :: * -> *). MonadBlockfrost m => m Network
getNetworkInfo = forall (m :: * -> *) a.
MonadBlockfrost m =>
(Project -> m a) -> m a
go forall (m :: * -> *). MonadBlockfrost m => Project -> m Network
getNetworkInfo_

getNetworkEras_ :: MonadBlockfrost m => Project -> m [NetworkEraSummary]
getNetworkEras_ :: forall (m :: * -> *).
MonadBlockfrost m =>
Project -> m [NetworkEraSummary]
getNetworkEras_ = forall route.
NetworkAPI route
-> route
   :- (Summary "Query summary of blockchain eras"
       :> (Description
             "Returns start and end of each era along with parameters that can vary between hard forks."
           :> ("eras" :> Get '[JSON] [NetworkEraSummary])))
_networkEras forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
MonadBlockfrost m =>
Project -> NetworkAPI (AsClientT m)
networkClient

-- | Get summarized information on each era in the network, including start, end, and variable era parameters.
getNetworkEras :: MonadBlockfrost m => m [NetworkEraSummary]
getNetworkEras :: forall (m :: * -> *). MonadBlockfrost m => m [NetworkEraSummary]
getNetworkEras = forall (m :: * -> *) a.
MonadBlockfrost m =>
(Project -> m a) -> m a
go forall (m :: * -> *).
MonadBlockfrost m =>
Project -> m [NetworkEraSummary]
getNetworkEras_